From d049782e36264e264b4a7dc7d4be78cb4b3d89f9 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Fri, 14 Jun 2024 13:03:20 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20filter=20=E0=B8=AA=E0=B8=96=E0=B8=B2?= =?UTF-8?q?=E0=B8=99=E0=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomerInfoComponent.vue | 27 +++++++++++++++---- src/pages/03_customer-management/MainPage.vue | 20 +++++++++++--- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/components/03_customer-management/CustomerInfoComponent.vue b/src/components/03_customer-management/CustomerInfoComponent.vue index f8adc363..286d56f7 100644 --- a/src/components/03_customer-management/CustomerInfoComponent.vue +++ b/src/components/03_customer-management/CustomerInfoComponent.vue @@ -6,6 +6,7 @@ import { onMounted } from 'vue'; import useCustomerStore from 'src/stores/customer'; import { CustomerBranch, CustomerType } from 'src/stores/customer/types'; import { watch } from 'vue'; +import { Status } from 'src/stores/types'; const userCustomer = useCustomerStore(); const { fetchListBranch } = userCustomer; @@ -19,6 +20,8 @@ const currentCustomerUrlImage = defineModel( 'currentCustomerUrlImage', ); +const currentStatus = ref('All'); + const currentPageBranch = ref(1); const maxPageBranch = ref(1); const pageSizeBranch = ref(30); @@ -52,18 +55,28 @@ async function searchBranch() { } onMounted(async () => { + await fetchList(); +}); + +async function fetchList() { const result = await fetchListBranch({ customerId: prop.customerId, page: 1, pageSize: pageSizeBranch.value, includeCustomer: true, + status: + currentStatus.value === 'All' + ? undefined + : currentStatus.value === 'ACTIVE' + ? 'ACTIVE' + : 'INACTIVE', }); if (result) { - currentCustomerName.value = result.result[0].customer?.customerName; + currentCustomerName.value = result.result[0].customer?.customerName ?? ''; maxPageBranch.value = Math.ceil(result.total / pageSizeBranch.value); branch.value = result.result; } -}); +} watch(currentPageBranch, async () => { const resultList = await fetchListBranch({ @@ -79,6 +92,10 @@ watch(currentPageBranch, async () => { branch.value = resultList.result; } }); + +watch(currentStatus, async () => { + await fetchList(); +});