Skip to content

Commit

Permalink
Lazy knoppen toegevoegd op de verzekeringspagina
Browse files Browse the repository at this point in the history
  • Loading branch information
TinusVL committed May 7, 2024
1 parent 022b99c commit de2f974
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/views/InsurancesHome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<a v-if="drafts.next" class="link-inline cursor-pointer" @click="getNextDrafts(drafts.next)">Volgende pagina</a>
</div>
</div>
<custom-button v-if="!drafts" @click="getDrafts()" text="Onvoltooide verzekeringen ophalen..." />
<br v-if="!drafts">
<br v-if="!drafts">

<div v-if="data">
<custom-list :items="data.results" title="Recent aangevraagd">
Expand All @@ -32,6 +35,7 @@
<a v-if="data.next" class="link-inline cursor-pointer" @click="getNextInsurances(data.next)">Volgende pagina</a>
</div>
</div>
<custom-button v-if="!data" @click="getInsurances()" text="Recent aangevraagde verzekeringen ophalen..." />
</div>
</div>
</template>
Expand All @@ -40,6 +44,7 @@
import { InsuranceRepository } from '@/repositories/insurances/insuranceRepository'
import { DraftRepository } from '@/repositories/insurances/draftRepository'
import CallToAction from '../components/customHeadlines/CallToAction.vue'
import CustomButton from '../components/CustomButton.vue'
import { ResponsibleMember } from '@/serializer/ResponsibleMember'
import RepositoryFactory from '@/repositories/repositoryFactory'
import customList from '../components/semantic/CustomList.vue'
Expand All @@ -53,17 +58,24 @@ export default defineComponent({
name: 'InsurancesHome',
components: {
'call-to-action': CallToAction,
'custom-button': CustomButton,
'multi-select': MultiSelect,
'custom-list': customList,
},
setup: () => {
const store = useStore()
store.dispatch('resetStates')
const data = ref<ArrayResult>()
const dataDisabled = ref(false);
const drafts = ref<ArrayResult>()
const draftsDisabled = ref(false);
const userData = ref<ResponsibleMember>(store.getters.user)
const getInsurances = () => {
if (dataDisabled.value) {
return;
}
dataDisabled.value = true;
RepositoryFactory.get(InsuranceRepository)
.getArray('/insurances/?page=1&page_size=10')
.then((res: ArrayResult) => {
Expand All @@ -88,6 +100,10 @@ export default defineComponent({
}
const getDrafts = () => {
if (draftsDisabled.value) {
return;
}
draftsDisabled.value = true;
RepositoryFactory.get(DraftRepository)
.getArray('/insurance_drafts/?page=1&page_size=10')
.then((res: ArrayResult) => {
Expand Down Expand Up @@ -123,13 +139,12 @@ export default defineComponent({
})
}
getInsurances()
getDrafts()
return {
addSelectionInsurances,
getInsurances,
getPreviousInsurances,
getNextInsurances,
getDrafts,
getPreviousDrafts,
getNextDrafts,
removeDraft,
Expand Down

0 comments on commit de2f974

Please sign in to comment.