add new changes in station and logo

This commit is contained in:
jaanvi 2025-03-28 14:58:24 +05:30
parent a6928b7db9
commit e038428607
16 changed files with 219 additions and 215 deletions

4
public/Group 14.svg Normal file
View file

@ -0,0 +1,4 @@
<svg width="535" height="226" viewBox="0 0 535 226" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M43.561 68.1C55.753 68.1 65.913 72.3757 74.041 80.927C82.2537 89.4783 86.36 100.019 86.36 112.55C86.36 125.081 82.2537 135.622 74.041 144.173C65.913 152.724 55.753 157 43.561 157H8.255V68.1H43.561ZM43.561 140.236C51.2657 140.236 57.531 137.696 62.357 132.616C67.183 127.451 69.596 120.763 69.596 112.55C69.596 104.337 67.183 97.691 62.357 92.611C57.531 87.4463 51.2657 84.864 43.561 84.864H25.781V140.236H43.561ZM98.7921 68.1H116.318V157H98.7921V68.1ZM220.024 109.248V116.106C220.024 128.806 215.96 139.093 207.832 146.967C199.704 154.841 189.205 158.778 176.336 158.778C162.62 158.778 151.232 154.333 142.173 145.443C133.198 136.468 128.711 125.546 128.711 112.677C128.711 99.723 133.156 88.7587 142.046 79.784C151.02 70.8093 162.112 66.322 175.32 66.322C183.617 66.322 191.195 68.227 198.053 72.037C204.911 75.7623 210.245 80.7577 214.055 87.023L199.069 95.659C196.952 92.0183 193.735 89.055 189.417 86.769C185.183 84.483 180.442 83.34 175.193 83.34C166.726 83.34 159.741 86.134 154.238 91.722C148.819 97.2253 146.11 104.21 146.11 112.677C146.11 121.059 148.861 128.002 154.365 133.505C159.953 138.924 167.319 141.633 176.463 141.633C183.236 141.633 188.824 140.151 193.227 137.188C197.714 134.14 200.762 129.991 202.371 124.742H175.447V109.248H220.024ZM232.489 68.1H250.015V157H232.489V68.1ZM410.998 140.236H448.463V157H393.472V68.1H447.828V84.864H410.998V103.787H444.653V120.297H410.998V140.236ZM482.788 157L452.943 68.1H471.993L493.71 136.426L515.3 68.1H534.477L504.505 157H482.788Z" fill="white"/>
<path d="M374.268 108.459L324.874 94.3623L347.782 14.0969L264.907 117.311L314.302 131.408L291.394 211.673L374.268 108.459Z" fill="#52ACDF"/>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
public/evLogo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB

View file

@ -341,7 +341,7 @@ export default function AddStationModal({
/>
<ListItemText
primary={vehicle.name}
/>
/>
</MenuItem>
))
) : (

View file

@ -83,10 +83,9 @@ interface CustomTableProps {
viewModal: boolean;
setViewModal: Function;
deleteModal: boolean;
handleStatusToggle: (id: string, currentStatus: number) => void;
handleStatusToggle?: (id: string, currentStatus: number) => void;
tableType: string; // Adding tableType prop to change header text dynamically
handleClickOpen: () => void;
//handleDeleteButton: (id: string | number | undefined) => void;
}
const CustomTable: React.FC<CustomTableProps> = ({
@ -108,11 +107,8 @@ const CustomTable: React.FC<CustomTableProps> = ({
const [searchQuery, setSearchQuery] = React.useState("");
const [currentPage, setCurrentPage] = React.useState(1);
const usersPerPage = 10;
const { user, isLoading } = useSelector(
(state: RootState) => state?.profileReducer
);
const { user } = useSelector((state: RootState) => state?.profileReducer);
const open = Boolean(anchorEl);
console.log("Rows", rows);
const handleClick = (event: React.MouseEvent<HTMLElement>, row: Row) => {
setAnchorEl(event.currentTarget);
setSelectedRow(row);
@ -199,7 +195,7 @@ const CustomTable: React.FC<CustomTableProps> = ({
if (selectedRow) {
// Toggle the opposite of current status
const newStatus = selectedRow.statusValue === 1 ? 0 : 1;
handleStatusToggle(selectedRow.id, newStatus);
handleStatusToggle?.(selectedRow.id, newStatus);
}
handleClose();
};
@ -216,7 +212,7 @@ const CustomTable: React.FC<CustomTableProps> = ({
const currentRows = filteredRows.slice(indexOfFirstRow, indexOfLastRow);
const handlePageChange = (
event: React.ChangeEvent<unknown>,
_event: React.ChangeEvent<unknown>,
value: number
) => {
setCurrentPage(value);
@ -241,24 +237,30 @@ const CustomTable: React.FC<CustomTableProps> = ({
}}
>
{/* Dynamic title based on the page type */}
{tableType === "admin"
? "Admin"
: tableType === "role"
? "Roles"
: tableType === "user"
? "Users"
: tableType === "manager"
? "Managers"
: tableType === "vehicle"
? "Vehicles"
: tableType === "station"
? "Charging Station"
: tableType === "booking"
? "Booking"
: tableType === "slots"
? "Slot"
: "List"}
{(() => {
switch (tableType) {
case "admin":
return "Admin";
case "role":
return "Roles";
case "user":
return "Users";
case "manager":
return "Managers";
case "vehicle":
return "Vehicles";
case "station":
return "Charging Station";
case "booking":
return "Booking";
case "slots":
return "Slot";
default:
return "List";
}
})()}
</Typography>
{/* Search & Buttons Section */}
<Box
sx={{
@ -324,23 +326,28 @@ const CustomTable: React.FC<CustomTableProps> = ({
onClick={() => handleClickOpen()}
>
Add{" "}
{tableType === "admin"
? "Admin"
: tableType === "role"
? "Role"
: tableType === "user"
? "User"
: tableType === "manager"
? "Manager"
: tableType === "vehicle"
? "Vehicle"
: tableType === "station"
? "Charging Station"
: tableType === "booking"
? "Booking"
: tableType === "slots"
? "Slot"
: "Item"}
{(() => {
switch (tableType) {
case "admin":
return "Admin";
case "role":
return "Role";
case "user":
return "User";
case "manager":
return "Manager";
case "vehicle":
return "Vehicle";
case "station":
return "Charging Station";
case "booking":
return "Booking";
case "slots":
return "Slot";
default:
return "Item";
}
})()}
</Button>
)}
</Box>

View file

@ -14,11 +14,19 @@ import {
CustomIconButton,
CustomTextField,
} from "../AddEditUserModel/styled.css.tsx"; // Custom styled components
import { AppDispatch } from "../../redux/store/store.ts";
interface EditManagerModalProps {
open: boolean;
handleClose: () => void;
editRow: any; // Manager data including id
handleUpdate: (
id: string,
name: string,
email: string,
phone: string,
stationId: string
) => Promise<void>;
editRow: any;
}
interface FormData {
@ -33,7 +41,7 @@ const EditManagerModal: React.FC<EditManagerModalProps> = ({
handleClose,
editRow,
}) => {
const dispatch = useDispatch(); // Use dispatch to send Redux actions
const dispatch = useDispatch<AppDispatch>();
const {
control,
handleSubmit,
@ -74,7 +82,7 @@ const EditManagerModal: React.FC<EditManagerModalProps> = ({
email: data.email,
phone: data.phone,
stationId: data.stationId,
},
})
).unwrap(); // Ensure that it throws an error if the update fails

View file

@ -14,10 +14,17 @@ import {
CustomIconButton,
CustomTextField,
} from "../AddEditUserModel/styled.css.tsx"; // Custom styled components
import { AppDispatch } from "../../redux/store/store.ts";
interface EditSlotModalProps {
open: boolean;
handleClose: () => void;
handleUpdate: (
id: string,
startTime: string,
endTime: string,
isAvailable: boolean
) => Promise<void>;
editRow: any; // Slot data including id
}
@ -33,7 +40,7 @@ const EditSlotModal: React.FC<EditSlotModalProps> = ({
handleClose,
editRow,
}) => {
const dispatch = useDispatch(); // Use dispatch to send Redux actions
const dispatch = useDispatch<AppDispatch>();
const {
control,
handleSubmit,
@ -54,13 +61,11 @@ const EditSlotModal: React.FC<EditSlotModalProps> = ({
editRow?.isAvailable || false
);
// Set values if editRow is provided
useEffect(() => {
if (editRow) {
// setValue("date", editRow.date);
setValue("startTime", editRow.startTime);
setValue("endTime", editRow.endTime);
setIsAvailable(editRow.isAvailable); // Set the initial availability correctly
setIsAvailable(editRow.isAvailable);
} else {
reset();
}
@ -68,10 +73,10 @@ const EditSlotModal: React.FC<EditSlotModalProps> = ({
const onSubmit = async (data: FormData) => {
if (editRow) {
setLoading(true); // Start loading
setLoading(true);
try {
// Convert boolean availability to 1/0
const availabilityStatus = isAvailable ? true : false;
await dispatch(
@ -81,9 +86,7 @@ const EditSlotModal: React.FC<EditSlotModalProps> = ({
endTime: data.endTime,
isAvailable: availabilityStatus,
})
).unwrap(); // Ensure that it throws an error if the update fails
// Refresh the list after updating the slot
).unwrap();
dispatch(fetchAvailableSlots());
handleClose(); // Close modal on success
reset(); // Reset form fields after submit

View file

@ -57,7 +57,6 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
handleSubmit,
setValue,
reset,
watch,
formState: { errors },
} = useForm<FormData>({
defaultValues: {
@ -77,7 +76,7 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
(state: RootState) => state.vehicleReducer.vehicleBrands
);
const [selectedBrand, setSelectedBrand] = useState<string | "">("");
const [selectedBrands, setSelectedBrands] = useState<string[]>([]);
const [selectedVehicles, setSelectedVehicles] = useState<string[]>([]);
useEffect(() => {
@ -98,11 +97,19 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
}
}, [editRow, setValue, reset]);
const filteredVehicles = vehicles.filter(
(vehicle) => vehicle.company === selectedBrand
// Filter vehicles based on selected brands
const filteredVehicles = vehicles.filter((vehicle) =>
selectedBrands.includes(vehicle.company)
);
// Handle changes in vehicle brand selection
const handleBrandChange = (
event: React.ChangeEvent<{ value: unknown }>
) => {
setSelectedBrands(event.target.value as string[]);
};
// Handle changes in vehicle selection
const handleCheckboxChange = (
event: React.ChangeEvent<{ value: unknown }>
) => {
@ -125,7 +132,7 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
);
handleClose();
reset();
setSelectedBrand(""); // Reset brand after submit
setSelectedBrands([]); // Reset brands after submit
setSelectedVehicles([]); // Reset selected vehicles
};
@ -285,7 +292,7 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
</Box>
</Box>
{/* Vehicle Brand Selection */}
{/* Vehicle Brand Selection with Checkboxes */}
<Box sx={{ display: "flex", gap: 2 }}>
<Box
sx={{
@ -295,16 +302,15 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
}}
>
<Typography variant="body2" fontWeight={500}>
Select Vehicle Brand
Select Vehicle Brands
</Typography>
<FormControl fullWidth>
<InputLabel>Choose Brand</InputLabel>
<Select
value={selectedBrand}
onChange={(e) =>
setSelectedBrand(e.target.value)
}
label="Choose Brand"
multiple
value={selectedBrands}
onChange={handleBrandChange}
label="Choose Brands"
>
{vehicleBrands.length > 0 ? (
vehicleBrands.map((brand) => (
@ -312,7 +318,14 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
key={brand.id}
value={brand.id}
>
{brand.name}
<Checkbox
checked={selectedBrands.includes(
brand.id
)}
/>
<ListItemText
primary={brand.name}
/>
</MenuItem>
))
) : (
@ -323,8 +336,6 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
</Select>
</FormControl>
</Box>
{/* Vehicle Selection with Checkboxes */}
<Box
sx={{
display: "flex",
@ -377,6 +388,8 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
</Box>
</Box>
{/* Submit Button */}
<Box
sx={{ display: "flex", justifyContent: "flex-end", mt: 3 }}

View file

@ -7,6 +7,7 @@ import CloseIcon from "@mui/icons-material/Close";
type Props = {
open: boolean;
setViewModal: Function;
handleView: (id: string | undefined) => void;
id?: string;
};

View file

@ -64,15 +64,25 @@ export default function SideMenu() {
pl: 2,
}}
>
<Avatar
<img
src="/evLogo.png"
alt="Logo"
src="/Digilogo.png"
sx={{
width: "50px",
height: "50px",
style={{
justifyContent: "center",
width: open ? "200px" : "60px", // Adjust width depending on open state
height: "auto",
transition: "width 0.5s ease", // Smooth transition for width change
}}
/>
<Box
{/* <Avatar
alt="Logo"
src="/evLogo.png"
sx={{
width: "100%",
height: "100%",
}}
/> */}
{/* <Box
sx={{
display: open ? "flex" : "none",
flexDirection: "column",
@ -81,7 +91,7 @@ export default function SideMenu() {
textAlign: "center",
}}
>
{/* Digi EV Text Section */}
<Typography
variant="body2"
color="#D9D8D8"
@ -95,7 +105,7 @@ export default function SideMenu() {
<Typography variant="subtitle2" color="#D9D8D8">
{user?.userType || "N/A"}
</Typography>
</Box>
</Box> */}
</Box>
<Box

View file

@ -23,6 +23,7 @@ import { useNavigate } from "react-router-dom";
import { Visibility, VisibilityOff } from "@mui/icons-material";
import { Card, SignInContainer } from "./styled.css.tsx";
import { CustomIconButton } from "../../../components/AddEditUserModel/styled.css.tsx";
import { AppDispatch } from "../../../redux/store/store.ts";
interface ILoginForm {
email: string;
password: string;
@ -37,7 +38,7 @@ export default function Login(props: { disableCustomTheme?: boolean }) {
handleSubmit,
formState: { errors, isValid },
} = useForm<ILoginForm>({ mode: "onChange" });
const dispatch = useDispatch();
const dispatch = useDispatch<AppDispatch>();
const router = useNavigate();
const handleClickOpen = () => {
@ -104,11 +105,11 @@ export default function Login(props: { disableCustomTheme?: boolean }) {
}}
>
<img
src="/DigiEVLogo.png"
src="/evLogo.png"
alt="Logo"
style={{
justifyContent: "center",
width: "250px",
width: "180px",
height: "auto",
}}
/>

View file

@ -1,5 +1,4 @@
import React, { useEffect, useState } from "react";
import { Box, Button, TextField, Typography } from "@mui/material";
import { useEffect, useState } from "react";
import CustomTable, { Column } from "../../components/CustomTable";
import { useDispatch, useSelector } from "react-redux";
import { RootState, AppDispatch } from "../../redux/store/store";
@ -15,12 +14,10 @@ import EditSlotModal from "../../components/EditSlotModal";
export default function EVSlotList() {
const [addModalOpen, setAddModalOpen] = useState<boolean>(false);
const [editModalOpen, setEditModalOpen] = useState<boolean>(false);
const [editRow, setEditRow] = useState<any>(null);
const { reset } = useForm();
const [deleteModal, setDeleteModal] = useState<boolean>(false);
const [viewModal, setViewModal] = useState<boolean>(false);
const [rowData, setRowData] = useState<any | null>(null);
const [searchTerm, setSearchTerm] = useState("");
const dispatch = useDispatch<AppDispatch>();
const availableSlots = useSelector(
(state: RootState) => state?.slotReducer.availableSlots
@ -55,29 +52,34 @@ export default function EVSlotList() {
console.error("Error adding slot", error);
}
};
const handleUpdate = async (
id: string,
startTime: string,
endTime: string,
isAvailable: boolean
) => {
try {
await dispatch(
updateSlot({
id, // Pass id separately, not inside slotData
startTime,
endTime,
isAvailable,
})
).unwrap(); // Ensure you unwrap the result so you can handle the error properly
await dispatch(fetchAvailableSlots()); // Refresh the list after update
handleCloseModal(); // Close modal after update
} catch (error) {
console.error("Update failed", error);
}
};
const handleUpdate = async (
id: string,
startTime: string,
endTime: string,
isAvailable: boolean
) => {
try {
const formattedStartTime = dayjs(startTime, "HH:mm").format(
"HH:mm"
);
const formattedEndTime = dayjs(endTime, "HH:mm").format("HH:mm");
await dispatch(
updateSlot({
id,
startTime: formattedStartTime,
endTime: formattedEndTime,
isAvailable,
})
).unwrap();
await dispatch(fetchAvailableSlots());
handleCloseModal();
} catch (error) {
console.error("Update failed", error);
}
};
const slotColumns: Column[] = [
{ id: "srno", label: "Sr No" },
@ -90,15 +92,12 @@ const handleUpdate = async (
{ id: "action", label: "Action", align: "center" },
];
// Make sure dayjs is imported
const slotRows = availableSlots?.length
? availableSlots.map((slot, index) => {
const formattedDate = dayjs(slot?.date).format("YYYY-MM-DD");
const startTime = dayjs(slot?.startTime).format("HH:mm");
const endTime = dayjs(slot?.endTime).format("HH:mm");
console.log("first", startTime);
return {
srno: index + 1,
id: slot?.id ?? "NA",

View file

@ -9,11 +9,9 @@ import {
managerList,
addManager,
updateManager,
deleteManager,
} from "../../redux/slices/managerSlice";
import { useForm } from "react-hook-form";
export default function ManagerList() {
const [addModalOpen, setAddModalOpen] = useState<boolean>(false);
const [editModalOpen, setEditModalOpen] = useState<boolean>(false);
@ -67,7 +65,7 @@ export default function ManagerList() {
// Handle updating an existing manager
const handleUpdate = async (
id: number,
id: string,
name: string,
email: string,
phone: string,
@ -101,65 +99,29 @@ export default function ManagerList() {
{ id: "registeredAddress", label: "Station Location" },
{ id: "action", label: "Action", align: "center" },
];
// const categoryColumns: Column[] = [
// { id: "srno", label: "Sr No" },
// { id: "name", label: "Name" },
// { id: "email", label: "Email" },
// { id: "phone", label: "Phone" },
// { id: "stationName", label: "Station Name" }, // Added station name column
// { id: "stationAddress", label: "Station Location" }, // Added station address column
// { id: "action", label: "Action", align: "center" },
// ];
// Filter managers based on search term
const filteredManagers = managers?.filter(
(manager) =>
manager.name?.toLowerCase().includes(searchTerm.toLowerCase()) ||
manager.email?.toLowerCase().includes(searchTerm.toLowerCase()) ||
manager.phone?.toLowerCase().includes(searchTerm.toLowerCase())
);
// Format rows to display manager details
// const categoryRows = filteredManagers?.length
// ? filteredManagers?.map(
// (
// manager: {
// id: number;
// name: string;
// email: string;
// phone: string;
// },
// index: number
// ) => ({
// id: manager?.id,
// srno: index + 1,
// name: manager?.name,
// email: manager?.email,
// phone: manager.phone ?? "NA",
// })
// )
// : [];
const categoryRows = filteredManagers?.length
? filteredManagers.map((manager, index) => {
const station = manager?.chargingStation; // Correct access to the ChargingStation data
return {
id: manager.id,
srno: index + 1,
name: manager.name,
email: manager.email,
phone: manager.phone ?? "NA",
stationName: station?.name ?? "NA", // Corrected station name
registeredAddress: station?.registeredAddress ?? "NA", // Corrected station address
};
})
: [];
// const filteredManagers = managers?.filter(
// (manager) =>
// manager.name?.toLowerCase().includes(searchTerm.toLowerCase()) ||
// manager.email?.toLowerCase().includes(searchTerm.toLowerCase()) ||
// manager.phone?.toLowerCase().includes(searchTerm.toLowerCase())
// );
const categoryRows = managers?.length
? managers.map((manager, index) => {
const station = manager?.chargingStation; // Correct access to the ChargingStation data
return {
id: manager.id,
srno: index + 1,
name: manager.name,
email: manager.email,
phone: manager.phone ?? "NA",
stationName: station?.name ?? "NA", // Corrected station name
registeredAddress: station?.registeredAddress ?? "NA", // Corrected station address
};
})
: [];
return (
<>

View file

@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import { useEffect, useState } from "react";
import { useForm } from "react-hook-form";
import CustomTable, { Column } from "../../components/CustomTable";
import { RootState } from "../../redux/reducers";
@ -15,13 +15,11 @@ import EditVehicleModal from "../../components/EditVehicleModal";
export default function VehicleList() {
const [addModalOpen, setAddModalOpen] = useState<boolean>(false);
const [editModalOpen, setEditModalOpen] = useState<boolean>(false);
const [editRow, setEditRow] = useState<any>(null);
const { reset } = useForm();
const [deleteModal, setDeleteModal] = useState<boolean>(false);
const [viewModal, setViewModal] = useState<boolean>(false);
const [rowData, setRowData] = useState<any | null>(null);
const [searchTerm, setSearchTerm] = useState("");
const dispatch = useDispatch<AppDispatch>();
const vehicles = useSelector(
(state: RootState) => state.vehicleReducer.vehicles
@ -32,7 +30,7 @@ export default function VehicleList() {
}, [dispatch]);
const handleClickOpen = () => {
setRowData(null); // Reset row data when opening for new admin
setRowData(null);
setAddModalOpen(true);
};
@ -44,7 +42,7 @@ export default function VehicleList() {
};
const handleAddVehicle = async (data: {
vehicleName: string;
name: string;
company: string;
modelName: string;
chargeType: string;
@ -60,7 +58,7 @@ export default function VehicleList() {
};
const handleUpdate = async (
id: number,
id: string,
name: string,
company: string,
modelName: string,
@ -95,24 +93,24 @@ export default function VehicleList() {
{ id: "action", label: "Action", align: "center" },
];
const filteredVehicles = vehicles?.filter(
(vehicle) =>
vehicle.name?.toLowerCase().includes(searchTerm.toLowerCase()) ||
vehicle.company?.toLowerCase().includes(searchTerm.toLowerCase()) ||
vehicle.modelName
?.toLowerCase()
.includes(searchTerm.toLowerCase()) ||
vehicle.chargeType
?.toLowerCase()
.includes(searchTerm.toLowerCase()) ||
vehicle.imageUrl?.toLowerCase().includes(searchTerm.toLowerCase())
);
// const filteredVehicles = vehicles?.filter(
// (vehicle) =>
// vehicle.name?.toLowerCase().includes(searchTerm.toLowerCase()) ||
// vehicle.company?.toLowerCase().includes(searchTerm.toLowerCase()) ||
// vehicle.modelName
// ?.toLowerCase()
// .includes(searchTerm.toLowerCase()) ||
// vehicle.chargeType
// ?.toLowerCase()
// .includes(searchTerm.toLowerCase()) ||
// vehicle.imageUrl?.toLowerCase().includes(searchTerm.toLowerCase())
// );
const categoryRows = filteredVehicles?.length
? filteredVehicles?.map(
const categoryRows = vehicles?.length
? vehicles?.map(
(
vehicle: {
id: number;
id: string;
name: string;
company: string;
modelName: string;
@ -132,8 +130,6 @@ export default function VehicleList() {
)
: [];
return (
<>
<CustomTable
@ -159,7 +155,6 @@ export default function VehicleList() {
handleUpdate={handleUpdate}
editRow={rowData}
/>
</>
);
}

View file

@ -8,7 +8,7 @@ interface VehicleBrand {
}
interface Vehicle {
brandId: string;
brandId?: string;
id: string;
name: string;
company: string;
@ -50,10 +50,8 @@ export const fetchVehicleBrands = createAsyncThunk<
}
});
export const vehicleList = createAsyncThunk<
Vehicle,
Vehicle[],
void,
{ rejectValue: string }
>("fetchVehicles", async (_, { rejectWithValue }) => {
@ -180,12 +178,9 @@ const vehicleSlice = createSlice({
state.vehicles.push(action.payload);
}
)
.addCase(
addVehicle.rejected,
(state, action: PayloadAction<string | undefined>) => {
state.loading = false;
}
)
.addCase(addVehicle.rejected, (state) => {
state.loading = false;
})
.addCase(updateVehicle.pending, (state) => {
state.loading = true;
})

View file

@ -6,12 +6,12 @@ import { toast } from "sonner";
interface Manager {
Manager: any;
id: number;
id: string;
name: string;
email: string;
phone: string;
stationId: string;
chargingStation:string;
chargingStation:{name:string, registeredAddress:string};
}
interface ManagerState {
@ -74,7 +74,7 @@ export const addManager = createAsyncThunk<
// Update Manager (Async Thunk)
export const updateManager = createAsyncThunk<
Manager,
{ id: number; managerData: Manager },
{ id: string; managerData: Manager },
{ rejectValue: string }
>("updateManager", async ({ id, managerData }, { rejectWithValue }) => {
if (!id) {

View file

@ -88,17 +88,23 @@ export const createSlot = createAsyncThunk<
// Update Slot details
export const updateSlot = createAsyncThunk<
Slot,
{ id: string; startTime: string; endTime: string; isAvailable: boolean }, // Argument type (slot update data)
{
id: string;
startTime: string;
endTime: string;
isAvailable: boolean;
},
{ rejectValue: string }
>("slots/updateSlot", async ({ id, ...slotData }, { rejectWithValue }) => {
try {
const response = await http.patch(
`/update-availability/${id}`,
slotData // slotData is being sent here, but we should ensure its structure is correct
);
const response = await http.patch(`/update-availability/${id}`, {
...slotData,
// Ensure data matches exactly what backend expects
startHour: slotData.startTime,
endHour: slotData.endTime,
});
toast.success("Slot updated successfully");
console.log("Slots", response.data.data);
return response.data.data; // Return updated slot data
return response.data.data;
} catch (error: any) {
toast.error("Error updating the slot: " + error?.message);
return rejectWithValue(