From 29c7186f9a91eb4ede513add3b23b376b31a627f Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Mon, 25 Nov 2024 10:50:52 +0700 Subject: [PATCH] refactor: handle filter file customer or employee --- .../08_request-list/DocumentExpansion.vue | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/pages/08_request-list/DocumentExpansion.vue b/src/pages/08_request-list/DocumentExpansion.vue index 77543144..0b9aa25d 100644 --- a/src/pages/08_request-list/DocumentExpansion.vue +++ b/src/pages/08_request-list/DocumentExpansion.vue @@ -182,22 +182,33 @@ async function fetchRequestAttachment(type: 'customer' | 'employee') { } const currentListDocument = computed(() => { - return props.listDocument.map((v, i) => { - const fileIds = attachmentList.value[v] - ? Object.values(attachmentList.value[v]) - : []; - const fileNames = fileIds.map((id) => String(id)); - return { - no: i + 1, - documentType: v, - fileName: fileNames, - amount: fileIds.length, - documentInSystem: fileIds.length > 0, - status: attributes.value - ? (attributes.value[state.tab]?.[v] ?? docStatus[0]) - : docStatus[0], - }; - }); + return props.listDocument + .map((v, i) => { + const fileIds = attachmentList.value[v] + ? Object.values(attachmentList.value[v]) + : []; + const fileNames = fileIds.map((id) => String(id)); + return { + no: i + 1, + documentType: v, + fileName: fileNames, + amount: fileIds.length, + documentInSystem: fileIds.length > 0, + status: attributes.value + ? (attributes.value[state.tab]?.[v] ?? docStatus[0]) + : docStatus[0], + }; + }) + .filter((v) => { + const filterFileCustomer = ['passport', 'visa', 'tm6']; + const filterFileEmployee = ['citizen']; + + if (state.tab === 'customer') { + return !filterFileCustomer.includes(v.documentType); + } else { + return !filterFileEmployee.includes(v.documentType); + } + }); }); function triggerCancel() {