diff --git a/src/store/modules/contactmoment.ts b/src/store/modules/contactmoment.ts index e0a0b00..458a1f4 100644 --- a/src/store/modules/contactmoment.ts +++ b/src/store/modules/contactmoment.ts @@ -34,16 +34,25 @@ export const useContactMomentStore = defineStore('contactmomenten', { * Refresh the list of contact moments. * * @param search - Optional search query to filter the contact moments list. (default: `null`) + * @param notClosed * @throws If the HTTP request fails. * @return {Promise<{ response: Response, data: TContactMoment[], entities: ContactMoment[] }>} The response, raw data, and entities. */ - async refreshContactMomentenList(search: string = null): Promise<{ response: Response, data: TContactMoment[], entities: ContactMoment[] }> { + async refreshContactMomentenList(search: string = null, notClosed: boolean = false): Promise<{ response: Response, data: TContactMoment[], entities: ContactMoment[] }> { let endpoint = apiEndpoint if (search !== null && search !== '') { endpoint = endpoint + '?_search=' + search } + if (notClosed) { + if (search !== null && search !== '') { + endpoint = endpoint + '&status=open' + } else { + endpoint = endpoint + '?status=open' + } + } + const response = await fetch(endpoint, { method: 'GET', }) diff --git a/src/views/widgets/ContactMomentenWidget.vue b/src/views/widgets/ContactMomentenWidget.vue index ede0c1f..f55f21f 100644 --- a/src/views/widgets/ContactMomentenWidget.vue +++ b/src/views/widgets/ContactMomentenWidget.vue @@ -94,7 +94,7 @@ export default { this.loading = true Promise.all([ - contactMomentStore.refreshContactMomentenList(), + contactMomentStore.refreshContactMomentenList(null, true), klantStore.refreshKlantenList(), ]) .then(([contactMomentResponse, klantResponse]) => { @@ -162,7 +162,7 @@ export default { contactMomentStore.saveContactMoment(newContactMoment) .then(({ response }) => { if (response.ok) { - this.fetchContactMomentItems() + this.fetchContactMomentItems(null, true) } }) },