diff --git a/src/components/03_customer-management/CustomerInfoComponent.vue b/src/components/03_customer-management/CustomerInfoComponent.vue index c8d5821e..ab4efa70 100644 --- a/src/components/03_customer-management/CustomerInfoComponent.vue +++ b/src/components/03_customer-management/CustomerInfoComponent.vue @@ -14,8 +14,8 @@ const branch = ref(); const prop = withDefaults( defineProps<{ - color: 'purple' | 'green'; - customerId: string; + color?: 'purple' | 'green'; + customerId?: string; }>(), { color: 'green', @@ -123,15 +123,8 @@ onMounted(async () => {
-<<<<<<< HEAD -
- -======= -
- ->>>>>>> 10383c3 (feat: fetchListById และ byค่า) +
+
diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index 0535bb40..f9d0b084 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -2,6 +2,9 @@ import { computed, ref } from 'vue'; import { storeToRefs } from 'pinia'; +import { Pagination } from 'src/stores/types'; +import useCustomerStore from 'src/stores/customer'; + import UsersDetailCardComponent from 'src/components/UsersDetailCardComponent.vue'; import SelectorList from 'components/SelectorList.vue'; import StatCardComponent from 'components/StatCardComponent.vue'; @@ -21,11 +24,11 @@ import FormBusiness from 'src/components/03_customer-management/FormBusiness.vue import DrawerInfo from 'src/components/DrawerInfo.vue'; import InfoForm from 'src/components/02_personnel-management/InfoForm.vue'; import CustomerInfoComponent from 'src/components/03_customer-management/CustomerInfoComponent.vue'; -import { CustomerCreate } from 'stores/customer/types'; -import useCustomerStore from 'src/stores/customer'; +import { CustomerCreate, CustomerStats, Customer } from 'stores/customer/types'; +import { onMounted } from 'vue'; const userCustomer = useCustomerStore(); -const { create } = userCustomer; +const { create, getStatsCustomer, fetchList } = userCustomer; const formData = ref({ status: 'CREATED', customerType: 'CORP', @@ -57,8 +60,8 @@ const formData = ref({ jobPositionEN: '', jobDescription: '', saleEmployee: '', - payDate: '', - wageDate: '', + payDate: new Date(), + wageRate: 0, }, ], image: new File([''], 'dummy.jpg'), @@ -72,6 +75,8 @@ const profileUrl = ref(''); const infoDrawer = ref(false); const infoDrawerEdit = ref(false); const isMainPage = ref(true); +const statsCustomerType = ref(); +const currentCustomerId = ref(''); const inputFile = (() => { const element = document.createElement('input'); @@ -93,6 +98,8 @@ const inputFile = (() => { return element; })(); +const listCustomer = ref>(); + const itemCard = [ { icon: 'mdi:office-building', @@ -125,7 +132,12 @@ const dialogInputForm = ref(false); const selectorLabel = ref(''); const selectorList = computed(() => [ - { label: 'EMPLOYER', count: 0 }, + { + label: 'EMPLOYER', + count: + (statsCustomerType.value?.CORP ?? 0) + + (statsCustomerType.value?.PERS ?? 0), + }, { label: 'WORKER', count: 0 }, ]); @@ -191,8 +203,8 @@ function clearForm() { jobPositionEN: '', jobDescription: '', saleEmployee: '', - payDate: '', - wageDate: '', + payDate: new Date(), + wageRate: 0, }, ], image: new File([''], 'dummy.jpg'), @@ -212,6 +224,18 @@ async function onSubmit() { function undo() { infoDrawerEdit.value = false; } + +onMounted(async () => { + const resultStats = await getStatsCustomer(); + + const resultList = await fetchList(); + + if (resultStats) statsCustomerType.value = resultStats; + + if (resultList) listCustomer.value = resultList; + + console.log(listCustomer.value); +});