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(); +});