Skip to content

Commit

Permalink
fixed klant sub object niet switchen - WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
SudoThijn committed Oct 23, 2024
1 parent 2b5e356 commit a7dc048
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions src/views/klanten/KlantDetails.vue
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ export default {
},
data() {
return {
currentActiveKlant: undefined,
zaken: [],
taken: [],
berichten: [],
Expand All @@ -298,45 +299,55 @@ export default {
}
},
mounted() {
this.fetchKlantData(klantStore.klantItem.id);
if (klantStore.klantItem?.id) {
this.currentActiveKlant = klantStore.klantItem
this.fetchKlantData(klantStore.klantItem.id)
}
},
updated() {
// if klantStore.klantItem.id is not falsy and the currentActiveKlant is not the same as klantStore.klantItem
if (!klantStore.klantItem?.id && (JSON.stringify(this.currentActiveKlant) !== JSON.stringify(klantStore.klantItem))) {
this.currentActiveKlant = klantStore.klantItem
this.fetchKlantData(klantStore.klantItem.id)
}
},
methods: {
fetchKlantData(id) {
fetch(`/index.php/apps/zaakafhandelapp/api/klanten/${id}/zaken`)
.then(response => response.json())
.then(data => {
if (Array.isArray(data.results)) {
this.zaken = data.results;
this.zaken = data.results
}
console.log(this.zaken);
return fetch(`/index.php/apps/zaakafhandelapp/api/klanten/${id}/taken`);
console.log(this.zaken)
return fetch(`/index.php/apps/zaakafhandelapp/api/klanten/${id}/taken`)
})
.then(response => response.json())
.then(data => {
if (Array.isArray(data.results)) {
this.taken = data.results;
this.taken = data.results
}
console.log(this.taken);
return fetch(`/index.php/apps/zaakafhandelapp/api/klanten/${id}/berichten`);
console.log(this.taken)
return fetch(`/index.php/apps/zaakafhandelapp/api/klanten/${id}/berichten`)
})
.then(response => response.json())
.then(data => {
if (Array.isArray(data.results)) {
this.berichten = data.results;
this.berichten = data.results
}
console.log(this.berichten);
return fetch(`/index.php/apps/zaakafhandelapp/api/klanten/${id}/audit_trail`);
console.log(this.berichten)
return fetch(`/index.php/apps/zaakafhandelapp/api/klanten/${id}/audit_trail`)
})
.then(response => response.json())
.then(data => {
if (Array.isArray(data)) {
this.auditTrails = data;
this.auditTrails = data
}
console.log(this.auditTrails);
console.log(this.auditTrails)
})
.catch(error => {
console.error('Error fetching klant data:', error);
});
console.error('Error fetching klant data:', error)
})
},
},
}
Expand Down

0 comments on commit a7dc048

Please sign in to comment.