diff --git a/src/components/AddAdminModal/addAdminModal.tsx b/src/components/AddAdminModal/addAdminModal.tsx index e459518..5c12acd 100644 --- a/src/components/AddAdminModal/addAdminModal.tsx +++ b/src/components/AddAdminModal/addAdminModal.tsx @@ -324,6 +324,7 @@ const AddAdminModal: React.FC = ({ backgroundColor: "#52ACDF", color: "white", borderRadius: "8px", + fontSize: "16px", width: "117px", "&:hover": { backgroundColor: "#439BC1" }, }} diff --git a/src/components/AddBookingModal/addBookingModal.tsx b/src/components/AddBookingModal/addBookingModal.tsx index 4062a81..b083277 100644 --- a/src/components/AddBookingModal/addBookingModal.tsx +++ b/src/components/AddBookingModal/addBookingModal.tsx @@ -125,7 +125,7 @@ export default function AddBookingModal({ alignItems: "center", }} > - + Add Booking @@ -453,6 +453,7 @@ export default function AddBookingModal({ backgroundColor: "#52ACDF", color: "white", borderRadius: "8px", + fontSize: "16px", width: "117px", "&:hover": { backgroundColor: "#439BC1" }, }} diff --git a/src/components/AddEditAdminModal/addEditAdminModal.tsx b/src/components/AddEditAdminModal/addEditAdminModal.tsx index 0f85b81..1df20ab 100644 --- a/src/components/AddEditAdminModal/addEditAdminModal.tsx +++ b/src/components/AddEditAdminModal/addEditAdminModal.tsx @@ -130,7 +130,7 @@ const AddEditCategoryModal: React.FC = ({ alignItems: "center", }} > - + {editRow ? "Edit Admin" : "Add Admin"} @@ -430,6 +430,7 @@ const AddEditCategoryModal: React.FC = ({ backgroundColor: "#52ACDF", color: "white", borderRadius: "8px", + fontSize: "16px", width: "117px", "&:hover": { backgroundColor: "#439BC1" }, }} diff --git a/src/components/AddManagerModal/addManagerModal.tsx b/src/components/AddManagerModal/addManagerModal.tsx index db9fb96..aac1da3 100644 --- a/src/components/AddManagerModal/addManagerModal.tsx +++ b/src/components/AddManagerModal/addManagerModal.tsx @@ -106,7 +106,7 @@ export default function AddManagerModal({ alignItems: "center", }} > - + Add Manager @@ -130,7 +130,6 @@ export default function AddManagerModal({ placeholder="Enter Manager Name" size="small" sx={{ marginTop: 1 }} - error={!!errors.name} helperText={ errors.name ? errors.name.message : "" @@ -160,10 +159,7 @@ export default function AddManagerModal({ {/* Station Dropdown */} - + Select Station { @@ -239,7 +234,6 @@ export default function AddManagerModal({ placeholder="Enter Manager Email" size="small" sx={{ marginTop: 1 }} - autoComplete="new-email" error={!!errors.email} helperText={ @@ -281,7 +275,6 @@ export default function AddManagerModal({ {...field} required sx={{ marginTop: 1 }} - autoComplete="new-password" placeholder="Enter Password" type={ @@ -334,7 +327,6 @@ export default function AddManagerModal({ placeholder="Enter Phone Number" size="small" sx={{ marginTop: 1 }} - error={!!errors.phone} helperText={ errors.phone ? errors.phone.message : "" @@ -372,6 +364,7 @@ export default function AddManagerModal({ backgroundColor: "#52ACDF", color: "white", borderRadius: "8px", + fontSize: "16px", width: "117px", "&:hover": { backgroundColor: "#439BC1" }, }} diff --git a/src/components/AddSlotModal/addSlotModal.tsx b/src/components/AddSlotModal/addSlotModal.tsx index 1986283..2950115 100644 --- a/src/components/AddSlotModal/addSlotModal.tsx +++ b/src/components/AddSlotModal/addSlotModal.tsx @@ -1,173 +1,25 @@ -// import React, { useState } from "react"; -// import { -// Dialog, -// DialogActions, -// DialogContent, -// DialogTitle, -// Button, -// TextField, -// Typography, -// Box, -// } from "@mui/material"; -// import { useForm } from "react-hook-form"; - -// const AddSlotModal = ({ open, handleClose, handleAddSlot }: any) => { -// const { -// register, -// handleSubmit, -// reset, -// formState: { errors }, -// } = useForm(); -// const [isAvailable, setIsAvailable] = useState(true); // Default is available - -// // Get today's date in the format yyyy-mm-dd -// const today = new Date().toISOString().split("T")[0]; - -// const onSubmit = (data: { -// date: string; -// startHour: string; -// endHour: string; -// }) => { -// handleAddSlot({ ...data, isAvailable }); -// reset(); -// handleClose(); -// }; - -// return ( -// -// Add EV Slot -// -//
-// -// Date -// -// -// value >= today || "Date cannot be in the past", -// })} -// // label="Date" -// // sx={{ marginTop: 1 }} -// type="date" -// fullWidth -// margin="normal" -// slotProps={{ -// inputLabel: { -// shrink: true, -// }, -// }} -// error={!!errors.date} -// helperText={errors.date?.message} -// // Set the min value to today's date -// inputProps={{ min: today }} -// /> -// -// Start Hour -// -// -// -// End Hour -// -// -// {/* Availability Toggle */} -// - -// -// -// {isAvailable ? "Available" : "Not Available"} -// -// -// -// - -// -// -// -//
-//
-// ); -// }; - -// export default AddSlotModal; import React, { useState, useEffect } from "react"; import { - Dialog, - DialogActions, - DialogContent, - DialogTitle, - Button, - TextField, - Typography, Box, + Button, + Typography, + Modal, FormControlLabel, Switch, + TextField, MenuItem, Select, - FormControl, InputLabel, + FormControl, } from "@mui/material"; import { useForm } from "react-hook-form"; -import { useDispatch } from "react-redux"; // Import the Redux dispatch +import { useDispatch } from "react-redux"; import { createSlot } from "../../redux/slices/slotSlice.ts"; // Assuming this is your slice +import CloseIcon from "@mui/icons-material/Close"; +import { CustomIconButton } from "../AddUserModal/styled.css"; // Assuming this is for custom styled components const AddSlotModal = ({ open, handleClose }: any) => { + const dispatch = useDispatch(); // Get dispatch from Redux const { register, handleSubmit, @@ -175,17 +27,13 @@ const AddSlotModal = ({ open, handleClose }: any) => { watch, formState: { errors }, } = useForm(); - const dispatch = useDispatch(); // Get dispatch from Redux const [isAvailable, setIsAvailable] = useState(true); const [isDateRange, setIsDateRange] = useState(false); - const [durationUnit, setDurationUnit] = useState("minutes"); const [minEndTime, setMinEndTime] = useState(""); + const [durationUnit, setDurationUnit] = useState("minutes"); // New state for duration unit - // Get today's date in the format yyyy-mm-dd const today = new Date().toISOString().split("T")[0]; - - // Watch the start time value const startHour = watch("startHour"); useEffect(() => { @@ -194,214 +42,256 @@ const AddSlotModal = ({ open, handleClose }: any) => { } }, [startHour]); -const onSubmit = (data: any) => { - const { - date, - startingDate, - endingDate, - startHour, - endHour, - duration, - - } = data; + const onSubmit = (data: any) => { + const { date, startingDate, endingDate, startHour, endHour, duration } = + data; - const payload = isDateRange - ? { - startingDate, - endingDate, - startHour, - endHour, - duration: parseInt(duration, 10), - isAvailable, - - } - : { - date, - startHour, - endHour, - duration: parseInt(duration, 10), - isAvailable, - - }; - - dispatch(createSlot(payload)); - reset(); - handleClose(); -}; + const payload = isDateRange + ? { + startingDate, + endingDate, + startHour, + endHour, + duration: parseInt(duration, 10), + durationUnit, // Include the duration unit (minutes or hours) + isAvailable, + } + : { + date, + startHour, + endHour, + duration: parseInt(duration, 10), + durationUnit, // Include the duration unit (minutes or hours) + isAvailable, + }; + dispatch(createSlot(payload)); + reset(); + handleClose(); + }; return ( - - Add EV Slot - -
- setIsDateRange(!isDateRange)} - /> - } - label="Select Date Range" - /> - {isDateRange ? ( - <> - - Start Date - - - value >= today || - "Start date cannot be in the past", - })} - type="date" - fullWidth - margin="normal" - error={!!errors.startingDate} - helperText={errors.startingDate?.message} - inputProps={{ min: today }} - /> - - End Date - - - value >= today || - "End date cannot be in the past", - })} - type="date" - fullWidth - margin="normal" - error={!!errors.endingDate} - helperText={errors.endingDate?.message} - inputProps={{ min: today }} - /> - - ) : ( - <> - - Date - - - value >= today || - "Date cannot be in the past", - })} - type="date" - fullWidth - margin="normal" - error={!!errors.date} - helperText={errors.date?.message} - inputProps={{ min: today }} - /> - - )} - - Start Hour + { + if (reason === "backdropClick") { + return; + } + handleClose(); + }} + aria-labelledby="add-slot-modal" + > + + {/* Header */} + + + Add Slot - - - End Hour - - - value > startHour || - "End hour must be after start hour", - })} - type="time" - fullWidth - margin="normal" - error={!!errors.endHour} - helperText={errors.endHour?.message} - inputProps={{ min: minEndTime }} - /> - - Slot Duration - - - + + + + + {/* Horizontal Line */} + + + {/* Date Range Toggle */} + setIsDateRange(!isDateRange)} /> - - - - - - - - - {isAvailable ? "Available" : "Not Available"} + } + label="Select Date Range" + sx={{ + fontWeight: 500, + fontSize: "16px", + margin: 0, + }} + /> + + {/* Date Input Fields */} + {isDateRange ? ( + <> + + Start Date - - - - + + {isAvailable ? "Available" : "Not Available"} + + + + {/* Submit Button */} + + + + + ); }; diff --git a/src/components/AddStationLocation/addStationLocation.tsx b/src/components/AddStationLocation/addStationLocation.tsx index 98d2bed..14581eb 100644 --- a/src/components/AddStationLocation/addStationLocation.tsx +++ b/src/components/AddStationLocation/addStationLocation.tsx @@ -52,7 +52,7 @@ const AddStationLocationModal = ({ helperText={errors.city?.message} /> -