sme-pos-package 1.0.13 → 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 -10
- 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,96 +0,0 @@
|
|
|
1
|
-
import { EmptyState } from "@components/common/empty-state";
|
|
2
|
-
import { usePosTable } from "@provider/pos-provider/table-provider";
|
|
3
|
-
import { useMemo, useState } from "react";
|
|
4
|
-
import { useTranslation } from "react-i18next";
|
|
5
|
-
import { TableItem } from "./table-item";
|
|
6
|
-
|
|
7
|
-
type TProps = {
|
|
8
|
-
onOpenAddModal: () => void;
|
|
9
|
-
};
|
|
10
|
-
const tableType = [
|
|
11
|
-
{
|
|
12
|
-
id: 1,
|
|
13
|
-
name: "Tất cả",
|
|
14
|
-
value: "all",
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
id: 2,
|
|
18
|
-
name: "Trống",
|
|
19
|
-
value: "available",
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
id: 3,
|
|
23
|
-
name: "Đang sử dụng",
|
|
24
|
-
value: "unavailable",
|
|
25
|
-
},
|
|
26
|
-
];
|
|
27
|
-
const Tables = ({ onOpenAddModal }: TProps) => {
|
|
28
|
-
const { t } = useTranslation();
|
|
29
|
-
const { mapTablesWithOrder } = usePosTable();
|
|
30
|
-
const [type, setType] = useState(tableType[0].value);
|
|
31
|
-
|
|
32
|
-
const getFilterTable = (value: string) => {
|
|
33
|
-
switch (value) {
|
|
34
|
-
case "all":
|
|
35
|
-
return mapTablesWithOrder;
|
|
36
|
-
case "available":
|
|
37
|
-
return mapTablesWithOrder.filter(
|
|
38
|
-
(table) => !table.currentOrder && !table.isTakeAway
|
|
39
|
-
);
|
|
40
|
-
case "unavailable":
|
|
41
|
-
return mapTablesWithOrder.filter(
|
|
42
|
-
(table) => !!table.currentOrder && !table.isTakeAway
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
const filteredByTypeTables = useMemo(() => {
|
|
48
|
-
return getFilterTable(type);
|
|
49
|
-
}, [mapTablesWithOrder, type]);
|
|
50
|
-
|
|
51
|
-
return (
|
|
52
|
-
<div className="flex flex-col py-4 flex-1 overflow-y-auto border-t border-stroke-default">
|
|
53
|
-
<div className="flex gap-3 justify-center">
|
|
54
|
-
{tableType.map((table) => {
|
|
55
|
-
const isActive = type === table.value;
|
|
56
|
-
const size = getFilterTable(table.value)?.length ?? 0;
|
|
57
|
-
return (
|
|
58
|
-
<div
|
|
59
|
-
key={table.id}
|
|
60
|
-
onClick={() => setType(table.value)}
|
|
61
|
-
className={`h-11 px-3 flex justify-center items-center rounded-full cursor-pointer ${
|
|
62
|
-
isActive
|
|
63
|
-
? "border-primary text-primary border-[2px]"
|
|
64
|
-
: "border-stroke-disabled text-text-primary border"
|
|
65
|
-
}`}
|
|
66
|
-
>
|
|
67
|
-
{table.name} ({size})
|
|
68
|
-
</div>
|
|
69
|
-
);
|
|
70
|
-
})}
|
|
71
|
-
</div>
|
|
72
|
-
<div className="z-0 w-full overflow-y-auto flex-1 p-4">
|
|
73
|
-
{filteredByTypeTables && filteredByTypeTables.length > 0 ? (
|
|
74
|
-
<div className="grid gap-5 grid-cols-[repeat(auto-fill,minmax(157px,1fr))]">
|
|
75
|
-
{filteredByTypeTables.map((table) => (
|
|
76
|
-
<TableItem key={table.table.id} tableCard={table} />
|
|
77
|
-
))}
|
|
78
|
-
</div>
|
|
79
|
-
) : (
|
|
80
|
-
<div className="z-0">
|
|
81
|
-
<EmptyState
|
|
82
|
-
image="/assets/images/empty-table-state.png"
|
|
83
|
-
imageAlt={t("no_table")}
|
|
84
|
-
title={t("no_table")}
|
|
85
|
-
description={t("try_add_table")}
|
|
86
|
-
buttonLabel={t("create_table")}
|
|
87
|
-
onAction={onOpenAddModal}
|
|
88
|
-
/>
|
|
89
|
-
</div>
|
|
90
|
-
)}
|
|
91
|
-
</div>
|
|
92
|
-
</div>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export default Tables;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { IcPlus } from "@assets/icons/common";
|
|
2
|
-
import ButtonAction from "@components/common/button-action";
|
|
3
|
-
import Input from "@components/common/input";
|
|
4
|
-
import ModalZoom from "@components/common/modal/modal-zoom";
|
|
5
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
6
|
-
import { useFloor } from "@provider/pos-provider/floor-provider";
|
|
7
|
-
import { useEffect, useMemo, useState } from "react";
|
|
8
|
-
import { useForm } from "react-hook-form";
|
|
9
|
-
import { useTranslation } from "react-i18next";
|
|
10
|
-
import z from "zod";
|
|
11
|
-
|
|
12
|
-
type TProps = {
|
|
13
|
-
defaultName?: string;
|
|
14
|
-
editingFloor?: number;
|
|
15
|
-
setIsEditingFloor?: (val: number | undefined) => void;
|
|
16
|
-
isOpen: boolean;
|
|
17
|
-
onClose: () => void;
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const AddFloorModal = ({
|
|
21
|
-
defaultName,
|
|
22
|
-
editingFloor,
|
|
23
|
-
setIsEditingFloor,
|
|
24
|
-
isOpen,
|
|
25
|
-
onClose,
|
|
26
|
-
}: TProps) => {
|
|
27
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
28
|
-
const { floors, onCreateFloor, onUpdateFloor } = useFloor();
|
|
29
|
-
const { t } = useTranslation();
|
|
30
|
-
|
|
31
|
-
const matchedFloor = useMemo(() => {
|
|
32
|
-
return floors.find((floor) => floor.id === editingFloor);
|
|
33
|
-
}, [floors]);
|
|
34
|
-
|
|
35
|
-
const {
|
|
36
|
-
handleSubmit,
|
|
37
|
-
register,
|
|
38
|
-
setValue,
|
|
39
|
-
formState: { errors },
|
|
40
|
-
setError,
|
|
41
|
-
} = useForm({
|
|
42
|
-
defaultValues: {
|
|
43
|
-
name: defaultName || "",
|
|
44
|
-
},
|
|
45
|
-
mode: "onChange",
|
|
46
|
-
resolver: zodResolver(
|
|
47
|
-
z.object({
|
|
48
|
-
name: z.string().min(1, "Tên tầng là bắt buộc"), //TODO
|
|
49
|
-
})
|
|
50
|
-
),
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const onSubmit = handleSubmit((data) => {
|
|
54
|
-
try {
|
|
55
|
-
setIsLoading(true);
|
|
56
|
-
if (editingFloor) handleEditFloorSubmit(data.name);
|
|
57
|
-
else handleAddFloorSubmit(data.name);
|
|
58
|
-
} catch (error: any) {
|
|
59
|
-
setError("name", { message: error?.message || "Lỗi không xác định" }); //TODO
|
|
60
|
-
setIsLoading(false);
|
|
61
|
-
console.error("Create floor error:", error);
|
|
62
|
-
} finally {
|
|
63
|
-
setIsLoading(false);
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const handleAddFloorSubmit = async (name: string) => {
|
|
68
|
-
await onCreateFloor(name, () => {
|
|
69
|
-
setValue("name", "");
|
|
70
|
-
onClose();
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const handleEditFloorSubmit = async (name: string) => {
|
|
75
|
-
if (!editingFloor) return;
|
|
76
|
-
await onUpdateFloor(Number(editingFloor), name, () => {
|
|
77
|
-
setValue("name", "");
|
|
78
|
-
onClose();
|
|
79
|
-
setIsEditingFloor && setIsEditingFloor(undefined);
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const handleClose = () => {
|
|
84
|
-
setValue("name", "");
|
|
85
|
-
setError("name", { message: "" });
|
|
86
|
-
onClose();
|
|
87
|
-
setIsEditingFloor && setIsEditingFloor(undefined);
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
if (editingFloor) setValue("name", matchedFloor?.name || "");
|
|
92
|
-
}, [editingFloor]);
|
|
93
|
-
|
|
94
|
-
return (
|
|
95
|
-
<ModalZoom
|
|
96
|
-
isOpen={isOpen}
|
|
97
|
-
onClose={handleClose}
|
|
98
|
-
title={editingFloor ? t("edit_floor") : t("add_floor")}
|
|
99
|
-
className="p-6 rounded-2xl bg-white w-[472px]"
|
|
100
|
-
>
|
|
101
|
-
<form onSubmit={onSubmit} className="flex flex-col gap-6">
|
|
102
|
-
<Input
|
|
103
|
-
title={t("floor_name")}
|
|
104
|
-
register={register("name")}
|
|
105
|
-
errorMessage={errors.name?.message}
|
|
106
|
-
isRequired
|
|
107
|
-
inputClassName="p-3"
|
|
108
|
-
placeholder="Nhập tên tầng" //TODO
|
|
109
|
-
/>
|
|
110
|
-
|
|
111
|
-
<div className="flex gap-2 w-full">
|
|
112
|
-
<ButtonAction
|
|
113
|
-
text={t("cancel_button")}
|
|
114
|
-
className="button-secondary w-full h-[60px]"
|
|
115
|
-
onClick={handleClose}
|
|
116
|
-
/>
|
|
117
|
-
<ButtonAction
|
|
118
|
-
type="submit"
|
|
119
|
-
text={
|
|
120
|
-
isLoading
|
|
121
|
-
? t("loading")
|
|
122
|
-
: editingFloor
|
|
123
|
-
? t("edit_floor")
|
|
124
|
-
: t("add_floor_btn_label")
|
|
125
|
-
}
|
|
126
|
-
className="button-primary w-full h-[60px]"
|
|
127
|
-
iconSrc={isLoading || editingFloor ? "" : <IcPlus />}
|
|
128
|
-
/>
|
|
129
|
-
</div>
|
|
130
|
-
</form>
|
|
131
|
-
</ModalZoom>
|
|
132
|
-
);
|
|
133
|
-
};
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { IcPlus, IcTrash } from "@assets/icons/common";
|
|
2
|
-
import ButtonAction from "@components/common/button-action";
|
|
3
|
-
import Input from "@components/common/input";
|
|
4
|
-
import ModalZoom from "@components/common/modal/modal-zoom";
|
|
5
|
-
import { zodResolver } from "@hookform/resolvers/zod";
|
|
6
|
-
import useGetQuery from "@hooks/common/use-get-query";
|
|
7
|
-
import { usePosTable } from "@provider/pos-provider/table-provider";
|
|
8
|
-
import { TBasicTable } from "@type/table";
|
|
9
|
-
import { useEffect, useMemo, useState } from "react";
|
|
10
|
-
import { useForm } from "react-hook-form";
|
|
11
|
-
import { useTranslation } from "react-i18next";
|
|
12
|
-
import { toast } from "react-toastify";
|
|
13
|
-
import z from "zod";
|
|
14
|
-
|
|
15
|
-
const schema = z.object({
|
|
16
|
-
tableNumber: z.coerce.number("Vui lòng nhập số").min(1, "Số bàn là bắt buộc"),
|
|
17
|
-
seats: z.coerce.number("Vui lòng nhập số").min(1, "Sức chứa là bắt buộc"),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
type TProps = {
|
|
21
|
-
isOpen: boolean;
|
|
22
|
-
onClose: () => void;
|
|
23
|
-
editMode?: boolean;
|
|
24
|
-
tableSelected?: TBasicTable;
|
|
25
|
-
onOpenDeleteConfirmModal?: () => void;
|
|
26
|
-
onTableSelected?: (table: TBasicTable | undefined) => void;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const AddTableModal = ({
|
|
30
|
-
isOpen,
|
|
31
|
-
onClose,
|
|
32
|
-
editMode,
|
|
33
|
-
tableSelected,
|
|
34
|
-
onOpenDeleteConfirmModal,
|
|
35
|
-
onTableSelected,
|
|
36
|
-
}: TProps) => {
|
|
37
|
-
const { t } = useTranslation();
|
|
38
|
-
const {
|
|
39
|
-
onCreateTable,
|
|
40
|
-
tablesByFloor: tableData,
|
|
41
|
-
onUpdateTable,
|
|
42
|
-
mapTablesWithOrder,
|
|
43
|
-
} = usePosTable();
|
|
44
|
-
const { floorId } = useGetQuery();
|
|
45
|
-
const [loading, setLoading] = useState(false);
|
|
46
|
-
|
|
47
|
-
const {
|
|
48
|
-
register,
|
|
49
|
-
formState: { errors },
|
|
50
|
-
handleSubmit,
|
|
51
|
-
setValue,
|
|
52
|
-
setError,
|
|
53
|
-
} = useForm({
|
|
54
|
-
defaultValues: {
|
|
55
|
-
tableNumber: "",
|
|
56
|
-
seats: "",
|
|
57
|
-
},
|
|
58
|
-
mode: "onChange",
|
|
59
|
-
resolver: zodResolver(schema),
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
const onSubmit = handleSubmit(async (data) => {
|
|
63
|
-
const payload = {
|
|
64
|
-
tableNumber: data.tableNumber,
|
|
65
|
-
seats: Number(data.seats),
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
const isExist = tableData?.some(
|
|
69
|
-
(table: TBasicTable) =>
|
|
70
|
-
table.table_number === Number(payload.tableNumber) &&
|
|
71
|
-
table.table_number !== tableSelected?.table_number
|
|
72
|
-
);
|
|
73
|
-
|
|
74
|
-
if (isExist) {
|
|
75
|
-
toast.error("Bàn đã tồn tại"); //TODO
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
setLoading(true);
|
|
80
|
-
|
|
81
|
-
try {
|
|
82
|
-
if (editMode) {
|
|
83
|
-
onUpdateTable({
|
|
84
|
-
tableId: tableSelected?.id || 0,
|
|
85
|
-
tableNumber: String(payload.tableNumber),
|
|
86
|
-
seats: payload.seats,
|
|
87
|
-
});
|
|
88
|
-
} else {
|
|
89
|
-
onCreateTable({
|
|
90
|
-
tableNumber: payload.tableNumber,
|
|
91
|
-
seats: payload.seats,
|
|
92
|
-
floorId: Number(floorId),
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
} catch (error: any) {
|
|
96
|
-
toast.error(error?.message);
|
|
97
|
-
} finally {
|
|
98
|
-
handleClose();
|
|
99
|
-
onTableSelected?.(undefined);
|
|
100
|
-
setLoading(false);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
const handleClose = () => {
|
|
105
|
-
setValue("tableNumber", "");
|
|
106
|
-
setValue("seats", "");
|
|
107
|
-
setError("tableNumber", { message: "" });
|
|
108
|
-
setError("seats", { message: "" });
|
|
109
|
-
onClose();
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
const isTableContainOrder = useMemo(() => {
|
|
113
|
-
return mapTablesWithOrder.find(
|
|
114
|
-
(table) => table.table.id === tableSelected?.id
|
|
115
|
-
)?.currentOrder;
|
|
116
|
-
}, [tableSelected]);
|
|
117
|
-
|
|
118
|
-
const handleDeleteTable = () => {
|
|
119
|
-
if (isTableContainOrder) {
|
|
120
|
-
toast.error("Bàn đang có đơn hàng");
|
|
121
|
-
} else {
|
|
122
|
-
onOpenDeleteConfirmModal?.();
|
|
123
|
-
handleClose();
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
useEffect(() => {
|
|
128
|
-
if (tableSelected) {
|
|
129
|
-
setValue("tableNumber", tableSelected.table_number);
|
|
130
|
-
setValue("seats", tableSelected.seats);
|
|
131
|
-
}
|
|
132
|
-
}, [tableSelected]);
|
|
133
|
-
|
|
134
|
-
return (
|
|
135
|
-
<ModalZoom
|
|
136
|
-
isOpen={isOpen}
|
|
137
|
-
onClose={handleClose}
|
|
138
|
-
title={editMode ? t("edit_table") : t("add_new_table")}
|
|
139
|
-
className="p-6 rounded-2xl bg-white"
|
|
140
|
-
headerAction={
|
|
141
|
-
editMode && (
|
|
142
|
-
<button onClick={handleDeleteTable} className="text-state-error-base">
|
|
143
|
-
<IcTrash />
|
|
144
|
-
</button>
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
|
-
>
|
|
148
|
-
<form onSubmit={onSubmit} className="flex flex-col gap-6">
|
|
149
|
-
<div className="flex items-center justify-center gap-6 w-full">
|
|
150
|
-
<Input
|
|
151
|
-
title="Số bàn" //TODO
|
|
152
|
-
register={register("tableNumber")}
|
|
153
|
-
placeholder="Nhập tên bàn" //TODO
|
|
154
|
-
isRequired
|
|
155
|
-
inputMode="numeric"
|
|
156
|
-
type="number"
|
|
157
|
-
errorMessage={errors.tableNumber?.message}
|
|
158
|
-
className="flex-1"
|
|
159
|
-
inputClassName="py-[15px] px-3"
|
|
160
|
-
/>
|
|
161
|
-
|
|
162
|
-
<Input
|
|
163
|
-
title="Sức chứa" //TODO
|
|
164
|
-
register={register("seats")}
|
|
165
|
-
placeholder="Nhập sức chứa" //TODO
|
|
166
|
-
isRequired
|
|
167
|
-
inputMode="numeric"
|
|
168
|
-
type="number"
|
|
169
|
-
errorMessage={errors.seats?.message}
|
|
170
|
-
className="flex-1"
|
|
171
|
-
inputClassName="py-[15px] px-3"
|
|
172
|
-
/>
|
|
173
|
-
</div>
|
|
174
|
-
|
|
175
|
-
<div className="flex gap-2 w-full">
|
|
176
|
-
<ButtonAction
|
|
177
|
-
text={t("cancel_button")}
|
|
178
|
-
className="button-secondary w-full h-[60px]"
|
|
179
|
-
onClick={handleClose}
|
|
180
|
-
/>
|
|
181
|
-
<ButtonAction
|
|
182
|
-
type="submit"
|
|
183
|
-
disabled={loading}
|
|
184
|
-
text={
|
|
185
|
-
loading
|
|
186
|
-
? t("loading")
|
|
187
|
-
: editMode
|
|
188
|
-
? t("update_button")
|
|
189
|
-
: t("add_table")
|
|
190
|
-
}
|
|
191
|
-
className="button-primary w-full h-[60px]"
|
|
192
|
-
iconSrc={loading || editMode ? "" : <IcPlus />}
|
|
193
|
-
/>
|
|
194
|
-
</div>
|
|
195
|
-
</form>
|
|
196
|
-
</ModalZoom>
|
|
197
|
-
);
|
|
198
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import DeleteConfirmModalContainer from "@components/common/modal/delete-confirm-modal-container";
|
|
2
|
-
import { useFloor } from "@provider/pos-provider/floor-provider";
|
|
3
|
-
import { Trans, useTranslation } from "react-i18next";
|
|
4
|
-
|
|
5
|
-
const DeleteFloorConfirmModal = ({
|
|
6
|
-
isOpen,
|
|
7
|
-
onClose,
|
|
8
|
-
floorId,
|
|
9
|
-
floorName,
|
|
10
|
-
}: {
|
|
11
|
-
isOpen: boolean;
|
|
12
|
-
onClose: () => void;
|
|
13
|
-
floorId: number;
|
|
14
|
-
floorName: string;
|
|
15
|
-
}) => {
|
|
16
|
-
const { t } = useTranslation();
|
|
17
|
-
const { onDeleteFloor } = useFloor();
|
|
18
|
-
|
|
19
|
-
const deleteFloor = async () => {
|
|
20
|
-
await onDeleteFloor(floorId, () => {
|
|
21
|
-
onClose();
|
|
22
|
-
});
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<DeleteConfirmModalContainer
|
|
27
|
-
title={t("confirm_delete_floor")}
|
|
28
|
-
description={
|
|
29
|
-
<Trans
|
|
30
|
-
i18nKey="confirm_delete_table"
|
|
31
|
-
values={{ floorName }}
|
|
32
|
-
components={{ bold: <span className="text-text-primary" /> }}
|
|
33
|
-
/>
|
|
34
|
-
}
|
|
35
|
-
onAction={deleteFloor}
|
|
36
|
-
onClose={onClose}
|
|
37
|
-
isOpen={isOpen}
|
|
38
|
-
/>
|
|
39
|
-
);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export default DeleteFloorConfirmModal;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import DeleteConfirmModalContainer from "@components/common/modal/delete-confirm-modal-container";
|
|
2
|
-
import { usePosTable } from "@provider/pos-provider/table-provider";
|
|
3
|
-
import { TBasicTable } from "@type/table";
|
|
4
|
-
import { Trans, useTranslation } from "react-i18next";
|
|
5
|
-
import { toast } from "react-toastify";
|
|
6
|
-
|
|
7
|
-
type TProps = {
|
|
8
|
-
isOpen: boolean;
|
|
9
|
-
onClose: () => void;
|
|
10
|
-
tableSelected?: TBasicTable;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
const DeleteTableConfirmModal = ({
|
|
14
|
-
isOpen,
|
|
15
|
-
onClose,
|
|
16
|
-
tableSelected,
|
|
17
|
-
}: TProps) => {
|
|
18
|
-
const { t } = useTranslation();
|
|
19
|
-
const { onDeleteTable: deleteTable } = usePosTable();
|
|
20
|
-
|
|
21
|
-
const onDeleteTable = async () => {
|
|
22
|
-
try {
|
|
23
|
-
if (!tableSelected) return;
|
|
24
|
-
deleteTable(tableSelected?.id, () => {
|
|
25
|
-
onClose();
|
|
26
|
-
});
|
|
27
|
-
} catch (error: any) {
|
|
28
|
-
toast.error(error);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<DeleteConfirmModalContainer
|
|
34
|
-
title={t("confirm_delete_table_title")}
|
|
35
|
-
description={
|
|
36
|
-
<Trans
|
|
37
|
-
i18nKey="confirm_delete_table_description"
|
|
38
|
-
values={{ tableName: tableSelected?.table_number }}
|
|
39
|
-
components={{
|
|
40
|
-
bold: <span className="text-text-primary font-semibold" />,
|
|
41
|
-
}}
|
|
42
|
-
/>
|
|
43
|
-
}
|
|
44
|
-
onAction={onDeleteTable}
|
|
45
|
-
onClose={onClose}
|
|
46
|
-
isOpen={isOpen}
|
|
47
|
-
/>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default DeleteTableConfirmModal;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useTranslation } from "react-i18next"
|
|
2
|
-
import { useNavigate } from "react-router-dom"
|
|
3
|
-
|
|
4
|
-
export const Header = () => {
|
|
5
|
-
const { t } = useTranslation()
|
|
6
|
-
const navigate = useNavigate()
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<div className="flex items-center justify-between h-[60px] px-3 py-[6px] border-b-[0.5px] bg-white">
|
|
10
|
-
<button
|
|
11
|
-
onClick={() => navigate(-1)}
|
|
12
|
-
className="w-12 aspect-square bg-neutral-disabled rounded-lg"
|
|
13
|
-
>
|
|
14
|
-
‹
|
|
15
|
-
</button>
|
|
16
|
-
<p className="text-lg text-strong-950 font-semibold leading-[26px]">
|
|
17
|
-
{t("floor-management")}
|
|
18
|
-
</p>
|
|
19
|
-
<div />
|
|
20
|
-
</div>
|
|
21
|
-
)
|
|
22
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import useGetQuery from "@hooks/common/use-get-query";
|
|
2
|
-
import { useFloor } from "@provider/pos-provider/floor-provider";
|
|
3
|
-
import { useMemo, useState } from "react";
|
|
4
|
-
import { AddFloorModal } from "./add-floor-modal";
|
|
5
|
-
import { Header } from "./header";
|
|
6
|
-
import LeftSide from "./left-side";
|
|
7
|
-
import RightSide from "./right-side";
|
|
8
|
-
|
|
9
|
-
const ManagementFloor = () => {
|
|
10
|
-
const { floors } = useFloor();
|
|
11
|
-
const { floorId } = useGetQuery();
|
|
12
|
-
const [isOpenAddFloor, setIsOpenAddFloor] = useState(false);
|
|
13
|
-
const [isEditingFloor, setIsEditingFloor] = useState<number | undefined>();
|
|
14
|
-
|
|
15
|
-
const activeFloor = useMemo(() => {
|
|
16
|
-
if (!floors.length) return;
|
|
17
|
-
|
|
18
|
-
if (!floorId) floors[0]?.id;
|
|
19
|
-
|
|
20
|
-
const activeFloor = floors.find((floor) => floor.id === floorId);
|
|
21
|
-
|
|
22
|
-
return activeFloor ?? floors[0];
|
|
23
|
-
}, [floors, floorId]);
|
|
24
|
-
|
|
25
|
-
return (
|
|
26
|
-
<div className="flex flex-col h-screen">
|
|
27
|
-
<Header />
|
|
28
|
-
<div className="flex flex-1 overflow-auto ">
|
|
29
|
-
<LeftSide
|
|
30
|
-
floors={floors}
|
|
31
|
-
activeFloor={activeFloor}
|
|
32
|
-
isOpenAddFloor={isOpenAddFloor}
|
|
33
|
-
setIsOpenAddFloor={setIsOpenAddFloor}
|
|
34
|
-
/>
|
|
35
|
-
|
|
36
|
-
<RightSide
|
|
37
|
-
activeFloor={activeFloor}
|
|
38
|
-
isOpenAddFloor={isOpenAddFloor}
|
|
39
|
-
setIsOpenAddFloor={setIsOpenAddFloor}
|
|
40
|
-
setIsEditingFloor={setIsEditingFloor}
|
|
41
|
-
/>
|
|
42
|
-
|
|
43
|
-
<AddFloorModal
|
|
44
|
-
isOpen={isOpenAddFloor}
|
|
45
|
-
editingFloor={isEditingFloor}
|
|
46
|
-
onClose={() => setIsOpenAddFloor(false)}
|
|
47
|
-
setIsEditingFloor={setIsEditingFloor}
|
|
48
|
-
/>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
);
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export default ManagementFloor;
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { IcPlus } from "@assets/icons/common";
|
|
2
|
-
import ButtonAction from "@components/common/button-action";
|
|
3
|
-
import { QUERY_KEYS } from "@constants/query.constant";
|
|
4
|
-
import { useQueryParams } from "@hooks/common/use-query-params";
|
|
5
|
-
import { TFloor } from "@type/floor/floor";
|
|
6
|
-
import { cn } from "@utils/functions";
|
|
7
|
-
|
|
8
|
-
type TProps = {
|
|
9
|
-
floors: TFloor[];
|
|
10
|
-
activeFloor: TFloor | undefined;
|
|
11
|
-
setIsOpenAddFloor: (isOpen: boolean) => void;
|
|
12
|
-
isOpenAddFloor: boolean;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const LeftSide = ({ floors, activeFloor, setIsOpenAddFloor }: TProps) => {
|
|
16
|
-
const { updateQuery } = useQueryParams();
|
|
17
|
-
|
|
18
|
-
const handleUpdateFloor = (floorId: string) => {
|
|
19
|
-
updateQuery(QUERY_KEYS.FLOOR, floorId);
|
|
20
|
-
};
|
|
21
|
-
return (
|
|
22
|
-
<div className="w-fit h-full flex flex-col gap-4 p-2 border-r-[0.5px] border-stroke-disabled bg-white">
|
|
23
|
-
<div className="flex-1 flex flex-col overflow-y-auto hide-scrollbar w-full">
|
|
24
|
-
{floors.map((floor) => (
|
|
25
|
-
<div
|
|
26
|
-
key={floor.id}
|
|
27
|
-
onClick={() => handleUpdateFloor(floor.id.toString())}
|
|
28
|
-
className={cn(
|
|
29
|
-
"p-3 text-text-disable font-medium text-sm leading-5 tracking-[-0.12px] h-fit min-h-12 rounded-lg w-full flex items-center cursor-pointer",
|
|
30
|
-
{
|
|
31
|
-
"bg-surface-primary text-text-active font-semibold":
|
|
32
|
-
activeFloor?.id === floor.id,
|
|
33
|
-
}
|
|
34
|
-
)}
|
|
35
|
-
>
|
|
36
|
-
{floor.name}
|
|
37
|
-
</div>
|
|
38
|
-
))}
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<ButtonAction
|
|
42
|
-
className="button-primary px-3 min-w-fit w-fit"
|
|
43
|
-
text=" Tạo tầng"
|
|
44
|
-
iconSrc={<IcPlus />}
|
|
45
|
-
onClick={() => setIsOpenAddFloor(true)}
|
|
46
|
-
/>
|
|
47
|
-
</div>
|
|
48
|
-
);
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default LeftSide;
|