Functionality bugs fixed

This commit is contained in:
jaanvi 2025-04-03 12:54:26 +05:30
parent 4a15fd3293
commit f40ac87da1
8 changed files with 36 additions and 30 deletions

View file

@ -203,13 +203,17 @@ const CustomTable: React.FC<CustomTableProps> = ({
handleClose(); handleClose();
}; };
const filteredRows = rows.filter( const filteredRows = rows.filter((row) => {
(row) => if (!searchQuery.trim()) return true; // Return all rows if searchQuery is empty or whitespace
(row.name && const lowerCaseQuery = searchQuery.toLowerCase().trim();
row.name.toLowerCase().includes(searchQuery.toLowerCase())) || return (
row.registeredAddress.toLowerCase().includes(searchQuery.toLowerCase()) || (row.name && row.name.toLowerCase().includes(lowerCaseQuery)) ||
false (row.registeredAddress &&
row.registeredAddress.toLowerCase().includes(lowerCaseQuery))
); );
});
const indexOfLastRow = currentPage * usersPerPage; const indexOfLastRow = currentPage * usersPerPage;
const indexOfFirstRow = indexOfLastRow - usersPerPage; const indexOfFirstRow = indexOfLastRow - usersPerPage;

View file

@ -209,9 +209,9 @@ const EditSlotModal: React.FC<EditSlotModalProps> = ({
> >
{isAvailable ? "Available" : "Not Available"} {isAvailable ? "Available" : "Not Available"}
</Button> </Button>
<Typography> {/* <Typography>
{isAvailable ? "Available" : "Not Available"} {isAvailable ? "Available" : "Not Available"}
</Typography> </Typography> */}
</Box> </Box>
</Box> </Box>

View file

@ -94,9 +94,15 @@ const EditStationModal: React.FC<EditStationModalProps> = ({
setSelectedVehicles(editRow.allowedCarIds || []); setSelectedVehicles(editRow.allowedCarIds || []);
// Set selectedBrands based on the vehicles associated with the station // Set selectedBrands based on the vehicles associated with the station
const brands = vehicles const brands = editRow?.allowedCarIds
.filter((vehicle) => editRow.allowedCarIds.includes(vehicle.id)) ? vehicles
.map((vehicle) => vehicle.company); .filter((vehicle) =>
editRow.allowedCarIds.includes(vehicle.id)
)
.map((vehicle) => vehicle.company)
: [];
setSelectedBrands(brands); setSelectedBrands(brands);
} else { } else {

View file

@ -16,7 +16,7 @@ root.render(
position="top-right" position="top-right"
richColors richColors
closeButton closeButton
duration={6000} duration={3000}
/> />
</Provider> </Provider>
</React.StrictMode> </React.StrictMode>

View file

@ -118,8 +118,8 @@ export default function StationList() {
return { return {
id: station.id, id: station.id,
srno: index + 1, srno: index + 1,
name: station.name, name: station.name || "N/A",
registeredAddress: station.registeredAddress, registeredAddress: station.registeredAddress || "N/A",
totalSlots: station.totalSlots, totalSlots: station.totalSlots,
vehicles: vehicleDisplay, // Add the formatted vehicle display here vehicles: vehicleDisplay, // Add the formatted vehicle display here
status: status:

View file

@ -17,7 +17,6 @@ export default function UserList() {
const [viewModal, setViewModal] = useState<boolean>(false); const [viewModal, setViewModal] = useState<boolean>(false);
const { reset } = useForm(); const { reset } = useForm();
const dispatch = useDispatch<AppDispatch>(); const dispatch = useDispatch<AppDispatch>();
const users = useSelector((state: RootState) => state.userReducer.users); const users = useSelector((state: RootState) => state.userReducer.users);
@ -65,7 +64,6 @@ export default function UserList() {
name, name,
email, email,
phone, phone,
}) })
); );
await dispatch(userList()); await dispatch(userList());
@ -76,24 +74,21 @@ export default function UserList() {
const categoryColumns: Column[] = [ const categoryColumns: Column[] = [
{ id: "srno", label: "Sr No" }, { id: "srno", label: "Sr No" },
{ id: "name", label: "Name" }, { id: "name", label: "User Name" },
{ id: "email", label: "Email" }, { id: "email", label: "Email" },
{ id: "phone", label: "Phone" }, { id: "phone", label: "Phone" },
{ id: "action", label: "Action", align: "center" }, { id: "action", label: "Action", align: "center" },
]; ];
const categoryRows = users?.length const categoryRows = users?.length
? users.map((user, index) => ({ ? users.map((user, index) => ({
id: user.id, id: user.id,
srno: index + 1, srno: index + 1,
name: user.name, name: user.name,
email: user.email, email: user.email,
phone: user.phone || "NA", // Ensures it's a string phone: user.phone || "NA", // Ensures it's a string
})) }))
: []; : [];
return ( return (
<> <>

View file

@ -79,6 +79,7 @@ export const createAdmin = createAsyncThunk<
>("/create-admin", async (data, { rejectWithValue }) => { >("/create-admin", async (data, { rejectWithValue }) => {
try { try {
const response = await http.post("/create-admin", data); const response = await http.post("/create-admin", data);
toast.success("Admin created successfully");
return response.data; return response.data;
} catch (error: any) { } catch (error: any) {
return rejectWithValue( return rejectWithValue(

View file

@ -63,7 +63,7 @@ export const addManager = createAsyncThunk<
toast.success("Manager created successfully"); toast.success("Manager created successfully");
return response.data?.data; return response.data?.data;
} catch (error: any) { } catch (error: any) {
toast.error("Error creating manager: " + error.message); toast.error("Error creating manager: " + error.response?.data?.message);
return rejectWithValue( return rejectWithValue(
error.response?.data?.message || "An error occurred" error.response?.data?.message || "An error occurred"
); );