diff --git a/src/components/CustomTable/customTable.tsx b/src/components/CustomTable/customTable.tsx index 7c13c38..2606e45 100644 --- a/src/components/CustomTable/customTable.tsx +++ b/src/components/CustomTable/customTable.tsx @@ -203,13 +203,17 @@ const CustomTable: React.FC = ({ handleClose(); }; - const filteredRows = rows.filter( - (row) => - (row.name && - row.name.toLowerCase().includes(searchQuery.toLowerCase())) || - row.registeredAddress.toLowerCase().includes(searchQuery.toLowerCase()) || - false +const filteredRows = rows.filter((row) => { + if (!searchQuery.trim()) return true; // Return all rows if searchQuery is empty or whitespace + const lowerCaseQuery = searchQuery.toLowerCase().trim(); + return ( + (row.name && row.name.toLowerCase().includes(lowerCaseQuery)) || + (row.registeredAddress && + row.registeredAddress.toLowerCase().includes(lowerCaseQuery)) ); +}); + + const indexOfLastRow = currentPage * usersPerPage; const indexOfFirstRow = indexOfLastRow - usersPerPage; diff --git a/src/components/EditSlotModal/editSlotModal.tsx b/src/components/EditSlotModal/editSlotModal.tsx index 4825de3..120da75 100644 --- a/src/components/EditSlotModal/editSlotModal.tsx +++ b/src/components/EditSlotModal/editSlotModal.tsx @@ -209,9 +209,9 @@ const EditSlotModal: React.FC = ({ > {isAvailable ? "Available" : "Not Available"} - + {/* {isAvailable ? "Available" : "Not Available"} - + */} diff --git a/src/components/EditStationModal/editSationModal.tsx b/src/components/EditStationModal/editSationModal.tsx index e7498dc..d77d5de 100644 --- a/src/components/EditStationModal/editSationModal.tsx +++ b/src/components/EditStationModal/editSationModal.tsx @@ -94,9 +94,15 @@ const EditStationModal: React.FC = ({ setSelectedVehicles(editRow.allowedCarIds || []); // Set selectedBrands based on the vehicles associated with the station - const brands = vehicles - .filter((vehicle) => editRow.allowedCarIds.includes(vehicle.id)) - .map((vehicle) => vehicle.company); + const brands = editRow?.allowedCarIds + ? vehicles + .filter((vehicle) => + editRow.allowedCarIds.includes(vehicle.id) + ) + .map((vehicle) => vehicle.company) + : []; + + setSelectedBrands(brands); } else { diff --git a/src/index.tsx b/src/index.tsx index 2a29a96..94f2fa4 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -16,7 +16,7 @@ root.render( position="top-right" richColors closeButton - duration={6000} + duration={3000} /> diff --git a/src/pages/StationList/index.tsx b/src/pages/StationList/index.tsx index 6f2f176..b372463 100644 --- a/src/pages/StationList/index.tsx +++ b/src/pages/StationList/index.tsx @@ -118,8 +118,8 @@ export default function StationList() { return { id: station.id, srno: index + 1, - name: station.name, - registeredAddress: station.registeredAddress, + name: station.name || "N/A", + registeredAddress: station.registeredAddress || "N/A", totalSlots: station.totalSlots, vehicles: vehicleDisplay, // Add the formatted vehicle display here status: diff --git a/src/pages/UserList/index.tsx b/src/pages/UserList/index.tsx index e14c2bf..cf8eb07 100644 --- a/src/pages/UserList/index.tsx +++ b/src/pages/UserList/index.tsx @@ -17,7 +17,6 @@ export default function UserList() { const [viewModal, setViewModal] = useState(false); const { reset } = useForm(); - const dispatch = useDispatch(); const users = useSelector((state: RootState) => state.userReducer.users); @@ -65,7 +64,6 @@ export default function UserList() { name, email, phone, - }) ); await dispatch(userList()); @@ -76,24 +74,21 @@ export default function UserList() { const categoryColumns: Column[] = [ { id: "srno", label: "Sr No" }, - { id: "name", label: "Name" }, + { id: "name", label: "User Name" }, { id: "email", label: "Email" }, { id: "phone", label: "Phone" }, { id: "action", label: "Action", align: "center" }, ]; -const categoryRows = users?.length - ? users.map((user, index) => ({ - id: user.id, - srno: index + 1, - name: user.name, - email: user.email, - phone: user.phone || "NA", // Ensures it's a string - })) - : []; - - - + const categoryRows = users?.length + ? users.map((user, index) => ({ + id: user.id, + srno: index + 1, + name: user.name, + email: user.email, + phone: user.phone || "NA", // Ensures it's a string + })) + : []; return ( <> diff --git a/src/redux/slices/adminSlice.ts b/src/redux/slices/adminSlice.ts index 00f306e..25584f8 100644 --- a/src/redux/slices/adminSlice.ts +++ b/src/redux/slices/adminSlice.ts @@ -79,6 +79,7 @@ export const createAdmin = createAsyncThunk< >("/create-admin", async (data, { rejectWithValue }) => { try { const response = await http.post("/create-admin", data); + toast.success("Admin created successfully"); return response.data; } catch (error: any) { return rejectWithValue( diff --git a/src/redux/slices/managerSlice.ts b/src/redux/slices/managerSlice.ts index 9fb47c3..3ed22c7 100644 --- a/src/redux/slices/managerSlice.ts +++ b/src/redux/slices/managerSlice.ts @@ -63,7 +63,7 @@ export const addManager = createAsyncThunk< toast.success("Manager created successfully"); return response.data?.data; } catch (error: any) { - toast.error("Error creating manager: " + error.message); + toast.error("Error creating manager: " + error.response?.data?.message); return rejectWithValue( error.response?.data?.message || "An error occurred" );