sme-pos-package 1.0.7 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +37 -2
- package/dist/index.mjs +17 -104
- package/dist/index.mjs.map +1 -1
- package/dist/tailwind.preset.d.mts +27 -0
- package/dist/tailwind.preset.mjs +2 -0
- package/dist/tailwind.preset.mjs.map +1 -0
- package/package.json +18 -30
- package/public/assets/images/bank-logos.png +0 -0
- package/public/assets/images/banner1.png +0 -0
- package/public/assets/images/banner2.png +0 -0
- package/public/assets/images/banner3.png +0 -0
- package/public/assets/images/banner4.png +0 -0
- package/public/assets/images/cashier.svg +9 -0
- package/public/assets/images/empty-cart.png +0 -0
- package/public/assets/images/empty-table-state.png +0 -0
- package/public/assets/images/layout-display/left-layout.png +0 -0
- package/public/assets/images/layout-display/right-layout.png +0 -0
- package/public/assets/images/modal-illustration.png +0 -0
- package/public/assets/images/order-empty-state.png +0 -0
- package/public/assets/images/order.png +0 -0
- package/public/assets/images/payment-success-label.png +0 -0
- package/public/assets/images/table-empty.png +0 -0
- package/public/assets/images/take-away.png +0 -0
- package/public/assets/lottie/loading.json +1 -0
- package/public/assets/lottie/soft_pos.json +1 -0
- package/public/assets/lottie/success.json +1 -0
- package/public/config.json +27 -0
- package/public/env.json +17 -0
- package/src/animations/success.json +9730 -0
- package/src/assets/icons/breadcrumbs-icon.tsx +85 -0
- package/src/assets/icons/cart-icon.tsx +14 -0
- package/src/assets/icons/common.tsx +270 -0
- package/src/assets/icons/customer-view-icon.tsx +20 -0
- package/src/assets/icons/dining-table.tsx +34 -0
- package/src/assets/icons/edit-line-icon.tsx +18 -0
- package/src/assets/icons/emenu-icon.tsx +39 -0
- package/src/assets/icons/file-close-line-icon.tsx +18 -0
- package/src/assets/icons/helper-icon.tsx +84 -0
- package/src/assets/icons/home-gear-line-icon.tsx +18 -0
- package/src/assets/icons/kanban-icon.tsx +16 -0
- package/src/assets/icons/loading-icon.tsx +45 -0
- package/src/assets/icons/logout-box-line-icon.tsx +18 -0
- package/src/assets/icons/order-icon.tsx +92 -0
- package/src/assets/icons/payment-icon.tsx +429 -0
- package/src/assets/icons/pincode.tsx +196 -0
- package/src/assets/icons/pos-connect-icon.tsx +67 -0
- package/src/assets/icons/pos-device-icon.tsx +52 -0
- package/src/assets/icons/pos-icon.tsx +75 -0
- package/src/assets/icons/printer-line-icon.tsx +18 -0
- package/src/assets/icons/star-icon.tsx +174 -0
- package/src/assets/icons/table-icon.tsx +77 -0
- package/src/assets/icons/user-add-line-icon.tsx +33 -0
- package/src/assets/icons/user-icon.tsx +65 -0
- package/src/components/common/button-action.tsx +46 -0
- package/src/components/common/button-icon.tsx +23 -0
- package/src/components/common/dropdown/index.tsx +79 -0
- package/src/components/common/empty-state.tsx +60 -0
- package/src/components/common/header/index.tsx +89 -0
- package/src/components/common/header/tabs.tsx +119 -0
- package/src/components/common/image.tsx +20 -0
- package/src/components/common/input/index.tsx +55 -0
- package/src/components/common/input/radio-group.tsx +75 -0
- package/src/components/common/input/text-area.tsx +28 -0
- package/src/components/common/modal/delete-confirm-modal-container.tsx +65 -0
- package/src/components/common/modal/index.ts +2 -0
- package/src/components/common/modal/modal-direction.tsx +125 -0
- package/src/components/common/modal/modal-header.tsx +37 -0
- package/src/components/common/modal/modal-wrapper.tsx +56 -0
- package/src/components/common/modal/modal-zoom.tsx +61 -0
- package/src/components/common/pagination.tsx +95 -0
- package/src/components/common/refresh-button.tsx +28 -0
- package/src/components/common/search-bar.tsx +27 -0
- package/src/components/common/search.tsx +59 -0
- package/src/components/common/skeleton.tsx +7 -0
- package/src/components/common/tabs-layout.tsx +98 -0
- package/src/components/common/use-check-session.tsx +19 -0
- package/src/components/customer-management/add-customer/add-customer-drawer.tsx +286 -0
- package/src/components/customer-management/add-customer/address-select.tsx +51 -0
- package/src/components/customer-management/choose-customer-drawer.tsx +177 -0
- package/src/components/customer-management/customer-info-drawer.tsx +166 -0
- package/src/components/customer-management/customer-no-data.tsx +18 -0
- package/src/components/emenu/emenu-qr-code.tsx +59 -0
- package/src/components/emenu/menu-link.tsx +67 -0
- package/src/components/index.ts +8 -0
- package/src/components/kanban-template/kitchen-template.tsx +60 -0
- package/src/components/kanban-template/pos-order-template.tsx +77 -0
- package/src/components/kanban-template/pos-template.tsx +170 -0
- package/src/components/kitchen-management/change-status-confirm-modal.tsx +61 -0
- package/src/components/kitchen-management/index.ts +1 -0
- package/src/components/kitchen-management/kitchen-order/index.tsx +153 -0
- package/src/components/kitchen-management/kitchen-order/line.tsx +78 -0
- package/src/components/kitchen-management/kitchen-order/state.tsx +52 -0
- package/src/components/kitchen-management/kitchen-status.tsx +69 -0
- package/src/components/kitchen-management/orders-kitchen-management.tsx +113 -0
- package/src/components/order-management/index.tsx +128 -0
- package/src/components/order-management/order-actions.tsx +46 -0
- package/src/components/order-management/order-detail/header.tsx +37 -0
- package/src/components/order-management/order-detail/index.ts +3 -0
- package/src/components/order-management/order-detail/information.tsx +96 -0
- package/src/components/order-management/order-detail/order-detail.tsx +84 -0
- package/src/components/order-management/order-detail/order-line.tsx +56 -0
- package/src/components/order-management/order-detail/summary.tsx +221 -0
- package/src/components/order-management/order-header.tsx +113 -0
- package/src/components/order-management/order-pagination.tsx +49 -0
- package/src/components/order-management/order-status.tsx +58 -0
- package/src/components/order-management/order-table.tsx +179 -0
- package/src/components/order-management/order-tabs.tsx +48 -0
- package/src/components/pos-management/add-product-from-barcode/index.tsx +97 -0
- package/src/components/pos-management/cart-content/action-line.tsx +81 -0
- package/src/components/pos-management/cart-content/cancel-order-line-modal.tsx +41 -0
- package/src/components/pos-management/cart-content/cart-item.tsx +173 -0
- package/src/components/pos-management/cart-content/cart-items.tsx +130 -0
- package/src/components/pos-management/cart-content/draft-orders/draft-order-line.tsx +67 -0
- package/src/components/pos-management/cart-content/draft-orders/index.tsx +40 -0
- package/src/components/pos-management/cart-content/edit-cart-modal.tsx +11 -0
- package/src/components/pos-management/cart-content/index.tsx +260 -0
- package/src/components/pos-management/cart-content/no-select-order.tsx +26 -0
- package/src/components/pos-management/cart-content/order-info/customer-info.tsx +53 -0
- package/src/components/pos-management/cart-content/order-info/index.tsx +109 -0
- package/src/components/pos-management/cart-content/order-total.tsx +36 -0
- package/src/components/pos-management/cart-content/orders-line.tsx +72 -0
- package/src/components/pos-management/menu-content/category-tab.tsx +38 -0
- package/src/components/pos-management/menu-content/create-order-modal.tsx +65 -0
- package/src/components/pos-management/menu-content/product-content.tsx +93 -0
- package/src/components/pos-management/menu-content/product-detail/info.tsx +28 -0
- package/src/components/pos-management/menu-content/product-detail/modal.tsx +148 -0
- package/src/components/pos-management/menu-content/product-detail/option.tsx +87 -0
- package/src/components/pos-management/menu-content/product-detail/quantity-control.tsx +155 -0
- package/src/components/pos-management/menu-content/product-detail/sale-keypad.tsx +100 -0
- package/src/components/pos-management/menu-content/product-item.tsx +65 -0
- package/src/components/pos-management/order-helper/cancel-order-confirm.tsx +43 -0
- package/src/components/pos-management/order-helper/history-call.tsx +105 -0
- package/src/components/pos-management/order-helper/order-helper-modal.tsx +116 -0
- package/src/components/pos-management/payment-content/bill/actions.tsx +46 -0
- package/src/components/pos-management/payment-content/bill/content.tsx +207 -0
- package/src/components/pos-management/payment-content/bill/index.tsx +18 -0
- package/src/components/pos-management/payment-content/card-payment/index.tsx +124 -0
- package/src/components/pos-management/payment-content/card-payment/pos-payment/pos-connect.tsx +183 -0
- package/src/components/pos-management/payment-content/card-payment/pos-payment/qr-connect.tsx +185 -0
- package/src/components/pos-management/payment-content/card-payment/waiting-for-payment-pos-modal.tsx +37 -0
- package/src/components/pos-management/payment-content/cash-payment/index.tsx +216 -0
- package/src/components/pos-management/payment-content/index.tsx +70 -0
- package/src/components/pos-management/payment-content/payment-info.tsx +67 -0
- package/src/components/pos-management/payment-content/payment-layout.tsx +16 -0
- package/src/components/pos-management/payment-content/payment-method-cards.tsx +99 -0
- package/src/components/pos-management/payment-content/qr-payment/index.tsx +118 -0
- package/src/components/pos-management/payment-content/qr-payment/qr_code.js +29 -0
- package/src/components/pos-management/payment-content/qr-payment/vietqr.js +436 -0
- package/src/components/pos-management/payment-content/session-close-modal.tsx +35 -0
- package/src/components/pos-management/payment-content/soft-pos-payment/index.tsx +48 -0
- package/src/components/pos-management/pos-helpers/back-confirm.tsx +45 -0
- package/src/components/pos-management/pos-helpers/index.tsx +135 -0
- package/src/components/pos-management/pos-helpers/layout-display-modal.tsx +99 -0
- package/src/components/pos-management/search.tsx +48 -0
- package/src/components/pos-management/table-content/filtered-tables.tsx +59 -0
- package/src/components/pos-management/table-content/floor-tabs.tsx +65 -0
- package/src/components/pos-management/table-content/index.tsx +76 -0
- package/src/components/pos-management/table-content/table-item.tsx +127 -0
- package/src/components/pos-management/table-content/tables.tsx +96 -0
- package/src/components/restaurant-management/add-floor-modal.tsx +133 -0
- package/src/components/restaurant-management/add-table-modal.tsx +198 -0
- package/src/components/restaurant-management/delete-floor-confirm-modal.tsx +42 -0
- package/src/components/restaurant-management/delete-table-confirm-modal.tsx +51 -0
- package/src/components/restaurant-management/header.tsx +22 -0
- package/src/components/restaurant-management/index.tsx +54 -0
- package/src/components/restaurant-management/left-side.tsx +51 -0
- package/src/components/restaurant-management/right-side.tsx +179 -0
- package/src/components/restaurant-management/table-empty.tsx +43 -0
- package/src/components/session-management/close-session-modal/actions.tsx +45 -0
- package/src/components/session-management/close-session-modal/close-session-confirm.tsx +157 -0
- package/src/components/session-management/close-session-modal/close-session-ticket.tsx +218 -0
- package/src/components/session-management/close-session-modal/container.tsx +25 -0
- package/src/components/session-management/close-session-modal/draft-orders-confirm.tsx +53 -0
- package/src/components/session-management/close-session-modal/draft-orders-summary.tsx +82 -0
- package/src/components/session-management/close-session-modal/draft-orders.tsx +34 -0
- package/src/components/session-management/close-session-modal/index.tsx +35 -0
- package/src/components/session-management/close-session-modal/order/index.ts +1 -0
- package/src/components/session-management/close-session-modal/order/order-line.tsx +64 -0
- package/src/components/session-management/close-session-modal/order/orders-in-draft.tsx +31 -0
- package/src/components/session-management/close-session-modal/session-summary.tsx +165 -0
- package/src/components/session-management/index.ts +1 -0
- package/src/components/session-management/open-shift/index.tsx +172 -0
- package/src/components/table-management/index.tsx +0 -0
- package/src/constants/api/index.ts +1 -0
- package/src/constants/headers.constant.tsx +24 -0
- package/src/constants/index.ts +1 -0
- package/src/constants/language.store.ts +21 -0
- package/src/constants/methods.constant.ts +10 -0
- package/src/constants/order-state.ts +8 -0
- package/src/constants/payment-color.constant.ts +26 -0
- package/src/constants/query.constant.ts +14 -0
- package/src/constants/routes.constants.ts +23 -0
- package/src/constants/template-name.constant.ts +9 -0
- package/src/hooks/bill/use-get-bill-information.ts +49 -0
- package/src/hooks/bill/use-print-bill.tsx +0 -0
- package/src/hooks/common/load-env-config.ts +98 -0
- package/src/hooks/common/use-back.ts +13 -0
- package/src/hooks/common/use-broadcast.ts +22 -0
- package/src/hooks/common/use-click-outside.ts +58 -0
- package/src/hooks/common/use-get-base64-photo.ts +71 -0
- package/src/hooks/common/use-get-query.ts +25 -0
- package/src/hooks/common/use-pos.ts +21 -0
- package/src/hooks/common/use-query-params.ts +89 -0
- package/src/hooks/common/use-speech.ts +36 -0
- package/src/hooks/customer/use-customer-provider.ts +247 -0
- package/src/hooks/floor/use-floor-provider.ts +172 -0
- package/src/hooks/kitchen/use-kitchen-provider.ts +80 -0
- package/src/hooks/order/use-get-point-reward.ts +50 -0
- package/src/hooks/order/use-loop-fetch-order.ts +30 -0
- package/src/hooks/order/use-order-items.ts +61 -0
- package/src/hooks/order/use-orders.ts +76 -0
- package/src/hooks/payment/use-payment-provider.ts +221 -0
- package/src/hooks/product/use-product-provider.ts +87 -0
- package/src/hooks/session/use-check-session.tsx +19 -0
- package/src/hooks/session/use-session-provider.ts +79 -0
- package/src/hooks/table/use-pos-table-provider.ts +193 -0
- package/src/index.css +5 -0
- package/src/index.ts +10 -0
- package/src/layouts/common.tsx +15 -0
- package/src/layouts/index.ts +4 -0
- package/src/layouts/pos-layout.tsx +33 -0
- package/src/layouts/pos-order-layout.tsx +43 -0
- package/src/layouts/sale-layout.tsx +25 -0
- package/src/locales/en.json +394 -0
- package/src/locales/vi.json +400 -0
- package/src/pages/index.ts +4 -0
- package/src/pages/login/index.tsx +128 -0
- package/src/pages/pincode/index.tsx +198 -0
- package/src/pages/pos/kitchen-management/layout.tsx +18 -0
- package/src/pages/pos/management-floor/index.tsx +7 -0
- package/src/pages/pos/management-order/index.tsx +7 -0
- package/src/pages/pos/management-order/order-detail/index.tsx +7 -0
- package/src/pages/pos/management-table/index.tsx +0 -0
- package/src/pages/pos/payment-success/index.tsx +75 -0
- package/src/provider/app-provider.tsx +56 -0
- package/src/provider/fallback/custom-error.tsx +26 -0
- package/src/provider/main-provider.tsx +41 -0
- package/src/provider/meta-provider.tsx +72 -0
- package/src/provider/modal-provider.tsx +48 -0
- package/src/provider/notification-provider.tsx +64 -0
- package/src/provider/pos-provider/close-session-provider/index.tsx +207 -0
- package/src/provider/pos-provider/customer-provider/index.tsx +30 -0
- package/src/provider/pos-provider/floor-provider/index.tsx +39 -0
- package/src/provider/pos-provider/index.ts +6 -0
- package/src/provider/pos-provider/kitchen-provider/index.tsx +30 -0
- package/src/provider/pos-provider/order-detail-provider/index.tsx +233 -0
- package/src/provider/pos-provider/order-provider/index.tsx +803 -0
- package/src/provider/pos-provider/payment-provider/index.tsx +30 -0
- package/src/provider/pos-provider/product-provider/index.tsx +30 -0
- package/src/provider/pos-provider/sale-provider/index.tsx +168 -0
- package/src/provider/pos-provider/session-provider/index.tsx +30 -0
- package/src/provider/pos-provider/socket-provider/index.tsx +118 -0
- package/src/provider/pos-provider/table-provider/index.tsx +30 -0
- package/src/provider/public-provider.tsx +104 -0
- package/src/provider/use-session-provider.ts +79 -0
- package/src/router/app-router.tsx +38 -0
- package/src/router/index.tsx +26 -0
- package/src/router/pos-route.tsx +75 -0
- package/src/router/protected-route.tsx +16 -0
- package/src/router/public-route.tsx +11 -0
- package/src/store/header/index.ts +21 -0
- package/src/store/session/index.ts +25 -0
- package/src/store/states/cart.state.ts +135 -0
- package/src/store/states/close-session.state.ts +20 -0
- package/src/store/states/customer.state.ts +19 -0
- package/src/store/states/payment.state.ts +14 -0
- package/src/styles/base.css +212 -0
- package/src/styles/common.css +65 -0
- package/src/styles/lib/tailwind.css +0 -0
- package/src/styles/lib/tailwind.theme.css +34 -0
- package/src/styles/loading.css +72 -0
- package/src/styles/main.css +5 -0
- package/src/styles/refreshing-content.css +55 -0
- package/src/styles/text.css +44 -0
- package/src/types/account.ts +61 -0
- package/src/types/branch.ts +6 -0
- package/src/types/category.ts +13 -0
- package/src/types/common.ts +4 -0
- package/src/types/customer.ts +52 -0
- package/src/types/dashboard.ts +18 -0
- package/src/types/edc.ts +37 -0
- package/src/types/export-e-invoice.ts +17 -0
- package/src/types/filter.d.ts +12 -0
- package/src/types/floor/floor.ts +16 -0
- package/src/types/floor.d.ts +36 -0
- package/src/types/index.ts +127 -0
- package/src/types/invoice.ts +32 -0
- package/src/types/modal.ts +15 -0
- package/src/types/notification.ts +12 -0
- package/src/types/order.ts +182 -0
- package/src/types/payment.ts +44 -0
- package/src/types/product/product.ts +47 -0
- package/src/types/product.ts +137 -0
- package/src/types/provider-info.d.ts +14 -0
- package/src/types/qr.d.ts +25 -0
- package/src/types/report.d.ts +43 -0
- package/src/types/sale.d.ts +68 -0
- package/src/types/search.d.ts +7 -0
- package/src/types/session.d.ts +30 -0
- package/src/types/shop-qr.d.ts +89 -0
- package/src/types/staff.d.ts +35 -0
- package/src/types/store.d.ts +25 -0
- package/src/types/table.d.ts +57 -0
- package/src/utils/close-session-ticket.tsx +129 -0
- package/src/utils/functions.ts +299 -0
- package/src/utils/i18n.ts +25 -0
- package/src/utils/pos/bill.ts +156 -0
- package/src/utils/pos/convert-order.ts +58 -0
- package/src/utils/pos/helpers.ts +48 -0
- package/src/utils/pos/session.ts +44 -0
- package/src/utils/storages/index.ts +1 -0
- package/src/utils/storages/local-storage.ts +72 -0
- package/tailwind.preset.ts +25 -0
- package/tsconfig.json +30 -0
- package/tsup.config.ts +30 -0
- package/dist/index.d.ts +0 -58
- package/dist/index.js +0 -145
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export type TStaff = {
|
|
2
|
+
staff_id: string
|
|
3
|
+
email: string
|
|
4
|
+
phone: string
|
|
5
|
+
id: number
|
|
6
|
+
updated_at: string
|
|
7
|
+
store_id: number
|
|
8
|
+
password: string
|
|
9
|
+
merchant_id: number
|
|
10
|
+
created_at: string
|
|
11
|
+
is_deleted: boolean
|
|
12
|
+
store_name: string
|
|
13
|
+
full_name: string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type TCreateStaffPayload = {
|
|
17
|
+
staff_id: string
|
|
18
|
+
full_name: string
|
|
19
|
+
store_id: number
|
|
20
|
+
phone: string
|
|
21
|
+
email: string
|
|
22
|
+
password: string
|
|
23
|
+
old_password?: string
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type TUpdateStaffPayload = {
|
|
27
|
+
id: number
|
|
28
|
+
staff_id: string
|
|
29
|
+
full_name: string
|
|
30
|
+
store_id: number
|
|
31
|
+
phone: string
|
|
32
|
+
email: string
|
|
33
|
+
password?: string
|
|
34
|
+
old_password?: string
|
|
35
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type TStore = {
|
|
2
|
+
source_id: number
|
|
3
|
+
name: string
|
|
4
|
+
vat: string | null
|
|
5
|
+
email: string | null
|
|
6
|
+
parent_id: number | null
|
|
7
|
+
create_date: number
|
|
8
|
+
id: number
|
|
9
|
+
address: string
|
|
10
|
+
phone: string | null
|
|
11
|
+
va_account_no: string | null
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type TCreateStorePayload = {
|
|
15
|
+
store_name: string
|
|
16
|
+
tax_no: string
|
|
17
|
+
address_line_1: string
|
|
18
|
+
country_id: number
|
|
19
|
+
city_id: string
|
|
20
|
+
district_id: string
|
|
21
|
+
ward_id: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type TAreaItem = { id: string; name: string }
|
|
25
|
+
export type TAreaItemBE1 = { code: string; full_name: string }
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { TBasicOrder } from "./order";
|
|
2
|
+
import { TProductInBill } from "./product";
|
|
3
|
+
|
|
4
|
+
export type TOrderInfor = {
|
|
5
|
+
order_id: number;
|
|
6
|
+
table_name: string;
|
|
7
|
+
name: string;
|
|
8
|
+
point: number;
|
|
9
|
+
updated_at: number;
|
|
10
|
+
status: 0 | 1 | 2; // 0: thanh toán, 1: Có món, 2: Chưa có món
|
|
11
|
+
product_amount: number;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export type TOrderDetail = {
|
|
15
|
+
order_info: TOrderInfor;
|
|
16
|
+
products: TProductInBill[];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type TTable = {
|
|
20
|
+
id: number;
|
|
21
|
+
table_id: number;
|
|
22
|
+
table_number: number;
|
|
23
|
+
max_slot: number;
|
|
24
|
+
available_slot: number;
|
|
25
|
+
customer_id: number | null;
|
|
26
|
+
is_available: boolean;
|
|
27
|
+
order_id: number | null;
|
|
28
|
+
order_code: string | null;
|
|
29
|
+
total_price: number | null;
|
|
30
|
+
product_amount: number | null;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export type TBasicTable = {
|
|
35
|
+
id: number;
|
|
36
|
+
table_number: number;
|
|
37
|
+
floor_id: number;
|
|
38
|
+
seats: number;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type TMapedTable = {
|
|
42
|
+
table: TBasicTable;
|
|
43
|
+
isTakeAway: boolean;
|
|
44
|
+
currentOrder?: TBasicOrder;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type TQRTable = {
|
|
48
|
+
tableName: string;
|
|
49
|
+
qrString: string;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export type TCreateTablePayload = {
|
|
53
|
+
tableNumber: number;
|
|
54
|
+
floorId: number;
|
|
55
|
+
seats: number;
|
|
56
|
+
onSuccess?: () => void;
|
|
57
|
+
};
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { formatCurrency, getDate, hh_mm_dd_mm_yyyy } from "@utils/functions";
|
|
2
|
+
|
|
3
|
+
type TProps = {
|
|
4
|
+
sessionConfirmParams: {
|
|
5
|
+
cashCount: number;
|
|
6
|
+
note: string;
|
|
7
|
+
};
|
|
8
|
+
userData: any;
|
|
9
|
+
posId: number;
|
|
10
|
+
dataCloseSession: any;
|
|
11
|
+
posDetailInfo: any;
|
|
12
|
+
cashDifference: number;
|
|
13
|
+
company: any;
|
|
14
|
+
openAt: any;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export const generateTextShift = async (props: TProps) => {
|
|
18
|
+
const {
|
|
19
|
+
sessionConfirmParams,
|
|
20
|
+
userData,
|
|
21
|
+
posId,
|
|
22
|
+
dataCloseSession,
|
|
23
|
+
posDetailInfo,
|
|
24
|
+
cashDifference,
|
|
25
|
+
company,
|
|
26
|
+
openAt,
|
|
27
|
+
} = props;
|
|
28
|
+
|
|
29
|
+
const user = userData?.userProfile?.data;
|
|
30
|
+
const companyName = userData?.userProfile?.data?.company?.invoice_name;
|
|
31
|
+
const address = user?.company?.address;
|
|
32
|
+
const addressFormat = `${address?.street ?? ""} ${address?.street2 ?? ""}, ${
|
|
33
|
+
address?.ward ?? ""
|
|
34
|
+
}, ${address?.state ?? ""}`;
|
|
35
|
+
|
|
36
|
+
const currentPos = posDetailInfo?.records?.find(
|
|
37
|
+
(item: any) => item.id === Number(posId)
|
|
38
|
+
);
|
|
39
|
+
const closeSessionDate = getDate(new Date());
|
|
40
|
+
|
|
41
|
+
const line = "----------------------------------------";
|
|
42
|
+
|
|
43
|
+
const header = `
|
|
44
|
+
[C]{LOGO}
|
|
45
|
+
[C]
|
|
46
|
+
[C]${addressFormat}
|
|
47
|
+
|
|
48
|
+
[C]<font size='big'><b>PHIẾU GIAO CA</b></font>
|
|
49
|
+
`;
|
|
50
|
+
|
|
51
|
+
const infoRows = `
|
|
52
|
+
[L]Mã ca / Quầy:[R]<b>${[
|
|
53
|
+
currentPos?.current_session_id?.display_name,
|
|
54
|
+
currentPos?.name,
|
|
55
|
+
].join("/")}</b>
|
|
56
|
+
|
|
57
|
+
[L]Nhân viên:[R]<b>${currentPos?.current_user_id?.display_name}</b>
|
|
58
|
+
|
|
59
|
+
[L]Giờ mở ca:[R]${hh_mm_dd_mm_yyyy(openAt)}
|
|
60
|
+
[L]Giờ đóng ca:[R]${hh_mm_dd_mm_yyyy(new Date())}
|
|
61
|
+
`;
|
|
62
|
+
|
|
63
|
+
const openingCash = `
|
|
64
|
+
${line}
|
|
65
|
+
[L]<b>Tiền mặt đầu ca (1)</b>[R]<b>${
|
|
66
|
+
formatCurrency(dataCloseSession?.default_cash_details?.opening) || 0
|
|
67
|
+
} đ</b>
|
|
68
|
+
`;
|
|
69
|
+
|
|
70
|
+
const middleSections = `
|
|
71
|
+
${line}
|
|
72
|
+
[L]<b>Tiền mặt trong ca (2)</b>[R]<b>${
|
|
73
|
+
formatCurrency(dataCloseSession?.default_cash_details?.payment_amount) || 0
|
|
74
|
+
} đ</b>
|
|
75
|
+
[L]Bán hàng[R]${
|
|
76
|
+
formatCurrency(dataCloseSession?.default_cash_details?.payment_amount) || 0
|
|
77
|
+
} đ
|
|
78
|
+
|
|
79
|
+
${line}
|
|
80
|
+
[L]<b>Tiền mặt cuối ca (3)=(1)+(2)</b>[R]<b>${
|
|
81
|
+
formatCurrency(dataCloseSession?.default_cash_details?.amount) || 0
|
|
82
|
+
} đ</b>
|
|
83
|
+
[L]Tiền mặt bàn giao thực tế[R]${
|
|
84
|
+
formatCurrency(sessionConfirmParams.cashCount) || 0
|
|
85
|
+
} đ
|
|
86
|
+
[L]Số tiền chênh lệch[R]${formatCurrency(cashDifference) || 0} đ
|
|
87
|
+
|
|
88
|
+
${line}
|
|
89
|
+
[L]<b>Phương thức thanh toán khác</b>[R]<b>${
|
|
90
|
+
formatCurrency(
|
|
91
|
+
dataCloseSession?.non_cash_payment_methods?.reduce(
|
|
92
|
+
(a: number, b: any) => a + (b?.amount || 0),
|
|
93
|
+
0
|
|
94
|
+
)
|
|
95
|
+
) || 0
|
|
96
|
+
} đ</b>
|
|
97
|
+
${
|
|
98
|
+
dataCloseSession?.non_cash_payment_methods
|
|
99
|
+
?.map(
|
|
100
|
+
(i: any) => `[L]${i?.name}[R]${formatCurrency(i?.amount || 0) || 0} đ`
|
|
101
|
+
)
|
|
102
|
+
?.join("\n") || ""
|
|
103
|
+
}
|
|
104
|
+
`;
|
|
105
|
+
const footer = `
|
|
106
|
+
${line}
|
|
107
|
+
|
|
108
|
+
[C]Ngày ${closeSessionDate.day} tháng ${closeSessionDate.month} năm ${closeSessionDate.year}
|
|
109
|
+
|
|
110
|
+
[C]<b>Người bàn giao Người nhận bàn giao</b>
|
|
111
|
+
|
|
112
|
+
[C]
|
|
113
|
+
[C]
|
|
114
|
+
|
|
115
|
+
[C]<font size='small'>Powered by ${company?.companyInfo?.data?.[0]?.display_name}</font>
|
|
116
|
+
|
|
117
|
+
[C]
|
|
118
|
+
[C]
|
|
119
|
+
[C]
|
|
120
|
+
`;
|
|
121
|
+
|
|
122
|
+
return `
|
|
123
|
+
${header}
|
|
124
|
+
${infoRows}
|
|
125
|
+
${openingCash}
|
|
126
|
+
${middleSections}
|
|
127
|
+
${footer}
|
|
128
|
+
`.trim();
|
|
129
|
+
};
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import { TProduct } from "@type/product/product";
|
|
2
|
+
import { clsx } from "clsx";
|
|
3
|
+
import { twMerge } from "tailwind-merge";
|
|
4
|
+
|
|
5
|
+
export function cn(...inputs: any[]) {
|
|
6
|
+
return twMerge(clsx(inputs));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const generateRandomText = (length: number) => {
|
|
10
|
+
const chars =
|
|
11
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
12
|
+
let result = "";
|
|
13
|
+
for (let i = 0; i < length; i++) {
|
|
14
|
+
result += chars.charAt(Math.floor(Math.random() * chars.length));
|
|
15
|
+
}
|
|
16
|
+
return result;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const isObjectEmpty = (obj: object): boolean => {
|
|
20
|
+
return Object.keys(obj).length === 0;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function arraysEqual(a: any[], b: any[]): boolean {
|
|
24
|
+
if (a.length !== b.length) return false;
|
|
25
|
+
return a.every((val, i) => val === b[i]);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export const formatCurrency = (value: string | number) => {
|
|
29
|
+
if (!value) return "";
|
|
30
|
+
return new Intl.NumberFormat("en-US").format(Number(value));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const getTimeNow = () => {
|
|
34
|
+
const now = new Date();
|
|
35
|
+
const formatted = `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(
|
|
36
|
+
2,
|
|
37
|
+
"0"
|
|
38
|
+
)}-${String(now.getDate()).padStart(2, "0")} ${String(
|
|
39
|
+
now.getHours()
|
|
40
|
+
).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}:${String(
|
|
41
|
+
now.getSeconds()
|
|
42
|
+
).padStart(2, "0")}`;
|
|
43
|
+
|
|
44
|
+
return formatted;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const parseStringToObject = (str: string) => {
|
|
48
|
+
try {
|
|
49
|
+
// First parse once — this removes outer quotes if needed
|
|
50
|
+
const firstParse = JSON.parse(str);
|
|
51
|
+
|
|
52
|
+
// If the result is still a string (double-encoded), parse again
|
|
53
|
+
if (typeof firstParse === "string") {
|
|
54
|
+
return JSON.parse(firstParse);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Otherwise, it's already an object
|
|
58
|
+
return firstParse;
|
|
59
|
+
} catch (error) {
|
|
60
|
+
console.error("❌ Failed to parse JSON:", error);
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export function cleanObject<T extends Record<string, any>>(obj: T): Partial<T> {
|
|
66
|
+
const result: Partial<T> = {};
|
|
67
|
+
for (const [k, v] of Object.entries(obj)) {
|
|
68
|
+
if (v != null) {
|
|
69
|
+
result[k as keyof T] = v;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return result;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function filterObject(obj: Record<string, any>) {
|
|
76
|
+
return Object.fromEntries(
|
|
77
|
+
Object.entries(obj).filter(([_, value]) => {
|
|
78
|
+
if (value === "" || value === null || value === undefined) return false;
|
|
79
|
+
if (value === 0 || value === false) return false;
|
|
80
|
+
if (typeof value === "number" && Number.isNaN(value)) return false;
|
|
81
|
+
return true;
|
|
82
|
+
})
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function normalizeObject(obj: Record<string, any> | null) {
|
|
87
|
+
if (!obj) return null;
|
|
88
|
+
return Object.fromEntries(
|
|
89
|
+
Object.entries(obj).map(([key, value]) => {
|
|
90
|
+
if (value === false) return [key, ""];
|
|
91
|
+
if (typeof value === "string") return [key, value.trim()];
|
|
92
|
+
return [key, value];
|
|
93
|
+
})
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const makeTaxIds = (taxIds: number[]) => {
|
|
98
|
+
if (!taxIds || taxIds.length === 0) return [];
|
|
99
|
+
|
|
100
|
+
if (taxIds.length === 1) {
|
|
101
|
+
const id = taxIds[0];
|
|
102
|
+
return [4, id, { id }];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return taxIds.map((id) => [4, id, { id }]);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export function generatePosReference({
|
|
109
|
+
posId,
|
|
110
|
+
loginNum,
|
|
111
|
+
orderLength,
|
|
112
|
+
}: {
|
|
113
|
+
posId: number | string;
|
|
114
|
+
loginNum: number | string;
|
|
115
|
+
orderLength: number | string;
|
|
116
|
+
}) {
|
|
117
|
+
return (
|
|
118
|
+
"Order " +
|
|
119
|
+
posId.toString().padStart(5, "0") +
|
|
120
|
+
"-" +
|
|
121
|
+
loginNum.toString().padStart(3, "0") +
|
|
122
|
+
"-" +
|
|
123
|
+
orderLength.toString().padStart(4, "0")
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export const getKey = (prodct: TProduct) => {
|
|
128
|
+
const attributeIds = prodct?.attributeValueIds?.join(".") ?? [];
|
|
129
|
+
return `${prodct?.id}${attributeIds.length > 0 ? "-" : ""}${attributeIds}`;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export const getProductIdFromKey = (key?: string) => {
|
|
133
|
+
return key?.includes("-") ? key?.split?.("-")?.[0] : key;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
//format date
|
|
137
|
+
|
|
138
|
+
export const getDate = (date: Date | string) => {
|
|
139
|
+
const value = new Date(date);
|
|
140
|
+
const day = value?.getDate().toString().padStart(2, "0");
|
|
141
|
+
const month = (value?.getMonth() + 1).toString().padStart(2, "0");
|
|
142
|
+
const year = value?.getFullYear();
|
|
143
|
+
|
|
144
|
+
return {
|
|
145
|
+
day,
|
|
146
|
+
month,
|
|
147
|
+
year,
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
export const hh_mm = (date: Date | string) => {
|
|
152
|
+
const value = new Date(date);
|
|
153
|
+
const hours = value?.getHours().toString().padStart(2, "0");
|
|
154
|
+
const minutes = value?.getMinutes().toString().padStart(2, "0");
|
|
155
|
+
|
|
156
|
+
return `${hours}:${minutes}`;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
export const dd_mm_yyyy = (date: Date | string) => {
|
|
160
|
+
const value = new Date(date);
|
|
161
|
+
const day = value?.getDate().toString().padStart(2, "0");
|
|
162
|
+
const month = (value?.getMonth() + 1).toString().padStart(2, "0");
|
|
163
|
+
const year = value?.getFullYear();
|
|
164
|
+
|
|
165
|
+
return `${day}/${month}/${year}`;
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
export const hh_mm_dd_mm_yyyy = (date: Date | string) => {
|
|
169
|
+
return `${hh_mm(date)} ${dd_mm_yyyy(date)}`;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export function add7Hours(str: string | Date) {
|
|
173
|
+
const d = new Date(str);
|
|
174
|
+
return new Date(d.getTime() + 7 * 3600 * 1000);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
// format currency
|
|
178
|
+
export const unFormatCurrency = (value: string) => {
|
|
179
|
+
return value.replace(/\,/g, "");
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
export function ceilDecimal(value: number, decimals: number = 0): number {
|
|
183
|
+
const factor = Math.pow(10, decimals);
|
|
184
|
+
return Math.ceil(value * factor) / factor;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
export function ceilToThousands(value: number): number {
|
|
188
|
+
return Math.ceil(value / 1000) * 1000;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export const formatVND = (amount: number) => {
|
|
192
|
+
return Math.ceil(amount).toLocaleString("en-US");
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const formatOrderPrice = (price: number) =>
|
|
196
|
+
price.toLocaleString("vi-VN", { maximumFractionDigits: 0 });
|
|
197
|
+
|
|
198
|
+
export const randomNumber = () => {
|
|
199
|
+
return (Date.now() + Math.floor(Math.random() * 1000)).toString();
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export const onFindTable = ({
|
|
203
|
+
order,
|
|
204
|
+
tables,
|
|
205
|
+
floors,
|
|
206
|
+
}: {
|
|
207
|
+
order: any;
|
|
208
|
+
tables: any;
|
|
209
|
+
floors: any;
|
|
210
|
+
}) => {
|
|
211
|
+
if (!tables || !floors || !tables.length || !floors.length)
|
|
212
|
+
return "Chưa xác định";
|
|
213
|
+
|
|
214
|
+
const tableMatched = tables?.find(
|
|
215
|
+
(table: any) => table.id === order?.table_id
|
|
216
|
+
);
|
|
217
|
+
const floorMatched = floors?.find(
|
|
218
|
+
(floor: any) => floor.id === tableMatched?.floor_id
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
const floor = floorMatched?.name;
|
|
222
|
+
const table = tableMatched?.table_number;
|
|
223
|
+
|
|
224
|
+
if ((order?.table_id && !tableMatched) || (!order?.table_id && floorMatched))
|
|
225
|
+
return "Chưa xác định";
|
|
226
|
+
|
|
227
|
+
const label = floor || table ? `${floor} - Bàn ${table}` : "Mang đi";
|
|
228
|
+
|
|
229
|
+
return label;
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
type ApiOrder = {
|
|
233
|
+
id: number;
|
|
234
|
+
pos_reference: string;
|
|
235
|
+
amount_total: number;
|
|
236
|
+
date_order: string | Date;
|
|
237
|
+
state: string;
|
|
238
|
+
table_id: string | number | boolean;
|
|
239
|
+
lines: number[];
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
export const imageToHex = (
|
|
243
|
+
imageUrl: string
|
|
244
|
+
): Promise<{ width: number; height: number; hexString: string }> => {
|
|
245
|
+
return new Promise((resolve, reject) => {
|
|
246
|
+
const img = new Image();
|
|
247
|
+
img.crossOrigin = "anonymous";
|
|
248
|
+
img.src = imageUrl;
|
|
249
|
+
|
|
250
|
+
img.onload = () => {
|
|
251
|
+
const width = img.width;
|
|
252
|
+
const height = img.height;
|
|
253
|
+
const canvas = document.createElement("canvas");
|
|
254
|
+
canvas.width = width;
|
|
255
|
+
canvas.height = height;
|
|
256
|
+
const ctx = canvas.getContext("2d");
|
|
257
|
+
if (!ctx) return reject("Cannot get canvas context");
|
|
258
|
+
|
|
259
|
+
ctx.drawImage(img, 0, 0, width, height);
|
|
260
|
+
const imageData = ctx.getImageData(0, 0, width, height);
|
|
261
|
+
const pixels = imageData.data;
|
|
262
|
+
|
|
263
|
+
let hexString = "";
|
|
264
|
+
|
|
265
|
+
for (let y = 0; y < height; y++) {
|
|
266
|
+
let byte = 0;
|
|
267
|
+
let bitCount = 0;
|
|
268
|
+
|
|
269
|
+
for (let x = 0; x < width; x++) {
|
|
270
|
+
const idx = (y * width + x) * 4;
|
|
271
|
+
const r = pixels[idx];
|
|
272
|
+
const g = pixels[idx + 1];
|
|
273
|
+
const b = pixels[idx + 2];
|
|
274
|
+
|
|
275
|
+
const gray = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
276
|
+
const bw = gray < 128 ? 1 : 0;
|
|
277
|
+
|
|
278
|
+
byte = (byte << 1) | bw;
|
|
279
|
+
bitCount++;
|
|
280
|
+
|
|
281
|
+
if (bitCount === 8) {
|
|
282
|
+
hexString += byte.toString(16).padStart(2, "0");
|
|
283
|
+
byte = 0;
|
|
284
|
+
bitCount = 0;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (bitCount > 0) {
|
|
289
|
+
byte = byte << (8 - bitCount);
|
|
290
|
+
hexString += byte.toString(16).padStart(2, "0");
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
resolve({ width, height, hexString });
|
|
295
|
+
};
|
|
296
|
+
|
|
297
|
+
img.onerror = reject;
|
|
298
|
+
});
|
|
299
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import i18n from "i18next";
|
|
2
|
+
import LanguageDetector from "i18next-browser-languagedetector";
|
|
3
|
+
import { initReactI18next } from "react-i18next";
|
|
4
|
+
import vi from "../locales/vi.json";
|
|
5
|
+
import en from "../locales/en.json";
|
|
6
|
+
i18n
|
|
7
|
+
.use(LanguageDetector)
|
|
8
|
+
.use(initReactI18next)
|
|
9
|
+
.init({
|
|
10
|
+
resources: {
|
|
11
|
+
vi: { translation: vi },
|
|
12
|
+
en: { translation: en },
|
|
13
|
+
},
|
|
14
|
+
fallbackLng: "vi",
|
|
15
|
+
debug: false,
|
|
16
|
+
nonExplicitSupportedLngs: true,
|
|
17
|
+
interpolation: {
|
|
18
|
+
escapeValue: false,
|
|
19
|
+
},
|
|
20
|
+
detection: {
|
|
21
|
+
caches: ["cookie"],
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export default i18n;
|