diff --git a/package-lock.json b/package-lock.json index 91e7caa..24a3be2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,14 +19,12 @@ "dayjs": "^1.11.13", "html-to-image": "^1.11.11", "html2canvas": "^1.4.1", - "moment": "^2.30.1", "pinia": "^2.3.1", "v-pagination-3": "^0.1.7", "vue": "^3.3.11", "vue-debounce": "^5.0.0", "vue-router": "^4.2.5", - "vue3-pdfmake": "^2.2.0", - "vuelidate": "^0.7.7" + "vue3-pdfmake": "^2.2.0" }, "devDependencies": { "@types/leaflet": "^1.9.12", @@ -4482,14 +4480,6 @@ "node": ">=16 || 14 >=14.17" } }, - "node_modules/moment": { - "version": "2.30.1", - "resolved": "https://registry.npmjs.org/moment/-/moment-2.30.1.tgz", - "integrity": "sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==", - "engines": { - "node": "*" - } - }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -9129,15 +9119,6 @@ } } }, - "node_modules/vuelidate": { - "version": "0.7.7", - "resolved": "https://registry.npmjs.org/vuelidate/-/vuelidate-0.7.7.tgz", - "integrity": "sha512-pT/U2lDI67wkIqI4tum7cMSIfGcAMfB+Phtqh2ttdXURwvHRBJEAQ0tVbUsW9Upg83Q5QH59bnCoXI7A9JDGnA==", - "engines": { - "node": ">= 4.0.0", - "npm": ">= 3.0.0" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", diff --git a/package.json b/package.json index 1759452..e87f64b 100755 --- a/package.json +++ b/package.json @@ -20,14 +20,12 @@ "dayjs": "^1.11.13", "html-to-image": "^1.11.11", "html2canvas": "^1.4.1", - "moment": "^2.30.1", "pinia": "^2.3.1", "v-pagination-3": "^0.1.7", "vue": "^3.3.11", "vue-debounce": "^5.0.0", "vue-router": "^4.2.5", - "vue3-pdfmake": "^2.2.0", - "vuelidate": "^0.7.7" + "vue3-pdfmake": "^2.2.0" }, "devDependencies": { "@types/leaflet": "^1.9.12", diff --git a/src/components/PaymentAuthorizePopup.vue b/src/components/PaymentAuthorizePopup.vue index 32456b5..a0a57d5 100644 --- a/src/components/PaymentAuthorizePopup.vue +++ b/src/components/PaymentAuthorizePopup.vue @@ -116,9 +116,17 @@ \ No newline at end of file +const handleClickOutside = (event: MouseEvent) => { + const container = searchContainer.value; + const searchInput = document.getElementById('customer-search-input'); + + if (container && !container.contains(event.target as Node) && searchInput && !searchInput.contains(event.target as Node)) { + searchStore.clearSearch(); + } +} + +// Lifecycle +onMounted(() => { + document.addEventListener('mousedown', handleClickOutside); +}) + +onBeforeUnmount(() => { + document.removeEventListener('mousedown', handleClickOutside); +}) + diff --git a/src/constants/status.ts b/src/constants/status.ts new file mode 100644 index 0000000..ddbd5e7 --- /dev/null +++ b/src/constants/status.ts @@ -0,0 +1,95 @@ +/** + * EAMCO Office Frontend Status Constants + * + * This file contains all status code constants used throughout the frontend + * to eliminate magic numbers and improve code maintainability. + */ + +export const DELIVERY_STATUS = { + WAITING: 0, + CANCELLED: 1, + OUT_FOR_DELIVERY: 2, + TOMORROW: 3, + PARTIAL_DELIVERY: 4, + ISSUE: 5, + UNKNOWN: 6, + PENDING_PAYMENT: 9, + FINALIZED: 10, + DELIVERED: 11, // New: Replaces previous use of 1 for delivered +} as const; + +export const PAYMENT_STATUS = { + UNPAID: 0, + PRE_AUTHORIZED: 1, + PROCESSING: 2, + PAID: 3, + FAILED: 4, +} as const; + +export const AUTO_STATUS = { + DEFAULT: 0, + WILL_CALL: 1, + READY_FOR_FINALIZATION: 3, +} as const; + +export const TRANSACTION_STATUS = { + APPROVED: 0, + DECLINED: 1, +} as const; + +export const CUSTOMER_AUTOMATIC_STATUS = { + WILL_CALL: 0, + AUTOMATIC: 1, +} as const; + +// Helper functions for type-safe status access +export type DeliveryStatusType = typeof DELIVERY_STATUS[keyof typeof DELIVERY_STATUS]; +export type PaymentStatusType = typeof PAYMENT_STATUS[keyof typeof PAYMENT_STATUS]; +export type AutoStatusType = typeof AUTO_STATUS[keyof typeof AUTO_STATUS]; +export type TransactionStatusType = typeof TRANSACTION_STATUS[keyof typeof TRANSACTION_STATUS]; +export type CustomerAutomaticStatus = typeof CUSTOMER_AUTOMATIC_STATUS[keyof typeof CUSTOMER_AUTOMATIC_STATUS]; + +// Utility functions for status display +export function getDeliveryStatusLabel(status: DeliveryStatusType): string { + switch (status) { + case DELIVERY_STATUS.WAITING: return 'Waiting'; + case DELIVERY_STATUS.CANCELLED: return 'Cancelled'; + case DELIVERY_STATUS.OUT_FOR_DELIVERY: return 'Out for Delivery'; + case DELIVERY_STATUS.TOMORROW: return 'Tomorrow'; + case DELIVERY_STATUS.PARTIAL_DELIVERY: return 'Partial Delivery'; + case DELIVERY_STATUS.ISSUE: return 'Issue'; + case DELIVERY_STATUS.UNKNOWN: return 'Unknown'; + case DELIVERY_STATUS.PENDING_PAYMENT: return 'Pending Payment'; + case DELIVERY_STATUS.FINALIZED: return 'Finalized'; + case DELIVERY_STATUS.DELIVERED: return 'Delivered'; + default: return 'N/A'; + } +} + +export function getPaymentStatusLabel(status: PaymentStatusType): string { + switch (status) { + case PAYMENT_STATUS.UNPAID: return 'Unpaid'; + case PAYMENT_STATUS.PRE_AUTHORIZED: return 'Pre-authorized'; + case PAYMENT_STATUS.PROCESSING: return 'Processing'; + case PAYMENT_STATUS.PAID: return 'Paid'; + case PAYMENT_STATUS.FAILED: return 'Failed'; + default: return 'Unknown'; + } +} + +export function getAutoStatusLabel(status: AutoStatusType): string { + switch (status) { + case AUTO_STATUS.DEFAULT: return 'Default'; + case AUTO_STATUS.WILL_CALL: return 'Will Call'; + case AUTO_STATUS.READY_FOR_FINALIZATION: return 'Ready for Finalization'; + default: return 'Unknown'; + } +} + +export function getTransactionStatusLabel(status: TransactionStatusType): string { + switch (status) { + case TRANSACTION_STATUS.APPROVED: return 'Approved'; + case TRANSACTION_STATUS.DECLINED: return 'Declined'; + default: return 'Unknown'; + } +} \ No newline at end of file diff --git a/src/layouts/headers/headerauth.vue b/src/layouts/headers/headerauth.vue index c6dfbc1..d441baa 100755 --- a/src/layouts/headers/headerauth.vue +++ b/src/layouts/headers/headerauth.vue @@ -212,9 +212,9 @@ - diff --git a/src/layouts/headers/headernoauth.vue b/src/layouts/headers/headernoauth.vue index a6a26ee..787857e 100755 --- a/src/layouts/headers/headernoauth.vue +++ b/src/layouts/headers/headernoauth.vue @@ -15,31 +15,19 @@ - \ No newline at end of file diff --git a/src/pages/Index.vue b/src/pages/Index.vue index f1e22a4..72ed099 100755 --- a/src/pages/Index.vue +++ b/src/pages/Index.vue @@ -110,200 +110,185 @@