dev-jaanvi #1
|
@ -14,7 +14,7 @@ import { useForm, Controller } from "react-hook-form";
|
|||
import {
|
||||
CustomIconButton,
|
||||
CustomTextField,
|
||||
} from "../AddUserModel/styled.css.tsx";
|
||||
} from "../AddEditUserModel/styled.css.tsx";
|
||||
|
||||
//By Jaanvi : Edit Model :: 11-feb-25
|
||||
interface AddEditCategoryModalProps {
|
||||
|
|
|
@ -30,7 +30,6 @@ interface AddUserModalProps {
|
|||
id: string,
|
||||
name: string,
|
||||
email: string,
|
||||
password: string,
|
||||
phone: string,
|
||||
|
||||
) => void;
|
||||
|
@ -50,24 +49,24 @@ const AddUserModal: React.FC<AddUserModalProps> = ({
|
|||
handleSubmit,
|
||||
formState: { errors },
|
||||
reset,
|
||||
setValue,
|
||||
} = useForm<FormData>({
|
||||
defaultValues: {
|
||||
name: "",
|
||||
email: "",
|
||||
password: "",
|
||||
phone: "",
|
||||
},
|
||||
});
|
||||
// useEffect(() => {
|
||||
// if (editRow) {
|
||||
// setValue("name", editRow.name);
|
||||
// setValue("email", editRow.email);
|
||||
// setValue("password", editRow.password);
|
||||
// setValue("phone", editRow.phone);
|
||||
// } else {
|
||||
// reset();
|
||||
// }
|
||||
// }, [editRow, setValue, reset]);
|
||||
|
||||
useEffect(() => {
|
||||
if (editRow) {
|
||||
setValue("name", editRow.name);
|
||||
setValue("email", editRow.email);
|
||||
setValue("phone", editRow.phone);
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
}, [editRow, setValue,reset]);
|
||||
|
||||
const onSubmit = (data: FormData) => {
|
||||
if (editRow) {
|
||||
|
@ -75,7 +74,6 @@ const AddUserModal: React.FC<AddUserModalProps> = ({
|
|||
editRow.id,
|
||||
data.name,
|
||||
data.email,
|
||||
data.password,
|
||||
data.phone
|
||||
);
|
||||
} else {
|
||||
|
@ -234,7 +232,7 @@ const AddUserModal: React.FC<AddUserModalProps> = ({
|
|||
|
||||
{/* Second Row - Two Inputs */}
|
||||
<Box sx={{ display: "flex", gap: 2 }}>
|
||||
<Box
|
||||
{!editRow && ( <Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
|
@ -304,7 +302,7 @@ const AddUserModal: React.FC<AddUserModalProps> = ({
|
|||
/>
|
||||
)}
|
||||
/>
|
||||
</Box>
|
||||
</Box>)}
|
||||
<Box
|
||||
sx={{
|
||||
display: "flex",
|
||||
|
@ -380,3 +378,7 @@ const AddUserModal: React.FC<AddUserModalProps> = ({
|
|||
|
||||
export default AddUserModal;
|
||||
|
||||
function setValue(arg0: string, name: any) {
|
||||
throw new Error("Function not implemented.");
|
||||
}
|
||||
|
|
@ -14,7 +14,7 @@ import { addManager, managerList } from "../../redux/slices/managerSlice";
|
|||
import {
|
||||
CustomIconButton,
|
||||
CustomTextField,
|
||||
} from "../AddUserModel/styled.css.tsx";
|
||||
} from "../AddEditUserModel/styled.css.tsx";
|
||||
import React, { useState, useRef } from "react";
|
||||
|
||||
export default function AddManagerModal({
|
||||
|
@ -38,10 +38,9 @@ export default function AddManagerModal({
|
|||
name: data.name,
|
||||
email: data.email,
|
||||
phone: data.phone,
|
||||
registeredAddress: data.registeredAddress,
|
||||
password: data.password,
|
||||
stationId: data.stationId, // Send stationId here
|
||||
roleName: "Manager", // You can replace this with dynamic role if needed
|
||||
|
||||
};
|
||||
|
||||
try {
|
||||
|
@ -274,26 +273,6 @@ export default function AddManagerModal({
|
|||
/>
|
||||
</Box>
|
||||
|
||||
{/* Registered Address */}
|
||||
<Box sx={{ flex: 1 }}>
|
||||
<Typography variant="body2" fontWeight={500}>
|
||||
Station Location
|
||||
</Typography>
|
||||
<CustomTextField
|
||||
fullWidth
|
||||
placeholder="Enter Registered Address"
|
||||
size="small"
|
||||
error={!!errors.registeredAddress}
|
||||
helperText={
|
||||
errors.registeredAddress
|
||||
? errors.registeredAddress.message
|
||||
: ""
|
||||
}
|
||||
{...register("registeredAddress", {
|
||||
required: "Registered Address is required",
|
||||
})}
|
||||
/>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
{/* Submit Button */}
|
||||
|
|
|
@ -4,7 +4,7 @@ import CloseIcon from "@mui/icons-material/Close";
|
|||
import {
|
||||
CustomIconButton,
|
||||
CustomTextField,
|
||||
} from "../AddUserModel/styled.css.tsx"; // Assuming custom styled components
|
||||
} from "../AddEditUserModel/styled.css.tsx"; // Assuming custom styled components
|
||||
|
||||
export default function AddStationModal({
|
||||
open,
|
||||
|
@ -125,7 +125,7 @@ export default function AddStationModal({
|
|||
</Typography>
|
||||
<CustomTextField
|
||||
fullWidth
|
||||
placeholder="Enter Registered Address"
|
||||
placeholder="Enter Charging Station Address"
|
||||
size="small"
|
||||
error={!!errors.registeredAddress}
|
||||
helperText={
|
||||
|
|
|
@ -6,7 +6,10 @@ import {
|
|||
Modal,
|
||||
} from "@mui/material";
|
||||
import CloseIcon from "@mui/icons-material/Close";
|
||||
import { CustomIconButton, CustomTextField } from "../AddUserModel/styled.css.tsx";
|
||||
import {
|
||||
CustomIconButton,
|
||||
CustomTextField,
|
||||
} from "../AddEditUserModel/styled.css.tsx";
|
||||
export default function AddVehicleModal({
|
||||
open,
|
||||
handleClose,
|
||||
|
|
|
@ -30,7 +30,7 @@ import VehicleViewModal from "../Modals/VehicleViewModal";
|
|||
|
||||
import SearchIcon from "@mui/icons-material/Search";
|
||||
import TuneIcon from "@mui/icons-material/Tune";
|
||||
import { CustomIconButton } from "../AddUserModel/styled.css.tsx";
|
||||
import { CustomIconButton } from "../AddEditUserModel/styled.css.tsx";
|
||||
import ManagerViewModal from "../Modals/ViewManagerModal";
|
||||
import UserViewModal from "../Modals/UserViewModal/index.tsx";
|
||||
import { deleteUser, userList } from "../../redux/slices/userSlice.ts";
|
||||
|
|
|
@ -13,7 +13,7 @@ import { managerList, updateManager } from "../../redux/slices/managerSlice"; //
|
|||
import {
|
||||
CustomIconButton,
|
||||
CustomTextField,
|
||||
} from "../AddUserModel/styled.css.tsx"; // Custom styled components
|
||||
} from "../AddEditUserModel/styled.css.tsx"; // Custom styled components
|
||||
|
||||
interface EditManagerModalProps {
|
||||
open: boolean;
|
||||
|
@ -25,6 +25,7 @@ interface FormData {
|
|||
name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
stationId: string;
|
||||
}
|
||||
|
||||
const EditManagerModal: React.FC<EditManagerModalProps> = ({
|
||||
|
@ -44,6 +45,7 @@ const EditManagerModal: React.FC<EditManagerModalProps> = ({
|
|||
name: "",
|
||||
email: "",
|
||||
phone: "",
|
||||
stationId: "",
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -55,6 +57,7 @@ const EditManagerModal: React.FC<EditManagerModalProps> = ({
|
|||
setValue("name", editRow.name);
|
||||
setValue("email", editRow.email);
|
||||
setValue("phone", editRow.phone);
|
||||
setValue("stationId", editRow.stationId);
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
|
@ -70,6 +73,8 @@ const EditManagerModal: React.FC<EditManagerModalProps> = ({
|
|||
name: data.name,
|
||||
email: data.email,
|
||||
phone: data.phone,
|
||||
stationId: data.stationId,
|
||||
|
||||
},
|
||||
})
|
||||
).unwrap(); // Ensure that it throws an error if the update fails
|
||||
|
@ -212,6 +217,26 @@ const EditManagerModal: React.FC<EditManagerModalProps> = ({
|
|||
)}
|
||||
/>
|
||||
</Box>
|
||||
{/* <Box sx={{ flex: "1 1 48%" }}>
|
||||
<Typography variant="body2" fontWeight={500} mb={0.5}>
|
||||
StationId
|
||||
</Typography>
|
||||
<Controller
|
||||
name="stationId"
|
||||
control={control}
|
||||
rules={{ required: "StationId is required" }}
|
||||
render={({ field }) => (
|
||||
<CustomTextField
|
||||
{...field}
|
||||
fullWidth
|
||||
placeholder="Enter Station Id"
|
||||
size="small"
|
||||
error={!!errors.stationId}
|
||||
helperText={errors.stationId?.message}
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Box> */}
|
||||
</Box>
|
||||
|
||||
{/* Submit Button */}
|
||||
|
@ -240,5 +265,4 @@ const EditManagerModal: React.FC<EditManagerModalProps> = ({
|
|||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default EditManagerModal;
|
||||
export default EditManagerModal;
|
|
@ -5,7 +5,7 @@ import { useForm, Controller } from "react-hook-form";
|
|||
import {
|
||||
CustomIconButton,
|
||||
CustomTextField,
|
||||
} from "../AddUserModel/styled.css.tsx";
|
||||
} from "../AddEditUserModel/styled.css.tsx";
|
||||
|
||||
interface EditStationModalProps {
|
||||
open: boolean;
|
||||
|
@ -15,7 +15,7 @@ interface EditStationModalProps {
|
|||
name: string,
|
||||
registeredAddress: string,
|
||||
totalSlots: number,
|
||||
imageUrl: string
|
||||
status: number
|
||||
) => void;
|
||||
editRow: any;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ interface FormData {
|
|||
name: string;
|
||||
registeredAddress: string;
|
||||
totalSlots: number;
|
||||
imageUrl: string;
|
||||
status: number;
|
||||
}
|
||||
|
||||
const EditStationModal: React.FC<EditStationModalProps> = ({
|
||||
|
@ -44,7 +44,7 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
|
|||
name: "",
|
||||
registeredAddress: "",
|
||||
totalSlots: 0,
|
||||
imageUrl: "",
|
||||
status: 1,
|
||||
},
|
||||
});
|
||||
|
||||
|
@ -54,7 +54,7 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
|
|||
setValue("name", editRow.name);
|
||||
setValue("registeredAddress", editRow.registeredAddress);
|
||||
setValue("totalSlots", editRow.totalSlots);
|
||||
setValue("imageUrl", editRow.imageUrl);
|
||||
setValue("status", editRow.number);
|
||||
} else {
|
||||
reset();
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
|
|||
data.name,
|
||||
data.registeredAddress,
|
||||
data.totalSlots,
|
||||
data.imageUrl
|
||||
data.status
|
||||
);
|
||||
}
|
||||
handleClose(); // Close the modal
|
||||
|
|
|
@ -11,7 +11,7 @@ import { updateVehicle } from "../../redux/slices/VehicleSlice";
|
|||
import {
|
||||
CustomIconButton,
|
||||
CustomTextField,
|
||||
} from "../AddUserModel/styled.css.tsx";
|
||||
} from "../AddEditUserModel/styled.css.tsx";
|
||||
interface EditVehicleModalProps {
|
||||
open: boolean;
|
||||
handleClose: () => void;
|
||||
|
|
|
@ -35,6 +35,7 @@ export default function ManagerViewModal({ open, setViewModal, id }: Props) {
|
|||
|
||||
useEffect(() => {
|
||||
if (id) {
|
||||
|
||||
const manager = managers.find((manager) => manager.id === id);
|
||||
setSelectedManager(manager || null);
|
||||
}
|
||||
|
@ -107,7 +108,7 @@ export default function ManagerViewModal({ open, setViewModal, id }: Props) {
|
|||
</Grid>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant="body1">
|
||||
<strong>Registered Address:</strong>
|
||||
<strong>Station Location:</strong>
|
||||
<Typography variant="body2">
|
||||
{selectedManager.registeredAddress}
|
||||
</Typography>
|
||||
|
|
|
@ -107,7 +107,8 @@ export default function ViewModal({ open, setViewModal, id }: Props) {
|
|||
<strong>Address:</strong>
|
||||
|
||||
<Typography variant="body2">
|
||||
{selectedAdmin.registeredAddress ?? "N/A"}
|
||||
{selectedAdmin?.Admins?.[0]
|
||||
?.registeredAddress ?? "N/A"}
|
||||
</Typography>
|
||||
</Typography>
|
||||
</Grid>
|
||||
|
|
|
@ -20,9 +20,7 @@ import { useDispatch, useSelector } from "react-redux";
|
|||
import { createRole } from "../../redux/slices/roleSlice"; // Import the createRole action
|
||||
import { AppDispatch, RootState } from "../../redux/store/store"; // Assuming this is the path to your store file
|
||||
import { toast } from "sonner";
|
||||
import {
|
||||
CustomTextField,
|
||||
} from "../../components/AddUserModel/styled.css.tsx";
|
||||
import { CustomTextField } from "../../components/AddEditUserModel/styled.css.tsx";
|
||||
// Define the data structure for permission
|
||||
interface Permission {
|
||||
module: string;
|
||||
|
|
|
@ -69,7 +69,6 @@ export default function AdminList() {
|
|||
email,
|
||||
phone,
|
||||
registeredAddress,
|
||||
|
||||
})
|
||||
);
|
||||
await dispatch(adminList());
|
||||
|
@ -86,40 +85,30 @@ export default function AdminList() {
|
|||
{ id: "registeredAddress", label: "Address" },
|
||||
{ id: "action", label: "Action", align: "center" },
|
||||
];
|
||||
// const filteredAdmins = admins?.filter(
|
||||
// (admin) =>
|
||||
// admin.name.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
// admin.email.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
// admin.phone.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
||||
// admin.registeredAddress
|
||||
// .toLowerCase()
|
||||
// .includes(searchTerm.toLowerCase())
|
||||
// );
|
||||
|
||||
const categoryRows = admins?.map(
|
||||
(
|
||||
admin: {
|
||||
id: string;
|
||||
name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
registeredAddress: string;
|
||||
},
|
||||
index: number
|
||||
) => ({
|
||||
id: admin?.id,
|
||||
srno: index + 1,
|
||||
name: admin?.name,
|
||||
email: admin?.email,
|
||||
phone: admin?.phone,
|
||||
registeredAddress: admin?.registeredAddress || "NA",
|
||||
})
|
||||
)
|
||||
;
|
||||
(
|
||||
admin: {
|
||||
id: string;
|
||||
name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
Admins: { registeredAddress: string }[]; // Adjusted to support array of Admins
|
||||
},
|
||||
index: number
|
||||
) => ({
|
||||
id: admin?.id,
|
||||
srno: index + 1,
|
||||
name: admin?.name,
|
||||
email: admin?.email,
|
||||
phone: admin?.phone,
|
||||
registeredAddress: admin?.Admins?.[0]?.registeredAddress || "NA",
|
||||
})
|
||||
);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
<CustomTable
|
||||
columns={categoryColumns}
|
||||
rows={categoryRows}
|
||||
|
|
|
@ -22,9 +22,7 @@ import { toast } from "sonner";
|
|||
import { useNavigate } from "react-router-dom";
|
||||
import { Visibility, VisibilityOff } from "@mui/icons-material";
|
||||
import { Card, SignInContainer } from "./styled.css.tsx";
|
||||
import {
|
||||
CustomIconButton,
|
||||
} from "../../../components/AddUserModel/styled.css.tsx";
|
||||
import { CustomIconButton } from "../../../components/AddEditUserModel/styled.css.tsx";
|
||||
interface ILoginForm {
|
||||
email: string;
|
||||
password: string;
|
||||
|
|
|
@ -12,7 +12,7 @@ import {
|
|||
deleteManager,
|
||||
} from "../../redux/slices/managerSlice";
|
||||
import { useForm } from "react-hook-form";
|
||||
import DeleteModal from "../../components/Modals/DeleteModal";
|
||||
|
||||
|
||||
export default function ManagerList() {
|
||||
const [addModalOpen, setAddModalOpen] = useState<boolean>(false);
|
||||
|
@ -53,7 +53,6 @@ export default function ManagerList() {
|
|||
name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
registeredAddress: string;
|
||||
stationId: string;
|
||||
}) => {
|
||||
try {
|
||||
|
@ -72,7 +71,6 @@ export default function ManagerList() {
|
|||
name: string,
|
||||
email: string,
|
||||
phone: string,
|
||||
registeredAddress: string,
|
||||
stationId: string
|
||||
) => {
|
||||
try {
|
||||
|
@ -83,7 +81,6 @@ export default function ManagerList() {
|
|||
name,
|
||||
email,
|
||||
phone,
|
||||
registeredAddress,
|
||||
stationId,
|
||||
})
|
||||
);
|
||||
|
@ -100,46 +97,69 @@ export default function ManagerList() {
|
|||
{ id: "name", label: "Name" },
|
||||
{ id: "email", label: "Email" },
|
||||
{ id: "phone", label: "Phone" },
|
||||
{ id: "registeredAddress", label: "Station Location" },
|
||||
{ id: "stationName", label: "Station Name" },
|
||||
{ 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()) ||
|
||||
manager.registeredAddress
|
||||
?.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;
|
||||
registeredAddress: string;
|
||||
stationName: string;
|
||||
},
|
||||
index: number
|
||||
) => ({
|
||||
id: manager?.id,
|
||||
srno: index + 1,
|
||||
name: manager?.name,
|
||||
email: manager?.email,
|
||||
phone: manager.phone ?? "NA",
|
||||
registeredAddress: manager?.registeredAddress ?? "NA",
|
||||
stationName: manager?.stationName ?? "NA",
|
||||
})
|
||||
)
|
||||
: [];
|
||||
// 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
|
||||
};
|
||||
})
|
||||
: [];
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
|
@ -4,16 +4,12 @@ import CustomTable, { Column } from "../../components/CustomTable";
|
|||
import { RootState } from "../../redux/reducers";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { AppDispatch } from "../../redux/store/store";
|
||||
import {
|
||||
addVehicle,
|
||||
updateVehicle,
|
||||
vehicleList,
|
||||
} from "../../redux/slices/VehicleSlice";
|
||||
import AddStationModal from "../../components/AddStationModal";
|
||||
import EditStationModal from "../../components/EditStationModal";
|
||||
import {
|
||||
createStation,
|
||||
stationList,
|
||||
toggleStatus,
|
||||
updateStation,
|
||||
} from "../../redux/slices/stationSlice";
|
||||
import { Chip, Switch } from "@mui/material";
|
||||
|
@ -76,6 +72,7 @@ export default function StationList() {
|
|||
name,
|
||||
registeredAddress,
|
||||
totalSlots,
|
||||
|
||||
})
|
||||
);
|
||||
await dispatch(stationList());
|
||||
|
@ -85,16 +82,23 @@ export default function StationList() {
|
|||
}
|
||||
};
|
||||
|
||||
const handleStatusToggle = async(id: string, newStatus: number) => {
|
||||
await dispatch(toggleStatus({ id, status: newStatus }));
|
||||
|
||||
};
|
||||
// Toggle station status
|
||||
// const handleStatusToggle = async (id: string, currentStatus: number) => {
|
||||
// try {
|
||||
// const newStatus = currentStatus === 1 ? 0 : 1; // Toggle between Active(1) and Inactive(0)
|
||||
// await dispatch(updateStation({
|
||||
// id, status: newStatus,
|
||||
// name: "",
|
||||
// registeredAddress: "",
|
||||
// totalSlots: ""
|
||||
// }));
|
||||
// await dispatch(
|
||||
// updateStation({
|
||||
// id,
|
||||
// status: newStatus,
|
||||
// name: stations.name,
|
||||
// registeredAddress: stations.registeredAddress,
|
||||
// totalSlots: stations.totalSlots,
|
||||
// })
|
||||
// );
|
||||
// await dispatch(stationList());
|
||||
// } catch (error) {
|
||||
// console.error("Error toggling status", error);
|
||||
|
@ -109,6 +113,8 @@ export default function StationList() {
|
|||
id: station.id,
|
||||
srno: index + 1,
|
||||
name: station.name,
|
||||
registeredAddress:station.registeredAddress,
|
||||
totalSlots:station.totalSlots,
|
||||
status: (
|
||||
<Chip
|
||||
label={
|
||||
|
@ -130,10 +136,11 @@ export default function StationList() {
|
|||
|
||||
const categoryColumns: Column[] = [
|
||||
{ id: "srno", label: "Sr No" },
|
||||
{ id: "id", label: "Station ID" },
|
||||
{ id: "name", label: "Station Name" },
|
||||
{ id: "registeredAddress", label: "Station Location" },
|
||||
{ id: "totalSlots", label: "Total Slots" },
|
||||
{ id: "status", label: "Status" },
|
||||
//{ id: "status", label: "Status" },
|
||||
{ id: "action", label: "Action", align: "center" },
|
||||
];
|
||||
|
||||
|
@ -173,6 +180,7 @@ export default function StationList() {
|
|||
viewModal={viewModal}
|
||||
setRowData={setRowData}
|
||||
setModalOpen={() => setEditModalOpen(true)}
|
||||
handleStatusToggle={handleStatusToggle}
|
||||
tableType="station"
|
||||
handleClickOpen={handleClickOpen}
|
||||
/>
|
||||
|
|
|
@ -8,7 +8,7 @@ import { createUser, updateUser, userList } from "../../redux/slices/userSlice";
|
|||
import { AppDispatch, RootState } from "../../redux/store/store";
|
||||
import { string } from "prop-types";
|
||||
import { adminList, updateAdmin } from "../../redux/slices/adminSlice";
|
||||
import AddUserModal from "../../components/AddUserModel";
|
||||
import AddUserModal from "../../components/AddEditUserModel";
|
||||
|
||||
export default function UserList() {
|
||||
const [modalOpen, setModalOpen] = useState(false);
|
||||
|
|
|
@ -5,11 +5,11 @@ import { toast } from "sonner";
|
|||
// Define the Manager interface based on the payload
|
||||
|
||||
interface Manager {
|
||||
Manager: any;
|
||||
id: number;
|
||||
name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
registeredAddress: string;
|
||||
stationId: string;
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,8 @@ export const managerList = createAsyncThunk<
|
|||
try {
|
||||
const token = localStorage?.getItem("authToken");
|
||||
if (!token) throw new Error("No token found");
|
||||
|
||||
const response = await http.get("manager-list");
|
||||
|
||||
const response = await http.get("/manager-list");
|
||||
if (!response.data?.data) throw new Error("Invalid API response");
|
||||
return response.data.data;
|
||||
} catch (error: any) {
|
||||
|
@ -50,6 +50,12 @@ export const managerList = createAsyncThunk<
|
|||
// Create Manager (Async Thunk)
|
||||
export const addManager = createAsyncThunk<
|
||||
Manager,
|
||||
{
|
||||
name: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
stationId: string;
|
||||
},
|
||||
{ rejectValue: string }
|
||||
>("addManager", async (data, { rejectWithValue }) => {
|
||||
try {
|
||||
|
|
|
@ -32,7 +32,7 @@ export const stationList = createAsyncThunk<any, void, { rejectValue: string }>(
|
|||
const token = localStorage?.getItem("authToken");
|
||||
if (!token) throw new Error("No token found");
|
||||
|
||||
const response = await http.get("/get-station");
|
||||
const response = await http.get("/get-stations");
|
||||
|
||||
if (!response.data) throw new Error("Invalid API response");
|
||||
|
||||
|
@ -97,8 +97,8 @@ export const deleteStation = createAsyncThunk<
|
|||
{ rejectValue: string }
|
||||
>("deleteStation", async (id, { rejectWithValue }) => {
|
||||
try {
|
||||
const response = await http.delete(`/delete-station/${id}`);
|
||||
toast.success(response.data?.message);
|
||||
await http.delete(`/delete-station/${id}`);
|
||||
toast.success("Station deleted successfully!");
|
||||
return id;
|
||||
} catch (error: any) {
|
||||
toast.error("Error deleting the Station" + error);
|
||||
|
@ -113,9 +113,9 @@ export const toggleStatus = createAsyncThunk<
|
|||
any,
|
||||
{ id: string; status: number },
|
||||
{ rejectValue: string }
|
||||
>("Station/toggleStatus", async ({ id, status }, { rejectWithValue }) => {
|
||||
>("station/toggleStatus", async ({ id, status }, { rejectWithValue }) => {
|
||||
try {
|
||||
const response = await http.patch(`${id}`, { status });
|
||||
const response = await http.patch(`/update-station/${id}`, { status });
|
||||
|
||||
if (response.data.statusCode === 200) {
|
||||
toast.success(
|
||||
|
|
Loading…
Reference in a new issue