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,118 @@
|
|
|
1
|
+
import { Skeleton } from "@components/common/skeleton";
|
|
2
|
+
import useCheckSession from "@components/common/use-check-session";
|
|
3
|
+
import { ORDER_STATE } from "@constants/order-state";
|
|
4
|
+
import { useEnv } from "@fctc/widget-logic/provider";
|
|
5
|
+
import useGetQuery from "@hooks/common/use-get-query";
|
|
6
|
+
import { useQueryParams } from "@hooks/common/use-query-params";
|
|
7
|
+
import { useOrder } from "@provider/pos-provider/order-provider";
|
|
8
|
+
import { usePayment } from "@provider/pos-provider/payment-provider";
|
|
9
|
+
import { useSale } from "@provider/pos-provider/sale-provider";
|
|
10
|
+
import { useEffect, useState } from "react";
|
|
11
|
+
import { toast } from "react-toastify";
|
|
12
|
+
import { PaymentInfo } from "../payment-info";
|
|
13
|
+
import { PaymentLayout } from "../payment-layout";
|
|
14
|
+
import SessionCloseModal from "../session-close-modal";
|
|
15
|
+
import QRCode from "./qr_code";
|
|
16
|
+
|
|
17
|
+
type Props = {
|
|
18
|
+
total: number;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const QRPayment = ({ total }: Props) => {
|
|
22
|
+
const { onGeneratePaymentQrInfo } = usePayment();
|
|
23
|
+
const [qrCode, setQrCode] = useState("");
|
|
24
|
+
const { env } = useEnv();
|
|
25
|
+
const { orderId, sessionId } = useGetQuery();
|
|
26
|
+
const { updateQuery } = useQueryParams();
|
|
27
|
+
const { orderDetailById } = useOrder();
|
|
28
|
+
|
|
29
|
+
const handleGetQrPaymentInfo = async () => {
|
|
30
|
+
try {
|
|
31
|
+
if (!sessionId) return;
|
|
32
|
+
if (!orderId) return;
|
|
33
|
+
const data = await onGeneratePaymentQrInfo(total, sessionId, orderId);
|
|
34
|
+
if (!data) return;
|
|
35
|
+
|
|
36
|
+
const qrCode = QRCode(
|
|
37
|
+
data.amount.toString(),
|
|
38
|
+
data.narrative,
|
|
39
|
+
data.account_no,
|
|
40
|
+
data.bin_code
|
|
41
|
+
);
|
|
42
|
+
setQrCode(qrCode.imgTag);
|
|
43
|
+
} catch (error: any) {
|
|
44
|
+
toast.error(error?.message || "");
|
|
45
|
+
console.log("error", error);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const [showCloseSessionModal, setShowCloseSessionModal] = useState(false);
|
|
50
|
+
const { onCheckSession } = useCheckSession();
|
|
51
|
+
const { queryResult } = useSale();
|
|
52
|
+
|
|
53
|
+
const handleCheckPayment = async () => {
|
|
54
|
+
const isSessionOpened = await onCheckSession();
|
|
55
|
+
|
|
56
|
+
if (!isSessionOpened) {
|
|
57
|
+
setShowCloseSessionModal(true);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
try {
|
|
64
|
+
handleGetQrPaymentInfo();
|
|
65
|
+
} catch (error) {
|
|
66
|
+
console.log("error", error);
|
|
67
|
+
}
|
|
68
|
+
handleCheckPayment();
|
|
69
|
+
const interval = setInterval(() => {
|
|
70
|
+
if (
|
|
71
|
+
orderDetailById?.state === ORDER_STATE.IN_PAID ||
|
|
72
|
+
orderDetailById?.state === ORDER_STATE.NEW
|
|
73
|
+
) {
|
|
74
|
+
queryResult.refetch();
|
|
75
|
+
}
|
|
76
|
+
}, 3000);
|
|
77
|
+
|
|
78
|
+
return () => {
|
|
79
|
+
clearInterval(interval);
|
|
80
|
+
};
|
|
81
|
+
}, []);
|
|
82
|
+
|
|
83
|
+
return (
|
|
84
|
+
<div className="h-full flex items-center justify-center w-full">
|
|
85
|
+
<QRContent qrData={qrCode} />
|
|
86
|
+
{showCloseSessionModal && (
|
|
87
|
+
<SessionCloseModal isOpen={showCloseSessionModal} onClose={() => {}} />
|
|
88
|
+
)}
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const QRContent = ({ qrData }: { qrData: string }) => {
|
|
94
|
+
return (
|
|
95
|
+
<PaymentLayout
|
|
96
|
+
leftContent={<QrPaymentCode qrData={qrData} />}
|
|
97
|
+
rightContent={<PaymentInfo />}
|
|
98
|
+
/>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const QrPaymentCode = ({ qrData }: { qrData: string }) => {
|
|
103
|
+
return (
|
|
104
|
+
<div className="flex flex-col items-center gap-4 size-[250px]">
|
|
105
|
+
<div className="flex-1 flex flex-col gap-2 items-center justify-center w-[235px]">
|
|
106
|
+
{qrData ? (
|
|
107
|
+
<div
|
|
108
|
+
className="w-full h-full [&>img]:w-full [&>img]:h-full [&>img]:object-contain"
|
|
109
|
+
dangerouslySetInnerHTML={{ __html: qrData }}
|
|
110
|
+
/>
|
|
111
|
+
) : (
|
|
112
|
+
<Skeleton className="size-[260px] rounded-lg" />
|
|
113
|
+
)}
|
|
114
|
+
<img src="/assets/images/bank-logos.png" className="w-full" />
|
|
115
|
+
</div>
|
|
116
|
+
</div>
|
|
117
|
+
);
|
|
118
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import QRCODE from "@unicube/vietqr/qrcode.js";
|
|
2
|
+
|
|
3
|
+
import { CURRENCY, SERVICE_CODE, VIETQR } from "./vietqr.js";
|
|
4
|
+
|
|
5
|
+
const QRCode = (amount, description, accountNumber, bankCode) => {
|
|
6
|
+
let vietQRdata = new VIETQR();
|
|
7
|
+
|
|
8
|
+
vietQRdata.fields.is_dynamic_qr = true;
|
|
9
|
+
vietQRdata.fields.merchant_category = "9999";
|
|
10
|
+
vietQRdata.fields.amount = amount;
|
|
11
|
+
vietQRdata.fields.acq = bankCode;
|
|
12
|
+
vietQRdata.fields.merchant_id = accountNumber;
|
|
13
|
+
vietQRdata.fields.service_code = SERVICE_CODE.TO_ACCOUNT;
|
|
14
|
+
vietQRdata.fields.purpose_txn = description;
|
|
15
|
+
vietQRdata.fields.currency = CURRENCY.VND;
|
|
16
|
+
let vietQRData = vietQRdata.builder();
|
|
17
|
+
let qrcode = new QRCODE(0, "M");
|
|
18
|
+
|
|
19
|
+
qrcode.addData(vietQRData, "Byte");
|
|
20
|
+
|
|
21
|
+
qrcode.make();
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
imgTag: qrcode.createImgTag(),
|
|
25
|
+
qrData: vietQRData,
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default QRCode;
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
const SERVICE_CODE = {
|
|
2
|
+
PAYMENT: "QRPUSH",
|
|
3
|
+
TO_CARD: "QRIBFTTC",
|
|
4
|
+
TO_ACCOUNT: "QRIBFTTA",
|
|
5
|
+
};
|
|
6
|
+
const NAPAS_GUID = "A000000727";
|
|
7
|
+
const CURRENCY = {
|
|
8
|
+
VND: "704",
|
|
9
|
+
USD: "840",
|
|
10
|
+
};
|
|
11
|
+
var FIELDS = {
|
|
12
|
+
is_dynamic_qr: true,
|
|
13
|
+
merchant_category: "",
|
|
14
|
+
merchant_name: "",
|
|
15
|
+
merchant_city: "",
|
|
16
|
+
postal_code: "",
|
|
17
|
+
currency: "704",
|
|
18
|
+
country_code: "VN",
|
|
19
|
+
amount: "0",
|
|
20
|
+
acq: "970403",
|
|
21
|
+
merchant_id: "",
|
|
22
|
+
service_code: SERVICE_CODE.TO_ACCOUNT,
|
|
23
|
+
bill_number: "",
|
|
24
|
+
mobile_number: "",
|
|
25
|
+
store_label: "",
|
|
26
|
+
loyalty_number: "",
|
|
27
|
+
ref_label: "",
|
|
28
|
+
customer_label: "",
|
|
29
|
+
terminal_label: "",
|
|
30
|
+
purpose_txn: "",
|
|
31
|
+
additional_data: "",
|
|
32
|
+
lang_ref: "",
|
|
33
|
+
local_merchant_name: "",
|
|
34
|
+
local_merchant_city: "",
|
|
35
|
+
uuid: "",
|
|
36
|
+
ipn_url: "",
|
|
37
|
+
app_package_name: "",
|
|
38
|
+
custom_data: "",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function pad_left(n, width, z) {
|
|
42
|
+
z = z || "0";
|
|
43
|
+
n = n + "";
|
|
44
|
+
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const CRC = {
|
|
48
|
+
stringToUtf8ByteArray(str) {
|
|
49
|
+
var out = [],
|
|
50
|
+
p = 0;
|
|
51
|
+
for (var i = 0; i < str.length; i++) {
|
|
52
|
+
var c = str.charCodeAt(i);
|
|
53
|
+
if (c < 128) {
|
|
54
|
+
out[p++] = c;
|
|
55
|
+
} else if (c < 2048) {
|
|
56
|
+
out[p++] = (c >> 6) | 192;
|
|
57
|
+
out[p++] = (c & 63) | 128;
|
|
58
|
+
} else if (
|
|
59
|
+
(c & 0xfc00) == 0xd800 &&
|
|
60
|
+
i + 1 < str.length &&
|
|
61
|
+
(str.charCodeAt(i + 1) & 0xfc00) == 0xdc00
|
|
62
|
+
) {
|
|
63
|
+
// Surrogate Pair
|
|
64
|
+
c = 0x10000 + ((c & 0x03ff) << 10) + (str.charCodeAt(++i) & 0x03ff);
|
|
65
|
+
out[p++] = (c >> 18) | 240;
|
|
66
|
+
out[p++] = ((c >> 12) & 63) | 128;
|
|
67
|
+
out[p++] = ((c >> 6) & 63) | 128;
|
|
68
|
+
out[p++] = (c & 63) | 128;
|
|
69
|
+
} else {
|
|
70
|
+
out[p++] = (c >> 12) | 224;
|
|
71
|
+
out[p++] = ((c >> 6) & 63) | 128;
|
|
72
|
+
out[p++] = (c & 63) | 128;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return out;
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Function này phải dùng stringToUtf8ByteArray để convert về Byte[]
|
|
80
|
+
* @param {*} str
|
|
81
|
+
* @param {*} offset
|
|
82
|
+
* @returns
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
getCrc16(str, offset = 0) {
|
|
86
|
+
let data = this.stringToUtf8ByteArray(str);
|
|
87
|
+
if (
|
|
88
|
+
data == null ||
|
|
89
|
+
offset < 0 ||
|
|
90
|
+
offset > data.length - 1 ||
|
|
91
|
+
offset + length > data.length
|
|
92
|
+
) {
|
|
93
|
+
return 0;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
let crc = 0xffff;
|
|
97
|
+
for (let i = 0; i < str.length; ++i) {
|
|
98
|
+
crc ^= data[offset + i] << 8;
|
|
99
|
+
for (let j = 0; j < 8; ++j) {
|
|
100
|
+
crc = (crc & 0x8000) > 0 ? (crc << 1) ^ 0x1021 : crc << 1;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return (crc & 0xffff).toString(16).toUpperCase();
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Function này không dùng stringToUtf8ByteArray để convert về Byte[]
|
|
108
|
+
* @param {Chuỗi cần check CRC} text
|
|
109
|
+
* @param {true hoặc false, mặc định là true} hex_output
|
|
110
|
+
* @returns {Chuỗi CRC}
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
getCrc16_array(text, hex_output = true) {
|
|
114
|
+
if (!Array.isArray(text)) text = [[text]];
|
|
115
|
+
const polynomial = 0x1021;
|
|
116
|
+
let result = text.map((row) =>
|
|
117
|
+
row.map((string) => {
|
|
118
|
+
if (!string.length) return null;
|
|
119
|
+
const bytes = Array.from(String(string)).map(
|
|
120
|
+
(char) => char.charCodeAt(0) & 0xff
|
|
121
|
+
); // gives 8 bits; higher bits get discarded
|
|
122
|
+
let crc = 0xffff;
|
|
123
|
+
bytes.forEach((byte) => {
|
|
124
|
+
for (let i = 0; i < 8; i++) {
|
|
125
|
+
let bit = 1 === ((byte >> (7 - i)) & 1);
|
|
126
|
+
let c15 = 1 === ((crc >> 15) & 1);
|
|
127
|
+
crc <<= 1;
|
|
128
|
+
if (c15 ^ bit) crc ^= polynomial;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
crc &= 0xffff;
|
|
132
|
+
// Padding handling
|
|
133
|
+
let crcHexString = crc.toString(16).toUpperCase();
|
|
134
|
+
crcHexString =
|
|
135
|
+
crcHexString.length < 4 ? pad_left(crcHexString, 4) : crcHexString;
|
|
136
|
+
return hex_output ? crcHexString : crc;
|
|
137
|
+
})
|
|
138
|
+
);
|
|
139
|
+
return result.toString();
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* This function is used for replace special character and Vietnamese Utf-8 character to ASCII character
|
|
144
|
+
* @param {*} str
|
|
145
|
+
* @returns
|
|
146
|
+
*/
|
|
147
|
+
nonAccentVietnamese(str) {
|
|
148
|
+
str = str.toLowerCase();
|
|
149
|
+
str = str.replace(new RegExp("/", "g"), "-");
|
|
150
|
+
str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
|
|
151
|
+
str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
|
|
152
|
+
str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
|
|
153
|
+
str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
|
|
154
|
+
str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
|
|
155
|
+
str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
|
|
156
|
+
str = str.replace(/đ/g, "d");
|
|
157
|
+
// Some system encode vietnamese combining accent as individual utf-8 characters
|
|
158
|
+
str = str.replace(/\u0300|\u0301|\u0303|\u0309|\u0323/g, ""); // Huyền sắc hỏi ngã nặng
|
|
159
|
+
str = str.replace(/\u02C6|\u0306|\u031B/g, ""); // Â, Ê, Ă, Ơ, Ư
|
|
160
|
+
return str.toUpperCase().trim();
|
|
161
|
+
},
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
const TLV = class {
|
|
165
|
+
constructor(
|
|
166
|
+
id = 0,
|
|
167
|
+
name = "",
|
|
168
|
+
length = 99,
|
|
169
|
+
is_fixed = true,
|
|
170
|
+
presense = "O",
|
|
171
|
+
// eslint-disable-next-line no-constant-binary-expression
|
|
172
|
+
value = "" || []
|
|
173
|
+
) {
|
|
174
|
+
this.tagId = id;
|
|
175
|
+
this.tagName = name;
|
|
176
|
+
if (is_fixed) {
|
|
177
|
+
this.tagLength = length;
|
|
178
|
+
} else {
|
|
179
|
+
this.tagLength = name.length;
|
|
180
|
+
}
|
|
181
|
+
this.tagValue = value;
|
|
182
|
+
this.presense = presense;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
toString() {
|
|
186
|
+
let value = "";
|
|
187
|
+
if (Array.isArray(this.tagValue)) {
|
|
188
|
+
for (let de = 0; de < this.tagValue.length; de++) {
|
|
189
|
+
if (this.tagValue[de] instanceof TLV) {
|
|
190
|
+
if (this.tagValue[de].tagValue !== "") {
|
|
191
|
+
value += this.tagValue[de].toString();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
} else {
|
|
196
|
+
value = this.tagValue;
|
|
197
|
+
}
|
|
198
|
+
if (value === "") {
|
|
199
|
+
return "";
|
|
200
|
+
} else {
|
|
201
|
+
this.tagLength = value.length;
|
|
202
|
+
return `${this.tagId >= 10 ? `${this.tagId}` : `0${this.tagId}`}${
|
|
203
|
+
this.tagLength >= 10 ? `${this.tagLength}` : `0${this.tagLength}`
|
|
204
|
+
}${value}`;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
//Classes
|
|
210
|
+
const VIETQR = class {
|
|
211
|
+
constructor() {
|
|
212
|
+
this.data = [];
|
|
213
|
+
this.fields = FIELDS;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
toStringNoCrc() {
|
|
217
|
+
let str = "";
|
|
218
|
+
for (let de = 0; de < this.data.length; de++) {
|
|
219
|
+
if (this.data[de] instanceof TLV) {
|
|
220
|
+
let deString = this.data[de].toString();
|
|
221
|
+
str += deString;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return `${str}6304`;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
getCrc() {
|
|
228
|
+
return CRC.getCrc16_array(this.toStringNoCrc());
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
toString() {
|
|
232
|
+
let semi_vietqr = this.toStringNoCrc();
|
|
233
|
+
let crc_value = this.getCrc();
|
|
234
|
+
return `${semi_vietqr}${crc_value}`;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
builder() {
|
|
238
|
+
this.data[0] = new TLV(0, "Payload Format Indicator", 2, true, "M", "01");
|
|
239
|
+
this.data[1] = new TLV(
|
|
240
|
+
1,
|
|
241
|
+
"QR Type",
|
|
242
|
+
2,
|
|
243
|
+
true,
|
|
244
|
+
"M",
|
|
245
|
+
this.fields.is_dynamic_qr ? "12" : "11"
|
|
246
|
+
);
|
|
247
|
+
this.data[38] = new TLV(
|
|
248
|
+
38,
|
|
249
|
+
"QR code service on NAPAS system",
|
|
250
|
+
99,
|
|
251
|
+
false,
|
|
252
|
+
"M",
|
|
253
|
+
[
|
|
254
|
+
new TLV(
|
|
255
|
+
0,
|
|
256
|
+
"Global Unique Identifier - GUID",
|
|
257
|
+
10,
|
|
258
|
+
true,
|
|
259
|
+
"M",
|
|
260
|
+
NAPAS_GUID
|
|
261
|
+
),
|
|
262
|
+
new TLV(1, "Payment network specific", 32, false, "M", [
|
|
263
|
+
new TLV(0, "Acquier ID/BNB ID", 6, true, "M", this.fields.acq),
|
|
264
|
+
new TLV(
|
|
265
|
+
1,
|
|
266
|
+
"Merchant ID/Consumer ID",
|
|
267
|
+
19,
|
|
268
|
+
false,
|
|
269
|
+
"M",
|
|
270
|
+
this.fields.merchant_id
|
|
271
|
+
),
|
|
272
|
+
]),
|
|
273
|
+
new TLV(2, "Service Code", 10, false, "C", this.fields.service_code),
|
|
274
|
+
]
|
|
275
|
+
);
|
|
276
|
+
this.data[52] = new TLV(
|
|
277
|
+
52,
|
|
278
|
+
"Merchant Category Code",
|
|
279
|
+
4,
|
|
280
|
+
true,
|
|
281
|
+
"O",
|
|
282
|
+
this.fields.merchant_category
|
|
283
|
+
);
|
|
284
|
+
this.data[53] = new TLV(
|
|
285
|
+
53,
|
|
286
|
+
"Transaction Currency",
|
|
287
|
+
3,
|
|
288
|
+
true,
|
|
289
|
+
"M",
|
|
290
|
+
this.fields.currency
|
|
291
|
+
);
|
|
292
|
+
this.data[54] = new TLV(
|
|
293
|
+
54,
|
|
294
|
+
"Transaction Amount",
|
|
295
|
+
13,
|
|
296
|
+
false,
|
|
297
|
+
"C",
|
|
298
|
+
this.fields.is_dynamic_qr ? this.fields.amount : ""
|
|
299
|
+
);
|
|
300
|
+
this.data[55] = new TLV(55, "Tip or Convenience Indicator", 2, true, "O");
|
|
301
|
+
this.data[56] = new TLV(
|
|
302
|
+
56,
|
|
303
|
+
"Value of Convenience Fee Fixed",
|
|
304
|
+
13,
|
|
305
|
+
false,
|
|
306
|
+
"O"
|
|
307
|
+
);
|
|
308
|
+
this.data[57] = new TLV(
|
|
309
|
+
57,
|
|
310
|
+
"Value of Convenience Fee Percentage",
|
|
311
|
+
5,
|
|
312
|
+
false,
|
|
313
|
+
"O"
|
|
314
|
+
);
|
|
315
|
+
this.data[58] = new TLV(
|
|
316
|
+
58,
|
|
317
|
+
"Country Code",
|
|
318
|
+
2,
|
|
319
|
+
true,
|
|
320
|
+
"M",
|
|
321
|
+
this.fields.country_code
|
|
322
|
+
);
|
|
323
|
+
this.data[59] = new TLV(
|
|
324
|
+
59,
|
|
325
|
+
"Merchant Name",
|
|
326
|
+
25,
|
|
327
|
+
false,
|
|
328
|
+
"O",
|
|
329
|
+
this.fields.merchant_name
|
|
330
|
+
);
|
|
331
|
+
this.data[60] = new TLV(
|
|
332
|
+
60,
|
|
333
|
+
"Merchant City",
|
|
334
|
+
15,
|
|
335
|
+
false,
|
|
336
|
+
"O",
|
|
337
|
+
this.fields.merchant_city
|
|
338
|
+
);
|
|
339
|
+
this.data[61] = new TLV(
|
|
340
|
+
61,
|
|
341
|
+
"Postal Code",
|
|
342
|
+
10,
|
|
343
|
+
false,
|
|
344
|
+
"O",
|
|
345
|
+
this.fields.postal_code
|
|
346
|
+
);
|
|
347
|
+
this.data[62] = new TLV(
|
|
348
|
+
62,
|
|
349
|
+
"Additional Data Field Template",
|
|
350
|
+
99,
|
|
351
|
+
true,
|
|
352
|
+
"O",
|
|
353
|
+
[
|
|
354
|
+
null,
|
|
355
|
+
new TLV(1, "Bill Number", 25, false, "C", this.fields.bill_number),
|
|
356
|
+
new TLV(2, "Mobile Number", 25, false, "C", this.fields.mobile_number),
|
|
357
|
+
new TLV(3, "Store Label", 25, false, "O", this.fields.store_label),
|
|
358
|
+
new TLV(
|
|
359
|
+
4,
|
|
360
|
+
"Loyalty Number",
|
|
361
|
+
25,
|
|
362
|
+
false,
|
|
363
|
+
"O",
|
|
364
|
+
this.fields.loyalty_number
|
|
365
|
+
),
|
|
366
|
+
new TLV(5, "Reference Label", 25, false, "C", this.fields.ref_label),
|
|
367
|
+
new TLV(
|
|
368
|
+
6,
|
|
369
|
+
"Customer Label",
|
|
370
|
+
25,
|
|
371
|
+
false,
|
|
372
|
+
"C",
|
|
373
|
+
this.fields.customer_label
|
|
374
|
+
),
|
|
375
|
+
new TLV(
|
|
376
|
+
7,
|
|
377
|
+
"Terminal Label",
|
|
378
|
+
25,
|
|
379
|
+
false,
|
|
380
|
+
"O",
|
|
381
|
+
this.fields.terminal_label
|
|
382
|
+
),
|
|
383
|
+
new TLV(
|
|
384
|
+
8,
|
|
385
|
+
"Purpose of Transaction",
|
|
386
|
+
25,
|
|
387
|
+
false,
|
|
388
|
+
"C",
|
|
389
|
+
CRC.nonAccentVietnamese(this.fields.purpose_txn)
|
|
390
|
+
),
|
|
391
|
+
new TLV(
|
|
392
|
+
9,
|
|
393
|
+
"Additional Consumer Data Request",
|
|
394
|
+
3,
|
|
395
|
+
false,
|
|
396
|
+
"O",
|
|
397
|
+
this.fields.additional_data
|
|
398
|
+
),
|
|
399
|
+
]
|
|
400
|
+
);
|
|
401
|
+
this.data[63] = new TLV(63, "CRC (Cyclic Redundancy Check)", 4, true, "M");
|
|
402
|
+
this.data[64] = new TLV(
|
|
403
|
+
64,
|
|
404
|
+
"Merchant Information - Language Template",
|
|
405
|
+
2,
|
|
406
|
+
true,
|
|
407
|
+
"O",
|
|
408
|
+
[
|
|
409
|
+
new TLV(0, "Language Preference", 2, true, "M", this.fields.lang_ref),
|
|
410
|
+
new TLV(
|
|
411
|
+
1,
|
|
412
|
+
"Merchant Name - Alternate Language",
|
|
413
|
+
25,
|
|
414
|
+
false,
|
|
415
|
+
"M",
|
|
416
|
+
this.fields.local_merchant_name
|
|
417
|
+
),
|
|
418
|
+
new TLV(
|
|
419
|
+
2,
|
|
420
|
+
"Merchant City - Alternate Language",
|
|
421
|
+
15,
|
|
422
|
+
false,
|
|
423
|
+
"O",
|
|
424
|
+
this.fields.local_merchant_city
|
|
425
|
+
),
|
|
426
|
+
]
|
|
427
|
+
);
|
|
428
|
+
this.data[80] = new TLV(80, "UniCube data", 99, false, "0", [
|
|
429
|
+
new TLV(0, "uuid", 16, false, "O", this.fields.uuid),
|
|
430
|
+
new TLV(1, "custom data", 83, false, "O", this.fields.custom_data),
|
|
431
|
+
]);
|
|
432
|
+
return this.toString();
|
|
433
|
+
}
|
|
434
|
+
};
|
|
435
|
+
|
|
436
|
+
export { CURRENCY, SERVICE_CODE, VIETQR };
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import ModalZoom from "@components/common/modal/modal-zoom"
|
|
2
|
+
import { useNavigate } from "react-router-dom"
|
|
3
|
+
|
|
4
|
+
type TProps = {
|
|
5
|
+
isOpen: boolean
|
|
6
|
+
onClose: () => void
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const SessionCloseModal = ({ isOpen, onClose }: TProps) => {
|
|
10
|
+
const navigate = useNavigate()
|
|
11
|
+
|
|
12
|
+
const onBack = () => {
|
|
13
|
+
navigate(`/console${sessionStorage.getItem("enter_pincode")}`)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<ModalZoom isOpen={isOpen} onClose={onClose}>
|
|
18
|
+
<div className="flex flex-col gap-2 items-center justify-center">
|
|
19
|
+
<p className="text-[32px] font-semibold text-text-primary">
|
|
20
|
+
Opps! Đóng cửa rồi
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<p className="leading-6 text-text-secondary tracking-[-0.24px]">
|
|
24
|
+
Cửa hàng chúng tôi đang đóng cửa, bạn hãy quay lại sau nhé
|
|
25
|
+
</p>
|
|
26
|
+
|
|
27
|
+
<button onClick={onBack} className="rounded-lg button-primary mt-4">
|
|
28
|
+
Trở về
|
|
29
|
+
</button>
|
|
30
|
+
</div>
|
|
31
|
+
</ModalZoom>
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default SessionCloseModal
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import ButtonAction from "@components/common/button-action";
|
|
2
|
+
import { QUERY_KEYS } from "@constants/query.constant";
|
|
3
|
+
import { useQueryParams } from "@hooks/common/use-query-params";
|
|
4
|
+
import { usePayment } from "@provider/pos-provider/payment-provider";
|
|
5
|
+
import Lottie from "lottie-react";
|
|
6
|
+
import animationData from "../../../../../public/assets/lottie/soft_pos.json";
|
|
7
|
+
import { PaymentInfo } from "../payment-info";
|
|
8
|
+
import { PaymentLayout } from "../payment-layout";
|
|
9
|
+
|
|
10
|
+
export const SoftPosPayment = ({ total }: { total: number }) => {
|
|
11
|
+
return (
|
|
12
|
+
<PaymentLayout
|
|
13
|
+
leftContent={<LeftContent />}
|
|
14
|
+
rightContent={<RightContent total={total} />}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const LeftContent = () => {
|
|
20
|
+
return (
|
|
21
|
+
<div className="flex flex-col gap-3 items-center">
|
|
22
|
+
<div style={{ width: 280 }}>
|
|
23
|
+
<Lottie animationData={animationData} />
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const RightContent = ({ total }: { total: number }) => {
|
|
30
|
+
const { onPaymentSoftPos } = usePayment();
|
|
31
|
+
const { updateQuery } = useQueryParams();
|
|
32
|
+
const handlePayment = () => {
|
|
33
|
+
updateQuery(QUERY_KEYS.SHOW_SCREEN, "true");
|
|
34
|
+
onPaymentSoftPos(total);
|
|
35
|
+
};
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<div className="flex flex-col gap-3 h-full justify-center ">
|
|
39
|
+
<PaymentInfo />
|
|
40
|
+
<ButtonAction
|
|
41
|
+
onClick={() => handlePayment()}
|
|
42
|
+
text="Thanh toán SoftPos"
|
|
43
|
+
className="button-primary h-[56px]"
|
|
44
|
+
/>
|
|
45
|
+
</div>
|
|
46
|
+
</>
|
|
47
|
+
);
|
|
48
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import ButtonAction from "@components/common/button-action";
|
|
2
|
+
import ModalZoom from "@components/common/modal/modal-zoom";
|
|
3
|
+
import { t } from "i18next";
|
|
4
|
+
import { useNavigate } from "react-router-dom";
|
|
5
|
+
|
|
6
|
+
export const BackConfirm = ({
|
|
7
|
+
isOpen,
|
|
8
|
+
onClose,
|
|
9
|
+
}: {
|
|
10
|
+
isOpen: boolean;
|
|
11
|
+
onClose: () => void;
|
|
12
|
+
}) => {
|
|
13
|
+
const navigate = useNavigate();
|
|
14
|
+
const onBack = () => {
|
|
15
|
+
navigate(`/console${sessionStorage.getItem("enter_pincode")}`);
|
|
16
|
+
};
|
|
17
|
+
return (
|
|
18
|
+
<ModalZoom
|
|
19
|
+
isOpen={isOpen}
|
|
20
|
+
onClose={onClose}
|
|
21
|
+
className="p-0 py-4 px-5"
|
|
22
|
+
modalClassName="w-[40%]"
|
|
23
|
+
title="Xác nhận thoát điểm bán" //multi language
|
|
24
|
+
footer={
|
|
25
|
+
<div className="flex gap-2 justify-end p-4">
|
|
26
|
+
<ButtonAction
|
|
27
|
+
onClick={() => onClose()}
|
|
28
|
+
text={t("cancel_button")}
|
|
29
|
+
className="button-secondary w-full"
|
|
30
|
+
/>
|
|
31
|
+
<ButtonAction
|
|
32
|
+
onClick={() => onBack()}
|
|
33
|
+
text={t("confirm_button")}
|
|
34
|
+
className="button-primary w-full"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
}
|
|
38
|
+
>
|
|
39
|
+
<p>
|
|
40
|
+
Bạn có đang thoát khỏi điểm bán này. Bạn có muốn thoát điểm bán này
|
|
41
|
+
không?
|
|
42
|
+
</p>
|
|
43
|
+
</ModalZoom>
|
|
44
|
+
);
|
|
45
|
+
};
|