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,21 @@
|
|
|
1
|
+
export interface ILanguage {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
subLabel: string;
|
|
5
|
+
id: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export const languages: ILanguage[] = [
|
|
9
|
+
{
|
|
10
|
+
id: "vi_VN",
|
|
11
|
+
value: "vi",
|
|
12
|
+
label: "Tiếng Việt",
|
|
13
|
+
subLabel: "Tiếng Việt",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
id: "en_US",
|
|
17
|
+
value: "en",
|
|
18
|
+
label: "English",
|
|
19
|
+
subLabel: "United Kingdom",
|
|
20
|
+
},
|
|
21
|
+
];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const METHOD = {
|
|
2
|
+
ACTION_POS_ORDER_CANCEL: "action_pos_order_cancel",
|
|
3
|
+
UNLINK: "unlink",
|
|
4
|
+
GET_CLOSING_CONTROL_DATA: "get_closing_control_data",
|
|
5
|
+
POST_CLOSING_CASH_DETAILS: "post_closing_cash_details",
|
|
6
|
+
UPDATE_CLOSING_CONTROL_STATE_SESSION: "update_closing_control_state_session",
|
|
7
|
+
ACTION_POS_SESSION_CLOSING_CONTROL: "action_pos_session_closing_control",
|
|
8
|
+
ACTION_POS_SESSION_CLOSE: "action_pos_session_close",
|
|
9
|
+
NAME_SEARCH: "name_search",
|
|
10
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const PAYMENT_COLORS = [
|
|
2
|
+
{
|
|
3
|
+
type: "card",
|
|
4
|
+
activeBorder: "border-[#6BCE00]",
|
|
5
|
+
background: "bg-[#F1FFE2]",
|
|
6
|
+
iconBackground: "bg-[#6BCE00]",
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
type: "qr",
|
|
10
|
+
activeBorder: "border-[#FFD207]",
|
|
11
|
+
background: "bg-[#FFF5C7]",
|
|
12
|
+
iconBackground: "bg-[#FFD207]",
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: "cash",
|
|
16
|
+
activeBorder: "border-[#004FD3]",
|
|
17
|
+
background: "bg-[#CEE1FF]",
|
|
18
|
+
iconBackground: "bg-[#004FD3]",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
type: "soft_pos",
|
|
22
|
+
activeBorder: "border-[#1FC163]",
|
|
23
|
+
background: "bg-[#E0FAEB]",
|
|
24
|
+
iconBackground: "bg-[#1FC163]",
|
|
25
|
+
},
|
|
26
|
+
];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const QUERY_KEYS = {
|
|
2
|
+
POS_ID: "pos_id",
|
|
3
|
+
FLOOR: "floor",
|
|
4
|
+
SESSION_ID: "session-id",
|
|
5
|
+
ORDER_ID: "order-id",
|
|
6
|
+
CATEGORY_ID: "category-id",
|
|
7
|
+
OPEN: "open",
|
|
8
|
+
CUSTOMER_INFO: "customer-info",
|
|
9
|
+
CUSTOMER_ID: "customer-id",
|
|
10
|
+
TABLE_ID: "table-id",
|
|
11
|
+
KITCHEN_ORDER_STATUS: "kitchen-order-status",
|
|
12
|
+
CLOSE_SESSION: "close-session",
|
|
13
|
+
SHOW_SCREEN: "show-screen",
|
|
14
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const ROUTES = {
|
|
2
|
+
home: "/",
|
|
3
|
+
login: "/login",
|
|
4
|
+
pinCode: "/pin-code",
|
|
5
|
+
independentForm: "/independent-form",
|
|
6
|
+
} as const;
|
|
7
|
+
|
|
8
|
+
enum POSPath {
|
|
9
|
+
POS = "/pos",
|
|
10
|
+
TABLES = "/pos/tables",
|
|
11
|
+
MENUS = "/pos/menus",
|
|
12
|
+
ORDERS = "/pos/orders",
|
|
13
|
+
PAYMENTS = "/pos/payments",
|
|
14
|
+
BILL = "/pos/bill",
|
|
15
|
+
SUCCESS = "/pos/success",
|
|
16
|
+
MANAGEMENT_FLOOR = "/pos/management-floor",
|
|
17
|
+
ORDER_DETAIL = "/pos/management-order/order-detail",
|
|
18
|
+
ORDERS_KITCHEN_MANAGEMENT = "/pos/kitchens/:kitchenId/orders",
|
|
19
|
+
CUSTOMER_VIEW = "/pos/customer-view",
|
|
20
|
+
SETTING = "setting/single-form",
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default POSPath;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const TEMPLATE_NAME = {
|
|
2
|
+
PARTNER_TEMPLATE: "partner_template",
|
|
3
|
+
PRODUCT_TEMPLATE: "product_template",
|
|
4
|
+
POS_TEMPLATE: "pos_template",
|
|
5
|
+
PREPARATION_TEMPLATE: "preparation_template",
|
|
6
|
+
POS_ORDER_TEMPLATE: "pos_order_template",
|
|
7
|
+
CUSTOMER_PROFILE_TEMPLATE: "customer_profile_template",
|
|
8
|
+
CATEGORY_PRODUCT_TEMPLATE: "category_product_template",
|
|
9
|
+
} as const;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useGetBase64Photo } from "@hooks/common/use-get-base64-photo";
|
|
2
|
+
import { usePosAppProvider } from "@provider/app-provider";
|
|
3
|
+
import { useOrderDetail } from "@provider/pos-provider/order-detail-provider";
|
|
4
|
+
import { useMemo } from "react";
|
|
5
|
+
|
|
6
|
+
const useGetBillInformation = () => {
|
|
7
|
+
const { items } = useOrderDetail();
|
|
8
|
+
const { taxAmount, totalAmount } = useOrderDetail();
|
|
9
|
+
const { company, userProfile } = usePosAppProvider();
|
|
10
|
+
|
|
11
|
+
const { data: brandLogo } = useGetBase64Photo(
|
|
12
|
+
company?.companyInfo.data[0]?.logo
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
// const data: any = convertOrderDetail(orderDetailById);
|
|
16
|
+
|
|
17
|
+
const address = useMemo(() => {
|
|
18
|
+
return userProfile?.company?.address;
|
|
19
|
+
}, [userProfile?.company]);
|
|
20
|
+
|
|
21
|
+
const addressFormat = useMemo(() => {
|
|
22
|
+
return `${address?.street} ${address?.street2}, ${
|
|
23
|
+
address?.ward ?? ""
|
|
24
|
+
}, Tỉnh ${address?.state} `;
|
|
25
|
+
}, [userProfile?.company]);
|
|
26
|
+
|
|
27
|
+
// const paymentMethod = useMemo(() => {
|
|
28
|
+
// return (
|
|
29
|
+
// orderDetailData?.payment_ids?.[0]?.payment_method_id?.display_name ||
|
|
30
|
+
// "Chưa xác định"
|
|
31
|
+
// );
|
|
32
|
+
// }, [orderDetailData]);
|
|
33
|
+
|
|
34
|
+
const amountTotalWithoutTax = useMemo(() => {
|
|
35
|
+
return totalAmount - taxAmount;
|
|
36
|
+
}, [totalAmount, taxAmount]);
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
items,
|
|
40
|
+
company,
|
|
41
|
+
userProfile,
|
|
42
|
+
addressFormat,
|
|
43
|
+
brandLogo,
|
|
44
|
+
paymentMethod: "Tiền mặt",
|
|
45
|
+
amountTotalWithoutTax,
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export default useGetBillInformation;
|
|
File without changes
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { useEnv } from "@fctc/widget-logic/provider";
|
|
2
|
+
|
|
3
|
+
export const loadEnvConfig = () => {
|
|
4
|
+
const { setupEnv, env, setEnvFile } = useEnv();
|
|
5
|
+
async function loadEnvAndConfig() {
|
|
6
|
+
try {
|
|
7
|
+
const envResponse = await fetch("/env.json");
|
|
8
|
+
const envConfig = await envResponse.json();
|
|
9
|
+
const configResponse = await fetch("/config.json");
|
|
10
|
+
const config = await configResponse.json();
|
|
11
|
+
setupEnv({
|
|
12
|
+
baseUrl: envConfig.baseUrl,
|
|
13
|
+
default_service: "mms",
|
|
14
|
+
config: {
|
|
15
|
+
grantType: envConfig.config?.grantType,
|
|
16
|
+
clientId: window.location.hostname.includes("mms")
|
|
17
|
+
? envConfig.config?.mmsClientId
|
|
18
|
+
: envConfig.config?.mpClientId,
|
|
19
|
+
clientSecret: envConfig.config?.clientSecret,
|
|
20
|
+
redirectUri: window.location.hostname.includes("mms")
|
|
21
|
+
? envConfig.config?.mmsRedirectUrl
|
|
22
|
+
: envConfig.config?.mpRedirectUrl,
|
|
23
|
+
websiteCode: window.location.hostname.includes("mms")
|
|
24
|
+
? envConfig.config?.websiteMmscode
|
|
25
|
+
: envConfig.config?.websiteMpcode,
|
|
26
|
+
},
|
|
27
|
+
refreshTokenEndpoint: "/id/api/v2/token",
|
|
28
|
+
// xNode: service === "wesap" ? dataUser?.x_node : "",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
setEnvFile(config);
|
|
32
|
+
|
|
33
|
+
document.documentElement.style.setProperty(
|
|
34
|
+
"--background-button",
|
|
35
|
+
config?.VITE_BG_BUTTON
|
|
36
|
+
);
|
|
37
|
+
document.documentElement.style.setProperty(
|
|
38
|
+
"--primary",
|
|
39
|
+
config?.VITE_BG_BUTTON
|
|
40
|
+
);
|
|
41
|
+
document.documentElement.style.setProperty(
|
|
42
|
+
"--background-page",
|
|
43
|
+
config?.VITE_BACKGROUND_PAGE
|
|
44
|
+
);
|
|
45
|
+
document.documentElement.style.setProperty(
|
|
46
|
+
"--text-color",
|
|
47
|
+
config?.TEXT_COLOR
|
|
48
|
+
);
|
|
49
|
+
document.documentElement.style.setProperty(
|
|
50
|
+
"--stroke-default",
|
|
51
|
+
config?.STROKE_DEFAULT
|
|
52
|
+
);
|
|
53
|
+
document.documentElement.style.setProperty(
|
|
54
|
+
"--selected-color",
|
|
55
|
+
config?.SELECTED_COLOR
|
|
56
|
+
);
|
|
57
|
+
document.documentElement.style.setProperty(
|
|
58
|
+
"--active-menu-bg-color",
|
|
59
|
+
config?.SIDEBAR_ACTIVE_MENU_BACKGROUND
|
|
60
|
+
);
|
|
61
|
+
document.documentElement.style.setProperty(
|
|
62
|
+
"--active-menu-text-color",
|
|
63
|
+
config?.SIDEBAR_ACTIVE_MENU_TEXT
|
|
64
|
+
);
|
|
65
|
+
document.documentElement.style.setProperty(
|
|
66
|
+
"--active-border-color",
|
|
67
|
+
config?.BORDER_ACTIVE_COLOR
|
|
68
|
+
);
|
|
69
|
+
document.documentElement.style.setProperty(
|
|
70
|
+
"--text-button",
|
|
71
|
+
config?.TEXT_BUTTON
|
|
72
|
+
);
|
|
73
|
+
document.documentElement.style.setProperty(
|
|
74
|
+
"--text-active-primary",
|
|
75
|
+
config?.ACTIVE_PRIMARY_COLOR
|
|
76
|
+
);
|
|
77
|
+
document.documentElement.style.setProperty(
|
|
78
|
+
"--text-active-secondary",
|
|
79
|
+
config?.ACTIVE_SECONDARY_COLOR
|
|
80
|
+
);
|
|
81
|
+
document.documentElement.style.setProperty(
|
|
82
|
+
"--text-take-away-color",
|
|
83
|
+
config?.TAKE_AWAY_COLOR
|
|
84
|
+
);
|
|
85
|
+
document.documentElement.style.setProperty(
|
|
86
|
+
"--text-unavailable-table-color",
|
|
87
|
+
config?.UNAVAILABLE_TABLE_COLOR
|
|
88
|
+
);
|
|
89
|
+
document.documentElement.style.setProperty(
|
|
90
|
+
"--text-surface-primary",
|
|
91
|
+
config?.SURFACE_PRIMARY_COLOR
|
|
92
|
+
);
|
|
93
|
+
} catch (error) {
|
|
94
|
+
console.error("Error loading env or config:", error);
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return { loadEnvAndConfig };
|
|
98
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { startTransition } from "react";
|
|
2
|
+
import { useNavigate } from "react-router-dom";
|
|
3
|
+
|
|
4
|
+
const useBack = () => {
|
|
5
|
+
const navigate = useNavigate();
|
|
6
|
+
return () => {
|
|
7
|
+
startTransition(() => {
|
|
8
|
+
navigate(-1);
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default useBack;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
export function useBroadcast<T>(
|
|
4
|
+
channelName: string,
|
|
5
|
+
onMessage: (msg: T) => void
|
|
6
|
+
) {
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
const bc = new BroadcastChannel(channelName);
|
|
9
|
+
bc.onmessage = (event) => {
|
|
10
|
+
onMessage(event.data);
|
|
11
|
+
};
|
|
12
|
+
return () => bc.close();
|
|
13
|
+
}, [channelName, onMessage]);
|
|
14
|
+
|
|
15
|
+
const postMessage = (msg: T) => {
|
|
16
|
+
const bc = new BroadcastChannel(channelName);
|
|
17
|
+
bc.postMessage(msg);
|
|
18
|
+
bc.close();
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return { postMessage };
|
|
22
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { useEffect, useRef, type RefObject } from "react";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_EVENTS = ["mousedown", "touchstart"] as const;
|
|
4
|
+
|
|
5
|
+
type EventType = (typeof DEFAULT_EVENTS)[number];
|
|
6
|
+
|
|
7
|
+
interface UseClickOutsideOptions {
|
|
8
|
+
handler: (event?: Event) => void;
|
|
9
|
+
events?: readonly EventType[];
|
|
10
|
+
nodes?: (HTMLDivElement | null)[]; // Ensure consistency with HTMLDivElement
|
|
11
|
+
refs?: any;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const useClickOutside = ({
|
|
15
|
+
handler,
|
|
16
|
+
events = DEFAULT_EVENTS,
|
|
17
|
+
nodes = [], // Default to empty array to avoid undefined errors
|
|
18
|
+
refs,
|
|
19
|
+
}: UseClickOutsideOptions): RefObject<HTMLDivElement | null> => {
|
|
20
|
+
const ref = useRef<HTMLDivElement>(null);
|
|
21
|
+
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
const listener = (event: Event) => {
|
|
24
|
+
const { target } = event as MouseEvent | TouchEvent;
|
|
25
|
+
|
|
26
|
+
if (
|
|
27
|
+
refs &&
|
|
28
|
+
refs?.length > 0 &&
|
|
29
|
+
refs?.some((r: any) => r.current?.contains(target as Node))
|
|
30
|
+
) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (!(target instanceof HTMLElement)) return;
|
|
35
|
+
|
|
36
|
+
const shouldIgnore =
|
|
37
|
+
target.hasAttribute("data-ignore-outside-clicks") ||
|
|
38
|
+
(!document.body.contains(target) && target.tagName !== "HTML");
|
|
39
|
+
|
|
40
|
+
const shouldTrigger =
|
|
41
|
+
nodes.length > 0
|
|
42
|
+
? nodes.every((node) => node && !event.composedPath().includes(node))
|
|
43
|
+
: ref.current && !ref.current.contains(target);
|
|
44
|
+
|
|
45
|
+
if (shouldTrigger && !shouldIgnore) {
|
|
46
|
+
handler(event);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
events.forEach((event) => document.addEventListener(event, listener));
|
|
51
|
+
|
|
52
|
+
return () => {
|
|
53
|
+
events.forEach((event) => document.removeEventListener(event, listener));
|
|
54
|
+
};
|
|
55
|
+
}, [handler, nodes, events]);
|
|
56
|
+
|
|
57
|
+
return ref;
|
|
58
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
|
|
3
|
+
export const useGetBase64Photo = (src?: string) => {
|
|
4
|
+
const queryResult = useQuery({
|
|
5
|
+
queryKey: ["photo-base64", src],
|
|
6
|
+
queryFn: () => urlToBase64(src ?? ""),
|
|
7
|
+
enabled: !!src,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
isLoading: queryResult.isLoading,
|
|
12
|
+
data: src ? queryResult.data : undefined,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
async function urlToBase64(url: string): Promise<string> {
|
|
17
|
+
try {
|
|
18
|
+
// 1️⃣ Fetch ảnh (binary)
|
|
19
|
+
const response = await fetch(url, { mode: "cors" });
|
|
20
|
+
if (!response.ok) throw new Error(`Fetch failed: ${response.statusText}`);
|
|
21
|
+
|
|
22
|
+
const contentType = response.headers.get("content-type") || "";
|
|
23
|
+
|
|
24
|
+
// 2️⃣ Nếu là SVG
|
|
25
|
+
if (contentType.includes("image/svg")) {
|
|
26
|
+
const svgText = await response.text();
|
|
27
|
+
const svgBlob = new Blob([svgText], { type: "image/svg+xml" });
|
|
28
|
+
const svgUrl = URL.createObjectURL(svgBlob);
|
|
29
|
+
const pngBase64 = await convertSvgToPngBase64(svgUrl);
|
|
30
|
+
URL.revokeObjectURL(svgUrl);
|
|
31
|
+
return pngBase64;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// 3️⃣ Nếu là ảnh thường (png/jpg/webp)
|
|
35
|
+
const blob = await response.blob();
|
|
36
|
+
const imgUrl = URL.createObjectURL(blob);
|
|
37
|
+
const pngBase64 = await convertSvgToPngBase64(imgUrl);
|
|
38
|
+
URL.revokeObjectURL(imgUrl);
|
|
39
|
+
return pngBase64;
|
|
40
|
+
} catch (err) {
|
|
41
|
+
console.error("urlToBase64 error:", err);
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Ảnh SVG hoặc PNG → PNG base64
|
|
47
|
+
function convertSvgToPngBase64(imageUrl: string): Promise<string> {
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
const img = new Image();
|
|
50
|
+
img.crossOrigin = "anonymous";
|
|
51
|
+
img.onload = () => {
|
|
52
|
+
const canvas = document.createElement("canvas");
|
|
53
|
+
const width = img.naturalWidth || img.width || 512;
|
|
54
|
+
const height = img.naturalHeight || img.height || 512;
|
|
55
|
+
canvas.width = width;
|
|
56
|
+
canvas.height = height;
|
|
57
|
+
|
|
58
|
+
const ctx = canvas.getContext("2d");
|
|
59
|
+
ctx?.drawImage(img, 0, 0, width, height);
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
const base64 = canvas.toDataURL("image/png");
|
|
63
|
+
resolve(base64);
|
|
64
|
+
} catch (err) {
|
|
65
|
+
reject(err);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
img.onerror = reject;
|
|
69
|
+
img.src = imageUrl;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { QUERY_KEYS } from "@constants/query.constant"
|
|
2
|
+
import { useMemo } from "react"
|
|
3
|
+
import { useQueryParams } from "./use-query-params"
|
|
4
|
+
|
|
5
|
+
const useGetQuery = () => {
|
|
6
|
+
const { getQuery } = useQueryParams()
|
|
7
|
+
|
|
8
|
+
return useMemo(() => {
|
|
9
|
+
const orderId = getQuery(QUERY_KEYS.ORDER_ID)
|
|
10
|
+
const sessionId = getQuery(QUERY_KEYS.SESSION_ID)
|
|
11
|
+
const posId = Number(getQuery(QUERY_KEYS.POS_ID)) || 5
|
|
12
|
+
const kitchenOrderStatus = Number(getQuery(QUERY_KEYS.KITCHEN_ORDER_STATUS))
|
|
13
|
+
const floorId = Number(getQuery(QUERY_KEYS.FLOOR))
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
orderId,
|
|
17
|
+
sessionId,
|
|
18
|
+
posId,
|
|
19
|
+
kitchenOrderStatus,
|
|
20
|
+
floorId,
|
|
21
|
+
}
|
|
22
|
+
}, [getQuery])
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export default useGetQuery
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { sessionStorageUtils } from "@fctc/widget-logic/utils";
|
|
2
|
+
import { usePosAppProvider } from "@provider/app-provider";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
|
|
5
|
+
const usePos = () => {
|
|
6
|
+
const { user } = usePosAppProvider();
|
|
7
|
+
|
|
8
|
+
return useMemo(() => {
|
|
9
|
+
const dataUser = user?.userProfile?.data;
|
|
10
|
+
const service = sessionStorageUtils.getMenuFocus().service || `wesap`;
|
|
11
|
+
const xNode = dataUser?.x_node || "";
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
dataUser,
|
|
15
|
+
service,
|
|
16
|
+
xNode,
|
|
17
|
+
};
|
|
18
|
+
}, [user]);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default usePos;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useSearchParams } from "react-router-dom";
|
|
2
|
+
|
|
3
|
+
export const useQueryParams = () => {
|
|
4
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
5
|
+
|
|
6
|
+
const getQuery = (key: string) => {
|
|
7
|
+
return searchParams.get(key);
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const updateQuery = (key: string, value: string) => {
|
|
11
|
+
setSearchParams(
|
|
12
|
+
(prev) => {
|
|
13
|
+
const params = new URLSearchParams(prev);
|
|
14
|
+
params.set(key, value);
|
|
15
|
+
return params;
|
|
16
|
+
},
|
|
17
|
+
{ replace: true }
|
|
18
|
+
);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const updateMultipleQuery = (query: QueryObject[]) => {
|
|
22
|
+
setSearchParams(
|
|
23
|
+
(prev) => {
|
|
24
|
+
const params = new URLSearchParams(prev);
|
|
25
|
+
query.forEach((q) => {
|
|
26
|
+
if (q.value) params.set(q.key, q.value);
|
|
27
|
+
else params.delete(q.key);
|
|
28
|
+
});
|
|
29
|
+
return params;
|
|
30
|
+
},
|
|
31
|
+
{ replace: true }
|
|
32
|
+
);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
function removeParam(keys: string[]) {
|
|
36
|
+
setSearchParams(
|
|
37
|
+
(prev) => {
|
|
38
|
+
const params = new URLSearchParams(prev.toString());
|
|
39
|
+
|
|
40
|
+
keys.forEach((key) => {
|
|
41
|
+
params.delete(key);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
return params;
|
|
45
|
+
},
|
|
46
|
+
{ replace: true }
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function removeParams(keys: string[]) {
|
|
51
|
+
setSearchParams(
|
|
52
|
+
(prev) => {
|
|
53
|
+
const params = new URLSearchParams(prev);
|
|
54
|
+
keys.forEach((key) => {
|
|
55
|
+
params.delete(key);
|
|
56
|
+
});
|
|
57
|
+
return params;
|
|
58
|
+
},
|
|
59
|
+
{ replace: true }
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function formatQuery(allowedKeys: string[]) {
|
|
64
|
+
const params = new URLSearchParams(searchParams.toString());
|
|
65
|
+
const filtered = new URLSearchParams();
|
|
66
|
+
|
|
67
|
+
for (const key of allowedKeys) {
|
|
68
|
+
const value = params.get(key);
|
|
69
|
+
if (value !== null) {
|
|
70
|
+
filtered.set(key, value);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return filtered.toString();
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
getQuery,
|
|
78
|
+
formatQuery,
|
|
79
|
+
updateQuery,
|
|
80
|
+
removeParam,
|
|
81
|
+
updateMultipleQuery,
|
|
82
|
+
removeParams,
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
interface QueryObject {
|
|
87
|
+
key: string;
|
|
88
|
+
value?: string;
|
|
89
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export const useSpeech = () => {
|
|
2
|
+
const speak = async (text: string, lang: string = "vi-VN") => {
|
|
3
|
+
try {
|
|
4
|
+
const envResponse = await fetch("/env.json");
|
|
5
|
+
const envConfig = await envResponse.json();
|
|
6
|
+
const res = await fetch(
|
|
7
|
+
`https://texttospeech.googleapis.com/v1/text:synthesize?key=${envConfig.config.googleKey}`,
|
|
8
|
+
{
|
|
9
|
+
method: "POST",
|
|
10
|
+
headers: { "Content-Type": "application/json" },
|
|
11
|
+
body: JSON.stringify({
|
|
12
|
+
input: { text },
|
|
13
|
+
voice: { languageCode: lang, name: "vi-VN-Wavenet-A" },
|
|
14
|
+
audioConfig: { audioEncoding: "MP3" },
|
|
15
|
+
}),
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
const data = await res.json();
|
|
20
|
+
const audioContent = data.audioContent;
|
|
21
|
+
const audio = new Audio("data:audio/mp3;base64," + audioContent);
|
|
22
|
+
await audio.play();
|
|
23
|
+
} catch (err) {
|
|
24
|
+
console.error("❌ Google TTS lỗi:", err);
|
|
25
|
+
// await TextToSpeech.speak({ text, lang });
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// const stop = async () => {
|
|
30
|
+
// await TextToSpeech.stop();
|
|
31
|
+
// };
|
|
32
|
+
return {
|
|
33
|
+
speak,
|
|
34
|
+
stop,
|
|
35
|
+
};
|
|
36
|
+
};
|