fix(admin): repair class, role, and room views
Use the RBAC user endpoint for teacher selection, restore role table columns, correct Ant Design props, and add typed room bed and locker responses.
This commit is contained in:
@@ -39,6 +39,20 @@ const statusMap: Record<string, { text: string; color: string }> = {
|
||||
archived: { text: '已归档', color: '#999' },
|
||||
};
|
||||
|
||||
interface BedItem {
|
||||
id: number;
|
||||
bedNumber: string;
|
||||
status: string;
|
||||
notes?: string | null;
|
||||
}
|
||||
|
||||
interface LockerItem {
|
||||
id: number;
|
||||
lockerNumber: string;
|
||||
status: string;
|
||||
notes?: string | null;
|
||||
}
|
||||
|
||||
function parseRoomNumber(input: string) {
|
||||
const cleaned = input.replace(/[((].*?[))]/g, '').trim();
|
||||
const familyMatch = cleaned.match(/^(\d+)-(\d+)-(\d+)$/);
|
||||
@@ -166,7 +180,7 @@ const RoomsPage: React.FC = () => {
|
||||
};
|
||||
const fetchBeds = useCallback(async (roomId: number) => {
|
||||
try {
|
||||
const res = await api.get(`/rooms/${roomId}/beds`);
|
||||
const res = await api.get<BedItem[]>(`/rooms/${roomId}/beds`);
|
||||
setBeds(res);
|
||||
} catch (e: unknown) {
|
||||
const err = e as { message?: string };
|
||||
@@ -176,7 +190,7 @@ const RoomsPage: React.FC = () => {
|
||||
|
||||
const fetchLockers = useCallback(async (roomId: number) => {
|
||||
try {
|
||||
const res = await api.get(`/rooms/${roomId}/lockers`);
|
||||
const res = await api.get<LockerItem[]>(`/rooms/${roomId}/lockers`);
|
||||
setLockers(res);
|
||||
} catch (e: unknown) {
|
||||
const err = e as { message?: string };
|
||||
|
||||
Reference in New Issue
Block a user