cart: Special request > move files
This commit is contained in:
@@ -15,7 +15,7 @@ import { selectCart } from "features/order/orderSlice.ts";
|
||||
import CarPlateCard from "pages/cart/components/CarPlateCard.tsx";
|
||||
import CouponCard from "pages/cart/components/CouponCard.tsx";
|
||||
import RewardWaiterCard from "pages/cart/components/RewardWaiterCard.tsx";
|
||||
import SpecialRequestCard from "pages/cart/components/SpecialRequestCard.tsx";
|
||||
import SpecialRequestCard from "pages/cart/components/specialRequest/SpecialRequestCard.tsx";
|
||||
import TableNumberCard from "pages/cart/components/TableNumberCard.tsx";
|
||||
import TimeEstimateCard from "pages/cart/components/timeEstimate/TimeEstimateCard.tsx";
|
||||
import YouMightAlsoLike from "pages/cart/components/youMayLike/YouMightAlsoLike.tsx";
|
||||
|
||||
@@ -21,7 +21,7 @@ import OrderSummary from "components/OrderSummary/OrderSummary.tsx";
|
||||
import { useAppSelector } from "redux/hooks.ts";
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import SpecialRequestCard from "pages/cart/components/SpecialRequestCard.tsx";
|
||||
import SpecialRequestCard from "pages/cart/components/specialRequest/SpecialRequestCard.tsx";
|
||||
import useBreakPoint from "hooks/useBreakPoint.ts";
|
||||
import CouponCard from "pages/cart/components/CouponCard.tsx";
|
||||
import RewardWaiterCard from "pages/cart/components/RewardWaiterCard.tsx";
|
||||
|
||||
68
src/pages/cart/components/specialRequest/BottomSheet.tsx
Normal file
68
src/pages/cart/components/specialRequest/BottomSheet.tsx
Normal file
@@ -0,0 +1,68 @@
|
||||
import { Button, Input } from "antd";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ProBottomSheet } from "components/ProBottomSheet/ProBottomSheet.tsx";
|
||||
|
||||
const { TextArea } = Input;
|
||||
|
||||
interface SpecialRequestBottomSheetProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
initialValue: string;
|
||||
onSave: (value: string) => void;
|
||||
}
|
||||
|
||||
export function BottomSheet({
|
||||
isOpen,
|
||||
onClose,
|
||||
initialValue,
|
||||
onSave,
|
||||
}: SpecialRequestBottomSheetProps) {
|
||||
const { t } = useTranslation();
|
||||
const [value, setValue] = useState(initialValue);
|
||||
|
||||
useEffect(() => {
|
||||
setValue(initialValue);
|
||||
}, [initialValue]);
|
||||
|
||||
const handleSave = () => {
|
||||
onSave(value);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
setValue(initialValue);
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<ProBottomSheet
|
||||
isOpen={isOpen}
|
||||
onClose={handleCancel}
|
||||
title={t("cart.specialRequest")}
|
||||
showCloseButton={false}
|
||||
initialSnap={1}
|
||||
height={"40vh"}
|
||||
snapPoints={["30vh"]}
|
||||
>
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<TextArea
|
||||
value={value}
|
||||
onChange={(e) => setValue(e.target.value)}
|
||||
placeholder={t("cart.specialRequest")}
|
||||
rows={6}
|
||||
size="middle"
|
||||
autoFocus={false}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<br />
|
||||
|
||||
<Button type="primary" style={{ width: "100%" }} onClick={handleSave}>
|
||||
{t("cart.save")}
|
||||
</Button>
|
||||
</div>
|
||||
</ProBottomSheet>
|
||||
);
|
||||
}
|
||||
66
src/pages/cart/components/specialRequest/Dialog.tsx
Normal file
66
src/pages/cart/components/specialRequest/Dialog.tsx
Normal file
@@ -0,0 +1,66 @@
|
||||
import { Button, Input, Modal } from "antd";
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
const { TextArea } = Input;
|
||||
|
||||
interface SpecialRequestDialogProps {
|
||||
isOpen: boolean;
|
||||
onClose: () => void;
|
||||
initialValue: string;
|
||||
onSave: (value: string) => void;
|
||||
}
|
||||
|
||||
export function Dialog({
|
||||
isOpen,
|
||||
onClose,
|
||||
initialValue,
|
||||
onSave,
|
||||
}: SpecialRequestDialogProps) {
|
||||
const { t } = useTranslation();
|
||||
const [value, setValue] = useState(initialValue);
|
||||
|
||||
useEffect(() => {
|
||||
setValue(initialValue);
|
||||
}, [initialValue]);
|
||||
|
||||
const handleSave = () => {
|
||||
onSave(value);
|
||||
onClose();
|
||||
};
|
||||
|
||||
const handleCancel = () => {
|
||||
setValue(initialValue);
|
||||
onClose();
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={t("cart.specialRequest")}
|
||||
open={isOpen}
|
||||
onCancel={handleCancel}
|
||||
footer={[
|
||||
<Button key="cancel" onClick={handleCancel}>
|
||||
{t("cart.cancel")}
|
||||
</Button>,
|
||||
<Button key="save" type="primary" onClick={handleSave}>
|
||||
{t("cart.save")}
|
||||
</Button>,
|
||||
]}
|
||||
width={500}
|
||||
destroyOnHidden
|
||||
>
|
||||
<div className="space-y-4">
|
||||
<div>
|
||||
<TextArea
|
||||
value={value}
|
||||
onChange={(e) => setValue(e.target.value)}
|
||||
placeholder={t("cart.specialRequest")}
|
||||
rows={6}
|
||||
autoFocus={false}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
.inputField {
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.editButton {
|
||||
color: var(--primary, #FFB700);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -3,12 +3,12 @@ import { message, Input } from "antd";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useAppDispatch, useAppSelector } from "redux/hooks.ts";
|
||||
import ProInputCard from "components/ProInputCard/ProInputCard.tsx";
|
||||
import { colors } from "ThemeConstants.ts";
|
||||
import { RightOutlined } from "@ant-design/icons";
|
||||
import { SpecialRequestBottomSheet } from "components/CustomBottomSheet/SpecialRequestBottomSheet.tsx";
|
||||
import { BottomSheet } from "pages/cart/components/specialRequest/BottomSheet.tsx";
|
||||
import { useState } from "react";
|
||||
import useBreakPoint from "hooks/useBreakPoint.ts";
|
||||
import { SpecialRequestDialog } from "components/CustomBottomSheet/SpecialRequestDialog.tsx";
|
||||
import { Dialog } from "pages/cart/components/specialRequest/Dialog.tsx";
|
||||
import styles from "./SpecialRequestCard.module.css";
|
||||
|
||||
export default function SpecialRequestCard() {
|
||||
const { t } = useTranslation();
|
||||
@@ -34,14 +34,10 @@ export default function SpecialRequestCard() {
|
||||
placeholder={t("cart.specialRequest")}
|
||||
size="large"
|
||||
autoFocus={false}
|
||||
style={{ height: 50 }}
|
||||
className={styles.inputField}
|
||||
suffix={
|
||||
<div
|
||||
style={{
|
||||
color: colors.primary,
|
||||
fontSize: 14,
|
||||
cursor: "pointer",
|
||||
}}
|
||||
className={styles.editButton}
|
||||
onClick={() => setIsSpecialRequestOpen(true)}
|
||||
>
|
||||
<u>{t("cart.editNote")}</u> <RightOutlined />
|
||||
@@ -50,14 +46,14 @@ export default function SpecialRequestCard() {
|
||||
/>
|
||||
</ProInputCard>
|
||||
{isDesktop ? (
|
||||
<SpecialRequestDialog
|
||||
<Dialog
|
||||
isOpen={isSpecialRequestOpen}
|
||||
onClose={handleSpecialRequestClose}
|
||||
initialValue={specialRequest}
|
||||
onSave={handleSpecialRequestSave}
|
||||
/>
|
||||
) : (
|
||||
<SpecialRequestBottomSheet
|
||||
<BottomSheet
|
||||
isOpen={isSpecialRequestOpen}
|
||||
onClose={handleSpecialRequestClose}
|
||||
initialValue={specialRequest}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ShoppingCartOutlined } from "@ant-design/icons";
|
||||
import { Button, Grid, message, Row } from "antd";
|
||||
import { SpecialRequestBottomSheet } from "components/CustomBottomSheet/SpecialRequestBottomSheet";
|
||||
import { BottomSheet } from "pages/cart/components/specialRequest/BottomSheet.tsx";
|
||||
import {
|
||||
addItem,
|
||||
selectCart,
|
||||
@@ -59,7 +59,7 @@ export default function ProductFooter({
|
||||
extrasgroup: selectedGroups,
|
||||
},
|
||||
quantity: quantity,
|
||||
})
|
||||
}),
|
||||
);
|
||||
// Navigate back to menu - scroll position will be restored automatically
|
||||
window.history.back();
|
||||
@@ -132,7 +132,7 @@ export default function ProductFooter({
|
||||
</div>
|
||||
</Row>
|
||||
|
||||
<SpecialRequestBottomSheet
|
||||
<BottomSheet
|
||||
isOpen={isSpecialRequestOpen}
|
||||
onClose={handleSpecialRequestClose}
|
||||
initialValue={specialRequest}
|
||||
|
||||
Reference in New Issue
Block a user