add select company in office case

This commit is contained in:
2025-11-16 23:45:18 +03:00
parent 6e49a89045
commit 73afaea60a

View File

@@ -6,40 +6,64 @@ import {
updateTables, updateTables,
} from "features/order/orderSlice.ts"; } from "features/order/orderSlice.ts";
import styles from "pages/cart/cart.module.css"; import styles from "pages/cart/cart.module.css";
import { OrderType } from "pages/checkout/hooks/types";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useGetTablesQuery } from "redux/api/others"; import { useGetTablesQuery } from "redux/api/others";
import { useAppDispatch, useAppSelector } from "redux/hooks.ts"; import { useAppDispatch, useAppSelector } from "redux/hooks.ts";
export default function TableNumberCard() { export default function TableNumberCard() {
const { t } = useTranslation(); const { t } = useTranslation();
const { tables } = useAppSelector(selectCart); const { tables, orderType } = useAppSelector(selectCart);
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { data: tableList } = useGetTablesQuery({ const { data: tableList } = useGetTablesQuery(
{
restaurantID: localStorage.getItem("restaurantID") || "", restaurantID: localStorage.getItem("restaurantID") || "",
tableType: "1", tableType: orderType === OrderType.DineIn ? "1" : "2",
}, { },
skip: !localStorage.getItem("restaurantID"), {
}); skip: !localStorage.getItem("restaurantID") || !orderType,
},
);
return ( return (
<> <>
<ProInputCard <ProInputCard
title={t("cart.tableNumber")} title={
orderType === OrderType.DineIn
? t("cart.tableNumber")
: t("cart.selectCompany")
}
className={styles.tableNumberCard} className={styles.tableNumberCard}
dividerStyle={{ margin: "5px 0 0 0" }} dividerStyle={{ margin: "5px 0 0 0" }}
> >
<Form.Item <Form.Item
label={t("cart.tableNumber")} label={
orderType === OrderType.DineIn
? t("cart.tableNumber")
: t("cart.selectCompany")
}
name="tables" name="tables"
required required
rules={[{ required: true, message: t("cart.pleaseSelectTable") }]} rules={[
{
required: true,
message:
orderType === OrderType.DineIn
? t("cart.pleaseSelectTable")
: t("cart.pleaseSelectCompany"),
},
]}
initialValue={tables} initialValue={tables}
style={{ position: "relative", top: -5 }} style={{ position: "relative", top: -5 }}
> >
<Select <Select
value={tables} value={tables}
mode="multiple" mode="multiple"
placeholder={t("cart.tableNumber")} placeholder={
orderType === OrderType.DineIn
? t("cart.tableNumber")
: t("cart.selectCompany")
}
size="large" size="large"
options={tableList?.map((table: any) => ({ options={tableList?.map((table: any) => ({
label: table.name, label: table.name,