import { useState } from "react"; import { useTranslation } from "react-i18next"; import { ProBottomSheet } from "components/ProBottomSheet/ProBottomSheet"; import { colors } from "ThemeConstants"; import { Button, Card } from "antd"; import CarRatioGroups from "./CarRatioGroups/CarRatioGroups"; import PlusIcon from "components/Icons/PlusIcon"; import styles from "../checkout.module.css"; import { AddCarBottomSheet } from "components/CustomBottomSheet/AddCarBottomSheet"; import { updatePlateCar } from "features/order/orderSlice"; import { useAppDispatch } from "redux/hooks"; interface CarBottomSheetProps { isOpen: boolean; onClose: () => void; } export function CarBottomSheet({ isOpen, onClose }: CarBottomSheetProps) { const { t } = useTranslation(); const [value, setValue] = useState(null); const [isAddCarOpen, setIsAddCarOpen] = useState(false); const dispatch = useAppDispatch(); const handleCancel = () => { setValue(null); onClose(); }; const handleSave = () => { dispatch(updatePlateCar(value || "")); onClose(); }; const handleAddCarClick = () => { setIsAddCarOpen(true); }; const handleAddCarClose = () => { setIsAddCarOpen(false); // Reopen CarBottomSheet when AddCarBottomSheet closes // The parent component should handle reopening, but we'll ensure state is correct }; const handleAddCarSave = () => { dispatch(updatePlateCar(value || "")); // After saving, close AddCarBottomSheet which will trigger reopening CarBottomSheet setIsAddCarOpen(false); }; // Show AddCarBottomSheet when it's open, otherwise show CarBottomSheet if (isAddCarOpen) { return ( ); } return ( setValue(value)} optionsStyle={{ fontSize: 12, fontWeight: 500, color: "#5F6C7B", }} valueStyle={{ fontSize: 12, fontWeight: 500, color: colors.primary, }} />
); }