sme-pos-package 1.0.14 → 1.0.15
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 +1 -1
- package/dist/index.mjs +1 -0
- package/package.json +4 -1
- package/dist/index.css.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/tailwind.preset.mjs.map +0 -1
- 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 +0 -9
- 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 +0 -1
- package/public/assets/lottie/soft_pos.json +0 -1
- package/public/assets/lottie/success.json +0 -1
- package/public/config.json +0 -27
- package/public/env.json +0 -17
- package/src/animations/success.json +0 -9730
- package/src/assets/icons/breadcrumbs-icon.tsx +0 -85
- package/src/assets/icons/cart-icon.tsx +0 -14
- package/src/assets/icons/common.tsx +0 -270
- package/src/assets/icons/customer-view-icon.tsx +0 -20
- package/src/assets/icons/dining-table.tsx +0 -34
- package/src/assets/icons/edit-line-icon.tsx +0 -18
- package/src/assets/icons/emenu-icon.tsx +0 -39
- package/src/assets/icons/file-close-line-icon.tsx +0 -18
- package/src/assets/icons/helper-icon.tsx +0 -84
- package/src/assets/icons/home-gear-line-icon.tsx +0 -18
- package/src/assets/icons/kanban-icon.tsx +0 -16
- package/src/assets/icons/loading-icon.tsx +0 -45
- package/src/assets/icons/logout-box-line-icon.tsx +0 -18
- package/src/assets/icons/order-icon.tsx +0 -92
- package/src/assets/icons/payment-icon.tsx +0 -429
- package/src/assets/icons/pincode.tsx +0 -196
- package/src/assets/icons/pos-connect-icon.tsx +0 -67
- package/src/assets/icons/pos-device-icon.tsx +0 -52
- package/src/assets/icons/pos-icon.tsx +0 -75
- package/src/assets/icons/printer-line-icon.tsx +0 -18
- package/src/assets/icons/star-icon.tsx +0 -174
- package/src/assets/icons/table-icon.tsx +0 -77
- package/src/assets/icons/user-add-line-icon.tsx +0 -33
- package/src/assets/icons/user-icon.tsx +0 -65
- package/src/components/common/button-action.tsx +0 -46
- package/src/components/common/button-icon.tsx +0 -23
- package/src/components/common/dropdown/index.tsx +0 -79
- package/src/components/common/empty-state.tsx +0 -60
- package/src/components/common/header/index.tsx +0 -89
- package/src/components/common/header/tabs.tsx +0 -119
- package/src/components/common/image.tsx +0 -20
- package/src/components/common/input/index.tsx +0 -55
- package/src/components/common/input/radio-group.tsx +0 -75
- package/src/components/common/input/text-area.tsx +0 -28
- package/src/components/common/modal/delete-confirm-modal-container.tsx +0 -65
- package/src/components/common/modal/index.ts +0 -2
- package/src/components/common/modal/modal-direction.tsx +0 -125
- package/src/components/common/modal/modal-header.tsx +0 -37
- package/src/components/common/modal/modal-wrapper.tsx +0 -56
- package/src/components/common/modal/modal-zoom.tsx +0 -61
- package/src/components/common/pagination.tsx +0 -95
- package/src/components/common/refresh-button.tsx +0 -28
- package/src/components/common/search-bar.tsx +0 -27
- package/src/components/common/search.tsx +0 -59
- package/src/components/common/skeleton.tsx +0 -7
- package/src/components/common/tabs-layout.tsx +0 -98
- package/src/components/common/use-check-session.tsx +0 -19
- package/src/components/customer-management/add-customer/add-customer-drawer.tsx +0 -286
- package/src/components/customer-management/add-customer/address-select.tsx +0 -51
- package/src/components/customer-management/choose-customer-drawer.tsx +0 -177
- package/src/components/customer-management/customer-info-drawer.tsx +0 -166
- package/src/components/customer-management/customer-no-data.tsx +0 -18
- package/src/components/emenu/emenu-qr-code.tsx +0 -59
- package/src/components/emenu/menu-link.tsx +0 -67
- package/src/components/index.ts +0 -8
- package/src/components/kanban-template/kitchen-template.tsx +0 -60
- package/src/components/kanban-template/pos-order-template.tsx +0 -77
- package/src/components/kanban-template/pos-template.tsx +0 -170
- package/src/components/kitchen-management/change-status-confirm-modal.tsx +0 -61
- package/src/components/kitchen-management/index.ts +0 -1
- package/src/components/kitchen-management/kitchen-order/index.tsx +0 -153
- package/src/components/kitchen-management/kitchen-order/line.tsx +0 -78
- package/src/components/kitchen-management/kitchen-order/state.tsx +0 -52
- package/src/components/kitchen-management/kitchen-status.tsx +0 -69
- package/src/components/kitchen-management/orders-kitchen-management.tsx +0 -113
- package/src/components/order-management/index.tsx +0 -128
- package/src/components/order-management/order-actions.tsx +0 -46
- package/src/components/order-management/order-detail/header.tsx +0 -37
- package/src/components/order-management/order-detail/index.ts +0 -3
- package/src/components/order-management/order-detail/information.tsx +0 -96
- package/src/components/order-management/order-detail/order-detail.tsx +0 -84
- package/src/components/order-management/order-detail/order-line.tsx +0 -56
- package/src/components/order-management/order-detail/summary.tsx +0 -221
- package/src/components/order-management/order-header.tsx +0 -113
- package/src/components/order-management/order-pagination.tsx +0 -49
- package/src/components/order-management/order-status.tsx +0 -58
- package/src/components/order-management/order-table.tsx +0 -179
- package/src/components/order-management/order-tabs.tsx +0 -48
- package/src/components/pos-management/add-product-from-barcode/index.tsx +0 -97
- package/src/components/pos-management/cart-content/action-line.tsx +0 -81
- package/src/components/pos-management/cart-content/cancel-order-line-modal.tsx +0 -41
- package/src/components/pos-management/cart-content/cart-item.tsx +0 -173
- package/src/components/pos-management/cart-content/cart-items.tsx +0 -130
- package/src/components/pos-management/cart-content/draft-orders/draft-order-line.tsx +0 -67
- package/src/components/pos-management/cart-content/draft-orders/index.tsx +0 -40
- package/src/components/pos-management/cart-content/edit-cart-modal.tsx +0 -11
- package/src/components/pos-management/cart-content/index.tsx +0 -260
- package/src/components/pos-management/cart-content/no-select-order.tsx +0 -26
- package/src/components/pos-management/cart-content/order-info/customer-info.tsx +0 -53
- package/src/components/pos-management/cart-content/order-info/index.tsx +0 -109
- package/src/components/pos-management/cart-content/order-total.tsx +0 -36
- package/src/components/pos-management/cart-content/orders-line.tsx +0 -72
- package/src/components/pos-management/menu-content/category-tab.tsx +0 -38
- package/src/components/pos-management/menu-content/create-order-modal.tsx +0 -65
- package/src/components/pos-management/menu-content/product-content.tsx +0 -93
- package/src/components/pos-management/menu-content/product-detail/info.tsx +0 -28
- package/src/components/pos-management/menu-content/product-detail/modal.tsx +0 -148
- package/src/components/pos-management/menu-content/product-detail/option.tsx +0 -87
- package/src/components/pos-management/menu-content/product-detail/quantity-control.tsx +0 -155
- package/src/components/pos-management/menu-content/product-detail/sale-keypad.tsx +0 -100
- package/src/components/pos-management/menu-content/product-item.tsx +0 -65
- package/src/components/pos-management/order-helper/cancel-order-confirm.tsx +0 -43
- package/src/components/pos-management/order-helper/history-call.tsx +0 -105
- package/src/components/pos-management/order-helper/order-helper-modal.tsx +0 -116
- package/src/components/pos-management/payment-content/bill/actions.tsx +0 -46
- package/src/components/pos-management/payment-content/bill/content.tsx +0 -207
- package/src/components/pos-management/payment-content/bill/index.tsx +0 -18
- package/src/components/pos-management/payment-content/card-payment/index.tsx +0 -124
- package/src/components/pos-management/payment-content/card-payment/pos-payment/pos-connect.tsx +0 -183
- package/src/components/pos-management/payment-content/card-payment/pos-payment/qr-connect.tsx +0 -185
- package/src/components/pos-management/payment-content/card-payment/waiting-for-payment-pos-modal.tsx +0 -37
- package/src/components/pos-management/payment-content/cash-payment/index.tsx +0 -216
- package/src/components/pos-management/payment-content/index.tsx +0 -70
- package/src/components/pos-management/payment-content/payment-info.tsx +0 -67
- package/src/components/pos-management/payment-content/payment-layout.tsx +0 -16
- package/src/components/pos-management/payment-content/payment-method-cards.tsx +0 -99
- package/src/components/pos-management/payment-content/qr-payment/index.tsx +0 -118
- package/src/components/pos-management/payment-content/qr-payment/qr_code.js +0 -29
- package/src/components/pos-management/payment-content/qr-payment/vietqr.js +0 -436
- package/src/components/pos-management/payment-content/session-close-modal.tsx +0 -35
- package/src/components/pos-management/payment-content/soft-pos-payment/index.tsx +0 -48
- package/src/components/pos-management/pos-helpers/back-confirm.tsx +0 -45
- package/src/components/pos-management/pos-helpers/index.tsx +0 -135
- package/src/components/pos-management/pos-helpers/layout-display-modal.tsx +0 -99
- package/src/components/pos-management/search.tsx +0 -48
- package/src/components/pos-management/table-content/filtered-tables.tsx +0 -59
- package/src/components/pos-management/table-content/floor-tabs.tsx +0 -65
- package/src/components/pos-management/table-content/index.tsx +0 -76
- package/src/components/pos-management/table-content/table-item.tsx +0 -127
- package/src/components/pos-management/table-content/tables.tsx +0 -96
- package/src/components/restaurant-management/add-floor-modal.tsx +0 -133
- package/src/components/restaurant-management/add-table-modal.tsx +0 -198
- package/src/components/restaurant-management/delete-floor-confirm-modal.tsx +0 -42
- package/src/components/restaurant-management/delete-table-confirm-modal.tsx +0 -51
- package/src/components/restaurant-management/header.tsx +0 -22
- package/src/components/restaurant-management/index.tsx +0 -54
- package/src/components/restaurant-management/left-side.tsx +0 -51
- package/src/components/restaurant-management/right-side.tsx +0 -179
- package/src/components/restaurant-management/table-empty.tsx +0 -43
- package/src/components/session-management/close-session-modal/actions.tsx +0 -45
- package/src/components/session-management/close-session-modal/close-session-confirm.tsx +0 -157
- package/src/components/session-management/close-session-modal/close-session-ticket.tsx +0 -218
- package/src/components/session-management/close-session-modal/container.tsx +0 -25
- package/src/components/session-management/close-session-modal/draft-orders-confirm.tsx +0 -53
- package/src/components/session-management/close-session-modal/draft-orders-summary.tsx +0 -82
- package/src/components/session-management/close-session-modal/draft-orders.tsx +0 -34
- package/src/components/session-management/close-session-modal/index.tsx +0 -35
- package/src/components/session-management/close-session-modal/order/index.ts +0 -1
- package/src/components/session-management/close-session-modal/order/order-line.tsx +0 -64
- package/src/components/session-management/close-session-modal/order/orders-in-draft.tsx +0 -31
- package/src/components/session-management/close-session-modal/session-summary.tsx +0 -165
- package/src/components/session-management/index.ts +0 -1
- package/src/components/session-management/open-shift/index.tsx +0 -172
- package/src/components/table-management/index.tsx +0 -0
- package/src/constants/api/index.ts +0 -1
- package/src/constants/headers.constant.tsx +0 -24
- package/src/constants/index.ts +0 -1
- package/src/constants/language.store.ts +0 -21
- package/src/constants/methods.constant.ts +0 -10
- package/src/constants/order-state.ts +0 -8
- package/src/constants/payment-color.constant.ts +0 -26
- package/src/constants/query.constant.ts +0 -14
- package/src/constants/routes.constants.ts +0 -23
- package/src/constants/template-name.constant.ts +0 -9
- package/src/hooks/bill/use-get-bill-information.ts +0 -49
- package/src/hooks/bill/use-print-bill.tsx +0 -0
- package/src/hooks/common/load-env-config.ts +0 -98
- package/src/hooks/common/use-back.ts +0 -13
- package/src/hooks/common/use-broadcast.ts +0 -22
- package/src/hooks/common/use-click-outside.ts +0 -58
- package/src/hooks/common/use-get-base64-photo.ts +0 -71
- package/src/hooks/common/use-get-query.ts +0 -25
- package/src/hooks/common/use-pos.ts +0 -21
- package/src/hooks/common/use-query-params.ts +0 -89
- package/src/hooks/common/use-speech.ts +0 -36
- package/src/hooks/customer/use-customer-provider.ts +0 -247
- package/src/hooks/floor/use-floor-provider.ts +0 -172
- package/src/hooks/kitchen/use-kitchen-provider.ts +0 -80
- package/src/hooks/order/use-get-point-reward.ts +0 -50
- package/src/hooks/order/use-loop-fetch-order.ts +0 -30
- package/src/hooks/order/use-order-items.ts +0 -61
- package/src/hooks/order/use-orders.ts +0 -76
- package/src/hooks/payment/use-payment-provider.ts +0 -221
- package/src/hooks/product/use-product-provider.ts +0 -87
- package/src/hooks/session/use-check-session.tsx +0 -19
- package/src/hooks/session/use-session-provider.ts +0 -79
- package/src/hooks/table/use-pos-table-provider.ts +0 -193
- package/src/index.css +0 -5
- package/src/index.ts +0 -13
- package/src/layouts/common.tsx +0 -15
- package/src/layouts/index.ts +0 -4
- package/src/layouts/pos-layout.tsx +0 -33
- package/src/layouts/pos-order-layout.tsx +0 -43
- package/src/layouts/sale-layout.tsx +0 -25
- package/src/locales/en.json +0 -394
- package/src/locales/vi.json +0 -400
- package/src/pages/index.ts +0 -4
- package/src/pages/login/index.tsx +0 -128
- package/src/pages/pincode/index.tsx +0 -198
- package/src/pages/pos/kitchen-management/layout.tsx +0 -18
- package/src/pages/pos/management-floor/index.tsx +0 -7
- package/src/pages/pos/management-order/index.tsx +0 -7
- package/src/pages/pos/management-order/order-detail/index.tsx +0 -7
- package/src/pages/pos/management-table/index.tsx +0 -0
- package/src/pages/pos/payment-success/index.tsx +0 -75
- package/src/provider/app-provider.tsx +0 -56
- package/src/provider/fallback/custom-error.tsx +0 -26
- package/src/provider/main-provider.tsx +0 -41
- package/src/provider/meta-provider.tsx +0 -72
- package/src/provider/modal-provider.tsx +0 -48
- package/src/provider/notification-provider.tsx +0 -64
- package/src/provider/pos-provider/close-session-provider/index.tsx +0 -207
- package/src/provider/pos-provider/customer-provider/index.tsx +0 -30
- package/src/provider/pos-provider/floor-provider/index.tsx +0 -39
- package/src/provider/pos-provider/index.ts +0 -6
- package/src/provider/pos-provider/kitchen-provider/index.tsx +0 -30
- package/src/provider/pos-provider/order-detail-provider/index.tsx +0 -233
- package/src/provider/pos-provider/order-provider/index.tsx +0 -803
- package/src/provider/pos-provider/payment-provider/index.tsx +0 -30
- package/src/provider/pos-provider/product-provider/index.tsx +0 -30
- package/src/provider/pos-provider/sale-provider/index.tsx +0 -168
- package/src/provider/pos-provider/session-provider/index.tsx +0 -30
- package/src/provider/pos-provider/socket-provider/index.tsx +0 -118
- package/src/provider/pos-provider/table-provider/index.tsx +0 -30
- package/src/provider/public-provider.tsx +0 -104
- package/src/provider/use-session-provider.ts +0 -79
- package/src/router/app-router.tsx +0 -38
- package/src/router/index.tsx +0 -26
- package/src/router/pos-route.tsx +0 -75
- package/src/router/protected-route.tsx +0 -16
- package/src/router/public-route.tsx +0 -11
- package/src/store/header/index.ts +0 -21
- package/src/store/session/index.ts +0 -25
- package/src/store/states/cart.state.ts +0 -135
- package/src/store/states/close-session.state.ts +0 -20
- package/src/store/states/customer.state.ts +0 -19
- package/src/store/states/payment.state.ts +0 -14
- package/src/styles/base.css +0 -212
- package/src/styles/common.css +0 -65
- package/src/styles/lib/tailwind.css +0 -0
- package/src/styles/lib/tailwind.theme.css +0 -34
- package/src/styles/loading.css +0 -72
- package/src/styles/main.css +0 -5
- package/src/styles/refreshing-content.css +0 -55
- package/src/styles/text.css +0 -44
- package/src/types/account.ts +0 -61
- package/src/types/branch.ts +0 -6
- package/src/types/category.ts +0 -13
- package/src/types/common.ts +0 -4
- package/src/types/customer.ts +0 -52
- package/src/types/dashboard.ts +0 -18
- package/src/types/edc.ts +0 -37
- package/src/types/export-e-invoice.ts +0 -17
- package/src/types/filter.d.ts +0 -12
- package/src/types/floor/floor.ts +0 -16
- package/src/types/floor.d.ts +0 -36
- package/src/types/index.ts +0 -127
- package/src/types/invoice.ts +0 -32
- package/src/types/modal.ts +0 -15
- package/src/types/notification.ts +0 -12
- package/src/types/order.ts +0 -182
- package/src/types/payment.ts +0 -44
- package/src/types/product/product.ts +0 -47
- package/src/types/product.ts +0 -137
- package/src/types/provider-info.d.ts +0 -14
- package/src/types/qr.d.ts +0 -25
- package/src/types/report.d.ts +0 -43
- package/src/types/sale.d.ts +0 -68
- package/src/types/search.d.ts +0 -7
- package/src/types/session.d.ts +0 -30
- package/src/types/shop-qr.d.ts +0 -89
- package/src/types/staff.d.ts +0 -35
- package/src/types/store.d.ts +0 -25
- package/src/types/table.d.ts +0 -57
- package/src/utils/close-session-ticket.tsx +0 -129
- package/src/utils/functions.ts +0 -299
- package/src/utils/i18n.ts +0 -25
- package/src/utils/pos/bill.ts +0 -156
- package/src/utils/pos/convert-order.ts +0 -58
- package/src/utils/pos/helpers.ts +0 -48
- package/src/utils/pos/session.ts +0 -44
- package/src/utils/storages/index.ts +0 -1
- package/src/utils/storages/local-storage.ts +0 -72
- package/tailwind.preset.ts +0 -25
- package/tsconfig.json +0 -30
- package/tsup.config.ts +0 -30
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { QUERY_KEYS } from "@constants/query.constant";
|
|
2
|
-
import { useQueryParams } from "@hooks/common/use-query-params";
|
|
3
|
-
import { useKitchen } from "@provider/pos-provider/kitchen-provider";
|
|
4
|
-
import { useProduct } from "@provider/pos-provider/product-provider";
|
|
5
|
-
import { TKitchenOrder } from "@type/order";
|
|
6
|
-
import { TAttributeLine, TProduct } from "@type/product/product";
|
|
7
|
-
import { useMemo, useState } from "react";
|
|
8
|
-
|
|
9
|
-
const useOrders = () => {
|
|
10
|
-
const { getQuery } = useQueryParams();
|
|
11
|
-
const { displayDataQueryResult } = useKitchen();
|
|
12
|
-
const { data: products } = useProduct();
|
|
13
|
-
|
|
14
|
-
const displayData = useMemo(
|
|
15
|
-
() => displayDataQueryResult?.data,
|
|
16
|
-
[displayDataQueryResult]
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
const kitchenOrders = useMemo(() => displayData?.orders ?? [], [displayData]);
|
|
20
|
-
|
|
21
|
-
const statusId = Number(getQuery(QUERY_KEYS.KITCHEN_ORDER_STATUS));
|
|
22
|
-
|
|
23
|
-
const [searchValue, setSearchValue] = useState("");
|
|
24
|
-
|
|
25
|
-
const onSearchChange = (value: string) => {
|
|
26
|
-
setSearchValue(value);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const kitchenOrdersFiltered = useMemo(() => {
|
|
30
|
-
const productMap = new Map<number, TProduct>(
|
|
31
|
-
products?.map((item: TProduct) => [item.id, item])
|
|
32
|
-
);
|
|
33
|
-
return kitchenOrders
|
|
34
|
-
.filter((order: TKitchenOrder) => {
|
|
35
|
-
return order.stage_id === statusId;
|
|
36
|
-
})
|
|
37
|
-
.filter((order: TKitchenOrder) => {
|
|
38
|
-
return (
|
|
39
|
-
order.pos_order_id.toString().includes(searchValue) ||
|
|
40
|
-
order.orderlines.some((orderLine: any) => {
|
|
41
|
-
return (orderLine.product_name as string)
|
|
42
|
-
.toLowerCase()
|
|
43
|
-
.includes(searchValue.toLowerCase());
|
|
44
|
-
})
|
|
45
|
-
);
|
|
46
|
-
})
|
|
47
|
-
.map((order: TKitchenOrder) => {
|
|
48
|
-
return {
|
|
49
|
-
...order,
|
|
50
|
-
orderlines: order.orderlines.map((orderLine: any) => {
|
|
51
|
-
const saleItem = productMap.get(orderLine.product_id);
|
|
52
|
-
return {
|
|
53
|
-
...orderLine,
|
|
54
|
-
pickAttributeValue: saleItem?.attributeLines?.map(
|
|
55
|
-
(attributeLine: TAttributeLine) => {
|
|
56
|
-
return {
|
|
57
|
-
...attributeLine,
|
|
58
|
-
value_string: attributeLine.value_string.filter(
|
|
59
|
-
(val: any) => orderLine.attribute_ids.includes(val.id)
|
|
60
|
-
),
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
),
|
|
64
|
-
};
|
|
65
|
-
}),
|
|
66
|
-
};
|
|
67
|
-
});
|
|
68
|
-
}, [kitchenOrders, products, searchValue, statusId]);
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
kitchenOrdersFiltered,
|
|
72
|
-
onSearchChange,
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export default useOrders;
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
import { PublishType } from "@components/pos-management/payment-content/card-payment/pos-payment/qr-connect";
|
|
2
|
-
import { ORDER_STATE } from "@constants/order-state";
|
|
3
|
-
import { QUERY_KEYS } from "@constants/query.constant";
|
|
4
|
-
import { useService } from "@fctc/widget-logic/provider";
|
|
5
|
-
import { sessionStorageUtils } from "@fctc/widget-logic/utils";
|
|
6
|
-
import { useQueryParams } from "@hooks/common/use-query-params";
|
|
7
|
-
import { usePosAppProvider } from "@provider/app-provider";
|
|
8
|
-
import { useOrderDetail } from "@provider/pos-provider/order-detail-provider";
|
|
9
|
-
import { useOrder } from "@provider/pos-provider/order-provider";
|
|
10
|
-
import { LoadDataModel } from "@provider/pos-provider/sale-provider";
|
|
11
|
-
import { useSocketData } from "@provider/pos-provider/socket-provider";
|
|
12
|
-
import { useMutation } from "@tanstack/react-query";
|
|
13
|
-
import {
|
|
14
|
-
TCheckPaymentPayload,
|
|
15
|
-
TMakePaymentPayload,
|
|
16
|
-
TPaymentInfo,
|
|
17
|
-
} from "@type/payment";
|
|
18
|
-
import { useTranslation } from "react-i18next";
|
|
19
|
-
import { toast } from "react-toastify";
|
|
20
|
-
|
|
21
|
-
const usePaymentProvider = () => {
|
|
22
|
-
const {
|
|
23
|
-
useAddEntity,
|
|
24
|
-
useCheckPayment,
|
|
25
|
-
useGeneratePaymentQrInfo,
|
|
26
|
-
useUpdateOrderStatus,
|
|
27
|
-
} = useService();
|
|
28
|
-
const createEntityMutation = useAddEntity().mutateAsync;
|
|
29
|
-
const checkPaymentMutation = useCheckPayment().mutateAsync;
|
|
30
|
-
const generatePaymentQrInfoMutation = useGeneratePaymentQrInfo().mutateAsync;
|
|
31
|
-
const useUpdateOrderStatusMutation = useUpdateOrderStatus().mutateAsync;
|
|
32
|
-
const { user } = usePosAppProvider();
|
|
33
|
-
const { t } = useTranslation();
|
|
34
|
-
const { getQuery } = useQueryParams();
|
|
35
|
-
|
|
36
|
-
const { updateOrder, orders, setOrders } = useOrder();
|
|
37
|
-
const { onPaymentSuccess } = useOrderDetail();
|
|
38
|
-
const xNode = user?.userProfile?.data?.x_node;
|
|
39
|
-
const service = sessionStorageUtils.getMenuFocus().service || `wesap`;
|
|
40
|
-
const menuItemId = Number(getQuery(QUERY_KEYS.POS_ID));
|
|
41
|
-
const orderIdParam = getQuery(QUERY_KEYS.ORDER_ID);
|
|
42
|
-
const sessionIdParam = getQuery(QUERY_KEYS.SESSION_ID);
|
|
43
|
-
|
|
44
|
-
const { clientMtqq, onPublish } = useSocketData();
|
|
45
|
-
const posId = getQuery(QUERY_KEYS.POS_ID);
|
|
46
|
-
const mqttConnect = localStorage.getItem(`mttqQrConnect${posId}`) ?? "";
|
|
47
|
-
const makePayment = useMutation<[number], Error, TMakePaymentPayload>({
|
|
48
|
-
mutationFn: (payload: TMakePaymentPayload) =>
|
|
49
|
-
createEntityMutation({
|
|
50
|
-
model: LoadDataModel.POS_MAKE_PAYMENT,
|
|
51
|
-
values: {
|
|
52
|
-
config_id: menuItemId,
|
|
53
|
-
payment_method_id: payload.paymentMethodId,
|
|
54
|
-
amount: payload.amount,
|
|
55
|
-
payment_name: payload.paymentName,
|
|
56
|
-
},
|
|
57
|
-
isCreateEndpoint: true,
|
|
58
|
-
service: service ?? "",
|
|
59
|
-
xNode: xNode ?? "",
|
|
60
|
-
}) as Promise<[number]>,
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
const checkPayment = useMutation({
|
|
64
|
-
mutationFn: (payload: TCheckPaymentPayload) =>
|
|
65
|
-
checkPaymentMutation({
|
|
66
|
-
model: LoadDataModel.POS_MAKE_PAYMENT,
|
|
67
|
-
ids: [payload.id],
|
|
68
|
-
withContext: {
|
|
69
|
-
active_model: "pos.order",
|
|
70
|
-
active_id: payload.orderId,
|
|
71
|
-
},
|
|
72
|
-
service: service ?? "",
|
|
73
|
-
xNode: xNode ?? "",
|
|
74
|
-
}),
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const payment = async (
|
|
78
|
-
payload: TMakePaymentPayload & { orderId: number }
|
|
79
|
-
) => {
|
|
80
|
-
const makePaymentRes: [number] = await makePayment.mutateAsync({
|
|
81
|
-
paymentMethodId: payload.paymentMethodId,
|
|
82
|
-
amount: payload.amount,
|
|
83
|
-
paymentName: payload.paymentName,
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const checkPaymentRes: any = await checkPayment.mutateAsync({
|
|
87
|
-
id: makePaymentRes[0],
|
|
88
|
-
orderId: payload.orderId,
|
|
89
|
-
});
|
|
90
|
-
|
|
91
|
-
return {
|
|
92
|
-
success: checkPaymentRes?.type === "ir.actions.act_window_close",
|
|
93
|
-
paymentId: makePaymentRes[0],
|
|
94
|
-
};
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
const handlePayment = async (
|
|
98
|
-
payload: TMakePaymentPayload & {
|
|
99
|
-
orderId: number;
|
|
100
|
-
receivedAmount: number;
|
|
101
|
-
}
|
|
102
|
-
) => {
|
|
103
|
-
try {
|
|
104
|
-
const { orderId, receivedAmount, amount, paymentMethodId, paymentName } =
|
|
105
|
-
payload;
|
|
106
|
-
|
|
107
|
-
const paymentResult = await payment({
|
|
108
|
-
amount: receivedAmount,
|
|
109
|
-
orderId: Number(orderId),
|
|
110
|
-
paymentMethodId: paymentMethodId,
|
|
111
|
-
paymentName: paymentName,
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
if (paymentResult.success) {
|
|
115
|
-
onPaymentSuccess(amount);
|
|
116
|
-
} else {
|
|
117
|
-
const res = await updateOrder.mutateAsync({
|
|
118
|
-
orderId: Number(orderId),
|
|
119
|
-
amount_return: receivedAmount - amount,
|
|
120
|
-
state: ORDER_STATE.IN_PAID,
|
|
121
|
-
});
|
|
122
|
-
if (res) {
|
|
123
|
-
onPaymentSuccess(amount);
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
} catch (error) {
|
|
127
|
-
console.error("Payment failed:", error);
|
|
128
|
-
toast.error(`${t("paymentFailedTitle")}12312`);
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
// ir.actions.act_window
|
|
132
|
-
const generatePaymentQrInfo = useMutation({
|
|
133
|
-
mutationFn: ({
|
|
134
|
-
amount,
|
|
135
|
-
sessionId,
|
|
136
|
-
orderId,
|
|
137
|
-
}: {
|
|
138
|
-
amount: number;
|
|
139
|
-
sessionId?: string;
|
|
140
|
-
orderId?: string;
|
|
141
|
-
}) =>
|
|
142
|
-
generatePaymentQrInfoMutation({
|
|
143
|
-
orderId: Number(orderId || orderIdParam),
|
|
144
|
-
amount,
|
|
145
|
-
posSessionId: Number(sessionId || sessionIdParam),
|
|
146
|
-
service: "wesap",
|
|
147
|
-
xNode: xNode ?? "",
|
|
148
|
-
}) as Promise<TPaymentInfo>,
|
|
149
|
-
});
|
|
150
|
-
|
|
151
|
-
const onUpdateOrderStatus = async (orderId: number) => {
|
|
152
|
-
const res = await useUpdateOrderStatusMutation({
|
|
153
|
-
orderId: orderId,
|
|
154
|
-
state: ORDER_STATE.IN_PAID,
|
|
155
|
-
xNode: dataUser?.x_node,
|
|
156
|
-
service: "wesap",
|
|
157
|
-
});
|
|
158
|
-
if (res) {
|
|
159
|
-
setOrders(
|
|
160
|
-
orders.map((order) => {
|
|
161
|
-
if (order.id === orderId) {
|
|
162
|
-
return {
|
|
163
|
-
...order,
|
|
164
|
-
state: ORDER_STATE.IN_PAID,
|
|
165
|
-
};
|
|
166
|
-
}
|
|
167
|
-
return order;
|
|
168
|
-
})
|
|
169
|
-
);
|
|
170
|
-
}
|
|
171
|
-
return res as Promise<{
|
|
172
|
-
name: string;
|
|
173
|
-
}>;
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
const onGeneratePaymentQrInfo = async (
|
|
177
|
-
amount: number,
|
|
178
|
-
sessionId?: string,
|
|
179
|
-
orderId?: string
|
|
180
|
-
) => {
|
|
181
|
-
await onUpdateOrderStatus(Number(orderId || orderIdParam));
|
|
182
|
-
const data = await generatePaymentQrInfo.mutateAsync({
|
|
183
|
-
amount,
|
|
184
|
-
sessionId,
|
|
185
|
-
orderId,
|
|
186
|
-
});
|
|
187
|
-
return data;
|
|
188
|
-
};
|
|
189
|
-
const dataUser = user?.userProfile?.data;
|
|
190
|
-
const onRequestPayment = async (amount: number) => {
|
|
191
|
-
await onUpdateOrderStatus(Number(orderIdParam));
|
|
192
|
-
const data = await onUpdateOrderStatus(Number(orderIdParam));
|
|
193
|
-
if (!clientMtqq) return;
|
|
194
|
-
onPublish(
|
|
195
|
-
mqttConnect,
|
|
196
|
-
JSON.stringify({
|
|
197
|
-
payload: {
|
|
198
|
-
orderId: data?.name,
|
|
199
|
-
amount: amount,
|
|
200
|
-
topic: mqttConnect,
|
|
201
|
-
},
|
|
202
|
-
type: PublishType.Payment,
|
|
203
|
-
})
|
|
204
|
-
);
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const onPaymentSoftPos = async (amount: number) => {
|
|
208
|
-
toast.error("Chức năng đang được phát triển");
|
|
209
|
-
};
|
|
210
|
-
|
|
211
|
-
return {
|
|
212
|
-
handlePayment,
|
|
213
|
-
onGeneratePaymentQrInfo,
|
|
214
|
-
onRequestPayment,
|
|
215
|
-
onPaymentSoftPos,
|
|
216
|
-
};
|
|
217
|
-
};
|
|
218
|
-
|
|
219
|
-
export default usePaymentProvider;
|
|
220
|
-
|
|
221
|
-
export type usePaymentProviderType = ReturnType<typeof usePaymentProvider>;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { LoadDataModel, useSale } from "@provider/pos-provider/sale-provider";
|
|
2
|
-
import { useCartStore } from "@store/states/cart.state";
|
|
3
|
-
import {
|
|
4
|
-
TAttributeLine,
|
|
5
|
-
TAttributeLineData,
|
|
6
|
-
TAttributeValueData,
|
|
7
|
-
TProduct,
|
|
8
|
-
TProductAttribute,
|
|
9
|
-
} from "@type/product/product";
|
|
10
|
-
import { getProductIdFromKey } from "@utils/functions";
|
|
11
|
-
import { useMemo } from "react";
|
|
12
|
-
|
|
13
|
-
const useProductProvider = () => {
|
|
14
|
-
const {
|
|
15
|
-
queryResult: { isLoading },
|
|
16
|
-
getData,
|
|
17
|
-
} = useSale();
|
|
18
|
-
|
|
19
|
-
const productsData = getData(LoadDataModel.PRODUCT_PRODUCT) as TProduct[];
|
|
20
|
-
const attributesValueData = getData(
|
|
21
|
-
LoadDataModel.PRODUCT_TEMPLATE_ATTRIBUTE_VALUE
|
|
22
|
-
) as TAttributeValueData[];
|
|
23
|
-
|
|
24
|
-
const attributesLinesData = getData(
|
|
25
|
-
LoadDataModel.PRODUCT_TEMPLATE_ATTRIBUTE_LINE
|
|
26
|
-
) as TAttributeLineData[];
|
|
27
|
-
|
|
28
|
-
const productAttributes = getData(
|
|
29
|
-
LoadDataModel.PRODUCT_ATTRIBUTE
|
|
30
|
-
) as TProductAttribute[];
|
|
31
|
-
|
|
32
|
-
const { activeProduct } = useCartStore();
|
|
33
|
-
|
|
34
|
-
const taxesData = getData(LoadDataModel.ACCOUNT_TAX);
|
|
35
|
-
|
|
36
|
-
const productWithImageAndTax: TProduct[] = useMemo(() => {
|
|
37
|
-
return (
|
|
38
|
-
productsData?.map((product) => {
|
|
39
|
-
const taxes = taxesData
|
|
40
|
-
?.filter((tax: any) => product?.taxes_id?.includes(tax?.id))
|
|
41
|
-
.map((tax: any) => tax?.amount || 0);
|
|
42
|
-
const temp: TAttributeLine[] =
|
|
43
|
-
product?.attribute_line_ids?.map((attributeLineId: number) => {
|
|
44
|
-
const attribute = attributesLinesData?.find(
|
|
45
|
-
(attributeLine: any) => attributeLine.id === attributeLineId
|
|
46
|
-
);
|
|
47
|
-
return {
|
|
48
|
-
id: attribute?.id ?? 0,
|
|
49
|
-
name: attribute?.display_name ?? "",
|
|
50
|
-
value_string: attributesValueData
|
|
51
|
-
?.filter(
|
|
52
|
-
(attributeValue: TAttributeValueData) =>
|
|
53
|
-
attributeValue.attribute_line_id === attributeLineId
|
|
54
|
-
)
|
|
55
|
-
?.map((attributeValue: TAttributeValueData) => {
|
|
56
|
-
return attributeValue;
|
|
57
|
-
}),
|
|
58
|
-
type:
|
|
59
|
-
productAttributes?.find((attribute: TProductAttribute) =>
|
|
60
|
-
attribute?.attributeValueIds?.includes(attributeLineId)
|
|
61
|
-
)?.display_type ?? "pills",
|
|
62
|
-
};
|
|
63
|
-
}) ?? [];
|
|
64
|
-
return {
|
|
65
|
-
...product,
|
|
66
|
-
|
|
67
|
-
tax: taxes?.reduce((acc: number, tax: number) => acc + tax, 0) || 0,
|
|
68
|
-
attributeLines: temp,
|
|
69
|
-
};
|
|
70
|
-
}) || []
|
|
71
|
-
);
|
|
72
|
-
}, [productsData, taxesData]);
|
|
73
|
-
const productData: TProduct | undefined = useMemo(() => {
|
|
74
|
-
if (!productsData || !activeProduct) return;
|
|
75
|
-
|
|
76
|
-
return productWithImageAndTax?.find(
|
|
77
|
-
(item: TProduct) =>
|
|
78
|
-
item.id.toString() === getProductIdFromKey(activeProduct.id)
|
|
79
|
-
);
|
|
80
|
-
}, [productWithImageAndTax, activeProduct]);
|
|
81
|
-
return { data: productWithImageAndTax, isLoading, productData };
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default useProductProvider;
|
|
85
|
-
|
|
86
|
-
export type useProductProviderType = ReturnType<typeof useProductProvider>;
|
|
87
|
-
export const defaultProductImage = "/product-default.png";
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { LoadDataModel, useSale } from "@provider/pos-provider/sale-provider";
|
|
2
|
-
|
|
3
|
-
const useCheckSession = () => {
|
|
4
|
-
const { getData } = useSale();
|
|
5
|
-
|
|
6
|
-
const onCheckSession = async () => {
|
|
7
|
-
const currentPos = getData(LoadDataModel.POS_CONFIG)?.[0];
|
|
8
|
-
|
|
9
|
-
const isSessionOpened = currentPos.pos_session_state === "opened";
|
|
10
|
-
|
|
11
|
-
return isSessionOpened;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
return {
|
|
15
|
-
onCheckSession,
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export default useCheckSession;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { useService } from "@fctc/widget-logic/provider";
|
|
2
|
-
import { sessionStorageUtils } from "@fctc/widget-logic/utils";
|
|
3
|
-
import { usePosAppProvider } from "@provider/app-provider";
|
|
4
|
-
import { useMutation } from "@tanstack/react-query";
|
|
5
|
-
|
|
6
|
-
const useSessionProvider = () => {
|
|
7
|
-
const { useCreateSession, useHandleClosingSession, useCreatePosConfig } =
|
|
8
|
-
useService();
|
|
9
|
-
|
|
10
|
-
const createSessionMutation = useCreateSession().mutateAsync;
|
|
11
|
-
const setOpeningCashBoxMutation = useHandleClosingSession().mutateAsync;
|
|
12
|
-
const createPosConfigMutation = useCreatePosConfig().mutateAsync;
|
|
13
|
-
|
|
14
|
-
const { user } = usePosAppProvider();
|
|
15
|
-
const dataUser = user?.userProfile?.data;
|
|
16
|
-
const service = sessionStorageUtils.getMenuFocus().service || `wesap`;
|
|
17
|
-
const xNode = dataUser?.x_node || "";
|
|
18
|
-
|
|
19
|
-
const openSession = useMutation({
|
|
20
|
-
mutationFn: async (configId: number) => {
|
|
21
|
-
return await createSessionMutation({
|
|
22
|
-
configId,
|
|
23
|
-
model: "pos.session",
|
|
24
|
-
service,
|
|
25
|
-
xNode,
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
const setOpeningCashBox = useMutation({
|
|
31
|
-
mutationFn: ({
|
|
32
|
-
cashBoxValue,
|
|
33
|
-
sessionId,
|
|
34
|
-
}: {
|
|
35
|
-
cashBoxValue: number;
|
|
36
|
-
sessionId: number;
|
|
37
|
-
}) => {
|
|
38
|
-
return setOpeningCashBoxMutation({
|
|
39
|
-
model: "pos.session",
|
|
40
|
-
ids: [Number(sessionId)],
|
|
41
|
-
service,
|
|
42
|
-
xNode,
|
|
43
|
-
method: "set_opening_control",
|
|
44
|
-
kwargs: {
|
|
45
|
-
cashbox_value: cashBoxValue,
|
|
46
|
-
notes: "Opening cashbox",
|
|
47
|
-
},
|
|
48
|
-
});
|
|
49
|
-
},
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const createPosConfig = useMutation({
|
|
53
|
-
mutationFn: async ({
|
|
54
|
-
name,
|
|
55
|
-
modulePosRestaurant,
|
|
56
|
-
}: {
|
|
57
|
-
name: string;
|
|
58
|
-
modulePosRestaurant: string;
|
|
59
|
-
}) => {
|
|
60
|
-
return await createPosConfigMutation({
|
|
61
|
-
model: "pos.config",
|
|
62
|
-
name,
|
|
63
|
-
service,
|
|
64
|
-
xNode,
|
|
65
|
-
modulePosRestaurant,
|
|
66
|
-
});
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
openSession,
|
|
72
|
-
setOpeningCashBox,
|
|
73
|
-
createPosConfig,
|
|
74
|
-
};
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
export default useSessionProvider;
|
|
78
|
-
|
|
79
|
-
export type useSessionProviderType = ReturnType<typeof useSessionProvider>;
|
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import { ORDER_STATE } from "@constants/order-state";
|
|
2
|
-
import { QUERY_KEYS } from "@constants/query.constant";
|
|
3
|
-
import { useService } from "@fctc/widget-logic/provider";
|
|
4
|
-
import usePos from "@hooks/common/use-pos";
|
|
5
|
-
import { useQueryParams } from "@hooks/common/use-query-params";
|
|
6
|
-
import { useOrder } from "@provider/pos-provider/order-provider";
|
|
7
|
-
import { LoadDataModel, useSale } from "@provider/pos-provider/sale-provider";
|
|
8
|
-
import { useMutation } from "@tanstack/react-query";
|
|
9
|
-
import { TBasicTable, TCreateTablePayload, TMapedTable } from "@type/table";
|
|
10
|
-
import { t } from "i18next";
|
|
11
|
-
import { useEffect, useMemo, useState } from "react";
|
|
12
|
-
import { toast } from "react-toastify";
|
|
13
|
-
|
|
14
|
-
const usePosTableProvider = (enabled = true) => {
|
|
15
|
-
const { useCreateEntity, useUpdateEntity } = useService();
|
|
16
|
-
const createEntityMutation = useCreateEntity().mutateAsync;
|
|
17
|
-
const updateEntityMutation = useUpdateEntity().mutateAsync;
|
|
18
|
-
const { xNode, service } = usePos();
|
|
19
|
-
const { getData } = useSale();
|
|
20
|
-
const { getQuery } = useQueryParams();
|
|
21
|
-
const [tables, setTables] = useState<TBasicTable[]>([]);
|
|
22
|
-
|
|
23
|
-
const createTable = useMutation({
|
|
24
|
-
mutationFn: (payload: TCreateTablePayload) =>
|
|
25
|
-
createEntityMutation({
|
|
26
|
-
model: LoadDataModel.RESTAURANT_TABLE,
|
|
27
|
-
args: [
|
|
28
|
-
{
|
|
29
|
-
table_number: payload.tableNumber,
|
|
30
|
-
floor_id: payload.floorId,
|
|
31
|
-
seats: payload.seats,
|
|
32
|
-
},
|
|
33
|
-
],
|
|
34
|
-
service: service ?? "",
|
|
35
|
-
xNode: xNode ?? "",
|
|
36
|
-
}),
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
const deleteTable = useMutation({
|
|
40
|
-
mutationFn: (tableId: number) =>
|
|
41
|
-
updateEntityMutation({
|
|
42
|
-
model: LoadDataModel.RESTAURANT_TABLE,
|
|
43
|
-
domain: [["id", "=", tableId]],
|
|
44
|
-
values: {
|
|
45
|
-
active: false,
|
|
46
|
-
},
|
|
47
|
-
service: service ?? "",
|
|
48
|
-
xNode: xNode ?? "",
|
|
49
|
-
}),
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
const updateTable = useMutation({
|
|
53
|
-
mutationFn: (payload: {
|
|
54
|
-
tableId: number;
|
|
55
|
-
tableNumber: string;
|
|
56
|
-
seats: number;
|
|
57
|
-
}) =>
|
|
58
|
-
updateEntityMutation({
|
|
59
|
-
model: LoadDataModel.RESTAURANT_TABLE,
|
|
60
|
-
domain: [["id", "=", payload.tableId]],
|
|
61
|
-
values: {
|
|
62
|
-
table_number: payload.tableNumber,
|
|
63
|
-
seats: payload.seats,
|
|
64
|
-
},
|
|
65
|
-
service: service ?? "",
|
|
66
|
-
xNode: xNode ?? "",
|
|
67
|
-
}),
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
const onCreateTable = async (payload: TCreateTablePayload) => {
|
|
71
|
-
const newTable = await createTable.mutateAsync(payload);
|
|
72
|
-
if (newTable) {
|
|
73
|
-
const newTableId = (newTable as any[][])?.[0]?.[0] as number;
|
|
74
|
-
setTables([
|
|
75
|
-
...tables,
|
|
76
|
-
{
|
|
77
|
-
id: newTableId,
|
|
78
|
-
table_number: payload.tableNumber,
|
|
79
|
-
floor_id: payload.floorId,
|
|
80
|
-
seats: payload.seats,
|
|
81
|
-
},
|
|
82
|
-
]);
|
|
83
|
-
toast.success("Thêm bàn thành công");
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
const onDeleteTable = async (tableId: number, onSuccess?: () => void) => {
|
|
88
|
-
const deleteTableId = await deleteTable.mutateAsync(tableId);
|
|
89
|
-
if (deleteTableId) {
|
|
90
|
-
setTables(tables.filter((t) => t.id !== tableId));
|
|
91
|
-
toast.success(t("deleteTableSuccess"));
|
|
92
|
-
onSuccess && onSuccess();
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
const onUpdateTable = async (payload: {
|
|
97
|
-
tableId: number;
|
|
98
|
-
tableNumber: string;
|
|
99
|
-
seats: number;
|
|
100
|
-
onSuccess?: () => void;
|
|
101
|
-
}) => {
|
|
102
|
-
const updateTableId = await updateTable.mutateAsync(payload);
|
|
103
|
-
if (updateTableId) {
|
|
104
|
-
setTables(
|
|
105
|
-
tables.map((table) =>
|
|
106
|
-
table.id === payload.tableId
|
|
107
|
-
? {
|
|
108
|
-
...table,
|
|
109
|
-
table_number: Number(payload.tableNumber),
|
|
110
|
-
seats: payload.seats,
|
|
111
|
-
}
|
|
112
|
-
: table
|
|
113
|
-
)
|
|
114
|
-
);
|
|
115
|
-
toast.success(t("updateTableSuccess"));
|
|
116
|
-
payload.onSuccess && payload.onSuccess();
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
const floorId = getQuery(QUERY_KEYS.FLOOR);
|
|
120
|
-
|
|
121
|
-
const tablesByFloor = useMemo(() => {
|
|
122
|
-
const tablesFloor = floorId
|
|
123
|
-
? tables?.filter((table) => table.floor_id === Number(floorId))
|
|
124
|
-
: [];
|
|
125
|
-
return [
|
|
126
|
-
{
|
|
127
|
-
id: 0,
|
|
128
|
-
table_number: 0,
|
|
129
|
-
floor_id: 0,
|
|
130
|
-
seats: 0,
|
|
131
|
-
},
|
|
132
|
-
...tablesFloor,
|
|
133
|
-
];
|
|
134
|
-
}, [tables, floorId]);
|
|
135
|
-
|
|
136
|
-
useEffect(() => {
|
|
137
|
-
if (enabled && getData) {
|
|
138
|
-
const tables = getData(LoadDataModel.RESTAURANT_TABLE) as TBasicTable[];
|
|
139
|
-
tables && setTables(tables);
|
|
140
|
-
}
|
|
141
|
-
}, [getData]);
|
|
142
|
-
|
|
143
|
-
const { orders } = useOrder();
|
|
144
|
-
const mapTablesWithOrder: TMapedTable[] = useMemo(() => {
|
|
145
|
-
return tablesByFloor.map((table) => {
|
|
146
|
-
const isTakeAway = table.id === 0;
|
|
147
|
-
const currentOrder = orders?.find((order) => {
|
|
148
|
-
return table.id === 0
|
|
149
|
-
? false
|
|
150
|
-
: table.id?.toString() === order.table_id?.toString() &&
|
|
151
|
-
(order.state === ORDER_STATE.NEW ||
|
|
152
|
-
order.state === ORDER_STATE.IN_PAID);
|
|
153
|
-
});
|
|
154
|
-
return {
|
|
155
|
-
table: {
|
|
156
|
-
id: table.id,
|
|
157
|
-
table_number: table.table_number,
|
|
158
|
-
floor_id: table.floor_id,
|
|
159
|
-
seats: table.seats,
|
|
160
|
-
},
|
|
161
|
-
isTakeAway: isTakeAway,
|
|
162
|
-
currentOrder: currentOrder
|
|
163
|
-
? {
|
|
164
|
-
id: currentOrder?.id,
|
|
165
|
-
table_id: currentOrder?.table_id,
|
|
166
|
-
state: currentOrder?.state,
|
|
167
|
-
create_date: currentOrder?.create_date,
|
|
168
|
-
pos_reference: currentOrder?.pos_reference,
|
|
169
|
-
amount_total: currentOrder?.amount_total,
|
|
170
|
-
amount_tax: currentOrder?.amount_tax,
|
|
171
|
-
user_id: currentOrder?.user_id,
|
|
172
|
-
partner_id: currentOrder?.partner_id,
|
|
173
|
-
write_date: currentOrder?.write_date,
|
|
174
|
-
lines: currentOrder?.lines,
|
|
175
|
-
}
|
|
176
|
-
: undefined,
|
|
177
|
-
};
|
|
178
|
-
});
|
|
179
|
-
}, [tablesByFloor, orders]);
|
|
180
|
-
|
|
181
|
-
return {
|
|
182
|
-
tables,
|
|
183
|
-
tablesByFloor,
|
|
184
|
-
mapTablesWithOrder,
|
|
185
|
-
onCreateTable,
|
|
186
|
-
onDeleteTable,
|
|
187
|
-
onUpdateTable,
|
|
188
|
-
};
|
|
189
|
-
};
|
|
190
|
-
|
|
191
|
-
export default usePosTableProvider;
|
|
192
|
-
|
|
193
|
-
export type usePosTableProviderType = ReturnType<typeof usePosTableProvider>;
|
package/src/index.css
DELETED
package/src/index.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export * from "./components";
|
|
2
|
-
export * from "./constants";
|
|
3
|
-
export * from "./layouts";
|
|
4
|
-
export * from "./pages";
|
|
5
|
-
export { default as PosAppProvider } from "./provider/app-provider";
|
|
6
|
-
export { default as SocketProvider } from "./provider/pos-provider/socket-provider";
|
|
7
|
-
export { default as PublicProvider } from "./provider/public-provider";
|
|
8
|
-
export { default as AppProvider } from "./router/app-router";
|
|
9
|
-
export {
|
|
10
|
-
default as createPOSRoutes,
|
|
11
|
-
default as POSRoutes,
|
|
12
|
-
} from "./router/pos-route";
|
|
13
|
-
import "./index.css";
|