fix: staff edit error and column order on appointment page
This commit is contained in:
@@ -49,7 +49,8 @@ router.put("/:id", async (req: Request, res: Response): Promise<any> => {
|
|||||||
return res.status(400).send("Invalid staff ID");
|
return res.status(400).send("Invalid staff ID");
|
||||||
}
|
}
|
||||||
|
|
||||||
const validatedData = staffUpdateSchema.parse(req.body);
|
const { userId: _userId, id: _id, createdAt: _createdAt, ...updateBody } = req.body;
|
||||||
|
const validatedData = staffUpdateSchema.parse(updateBody);
|
||||||
const updatedStaff = await storage.updateStaff(
|
const updatedStaff = await storage.updateStaff(
|
||||||
parsedStaffId,
|
parsedStaffId,
|
||||||
validatedData
|
validatedData
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const staffStorage: IStorage = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async getAllStaff(): Promise<Staff[]> {
|
async getAllStaff(): Promise<Staff[]> {
|
||||||
const staff = await db.staff.findMany();
|
const staff = await db.staff.findMany({ orderBy: { id: "asc" } });
|
||||||
return staff;
|
return staff;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import React, { useState, useEffect } from "react";
|
|||||||
|
|
||||||
interface StaffFormProps {
|
interface StaffFormProps {
|
||||||
initialData?: Partial<Staff>;
|
initialData?: Partial<Staff>;
|
||||||
onSubmit: (data: Omit<Staff, "id">) => void;
|
onSubmit: (data: Omit<Staff, "id" | "userId" | "createdAt">) => void;
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,6 @@ export function StaffForm({
|
|||||||
const [email, setEmail] = useState("");
|
const [email, setEmail] = useState("");
|
||||||
const [role, setRole] = useState("Staff");
|
const [role, setRole] = useState("Staff");
|
||||||
const [phone, setPhone] = useState("");
|
const [phone, setPhone] = useState("");
|
||||||
const [userId, setUserId] = useState<number | undefined>(undefined);
|
|
||||||
|
|
||||||
const [hasTypedRole, setHasTypedRole] = useState(false);
|
const [hasTypedRole, setHasTypedRole] = useState(false);
|
||||||
|
|
||||||
@@ -44,7 +43,6 @@ export function StaffForm({
|
|||||||
email: email.trim() || undefined,
|
email: email.trim() || undefined,
|
||||||
role: role.trim(),
|
role: role.trim(),
|
||||||
phone: phone.trim() || undefined,
|
phone: phone.trim() || undefined,
|
||||||
userId: userId || 0,
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user