diff --git a/src/assets/locals/ar.json b/src/assets/locals/ar.json index ead7256..37d4d8f 100644 --- a/src/assets/locals/ar.json +++ b/src/assets/locals/ar.json @@ -511,6 +511,11 @@ }, "car":{ "addCar":"إضافة سيارة", - "selectCar":"اختر السيارة" + "selectCar":"اختر السيارة", + "addCarDetails":"إضافة تفاصيل السيارة", + "brand":"العلامة التجارية", + "color":"اللون", + "category":"الفئة", + "plateNumber":"رقم السيارة" } } diff --git a/src/assets/locals/en.json b/src/assets/locals/en.json index a9ce846..8a68f0c 100644 --- a/src/assets/locals/en.json +++ b/src/assets/locals/en.json @@ -523,6 +523,11 @@ }, "car": { "addCar": "Add Car", - "selectCar": "Select Car" + "selectCar": "Select Car", + "addCarDetails": "Add Car Details", + "brand": "Brand", + "color": "Color", + "category": "Category", + "plateNumber": "Plate Number" } } diff --git a/src/components/CustomBottomSheet/AddCarBottomSheet.tsx b/src/components/CustomBottomSheet/AddCarBottomSheet.tsx new file mode 100644 index 0000000..d0c2a6f --- /dev/null +++ b/src/components/CustomBottomSheet/AddCarBottomSheet.tsx @@ -0,0 +1,126 @@ +import { Button, Form, Input } from "antd"; +import ProPhoneInput from "components/ProPhoneInput"; +import { useEffect } from "react"; +import { useTranslation } from "react-i18next"; +import { ProBottomSheet } from "../ProBottomSheet/ProBottomSheet"; + +const { TextArea } = Input; + +interface CarDetailsType { + brandId: string; + category: string; + color: string; + plateNumber: string; +} + +interface AddCarBottomSheetProps { + isOpen: boolean; + onClose: () => void; + onSave: (value: CarDetailsType) => void; +} + +export function AddCarBottomSheet({ + isOpen, + onClose, + onSave, +}: AddCarBottomSheetProps) { + const { t } = useTranslation(); + const [carForm] = Form.useForm(); + useEffect(() => { + carForm.setFieldsValue({}); + }, [carForm]); + + const handleSave = () => { + onSave(carForm.getFieldsValue()); + carForm.resetFields(); + onClose(); + }; + + const handleCancel = () => { + carForm.resetFields(); + onClose(); + }; + + return ( + +
+
+ + + + + + + + + + + + + + + +
+
+ +
+ + +
+ ); +} diff --git a/src/pages/checkout/components/CarBottomSheet.tsx b/src/pages/checkout/components/CarBottomSheet.tsx index 26fe9c6..c7d6d80 100644 --- a/src/pages/checkout/components/CarBottomSheet.tsx +++ b/src/pages/checkout/components/CarBottomSheet.tsx @@ -6,6 +6,7 @@ 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"; interface CarBottomSheetProps { isOpen: boolean; @@ -15,6 +16,7 @@ interface CarBottomSheetProps { export function CarBottomSheet({ isOpen, onClose }: CarBottomSheetProps) { const { t } = useTranslation(); const [value, setValue] = useState(null); + const [isAddCarOpen, setIsAddCarOpen] = useState(false); const handleCancel = () => { setValue(null); @@ -26,6 +28,34 @@ export function CarBottomSheet({ isOpen, onClose }: CarBottomSheetProps) { setValue(value); }; + 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 = (carDetails: any) => { + // Handle saving the new car details + console.log("Car details saved:", carDetails); + // After saving, close AddCarBottomSheet which will trigger reopening CarBottomSheet + setIsAddCarOpen(false); + }; + + // Show AddCarBottomSheet when it's open, otherwise show CarBottomSheet + if (isAddCarOpen) { + return ( + + ); + } + return ( } + onClick={handleAddCarClick} + icon={ + + } > {t("car.addCar")}