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:
@@ -286,7 +286,7 @@ const ClassDetailPage: React.FC = () => {
|
|||||||
|
|
||||||
const openTeacherModal = async () => {
|
const openTeacherModal = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await api.get('/users') as UserItem[];
|
const res = await api.get('/rbac/users') as UserItem[];
|
||||||
setAllUsers(res || []);
|
setAllUsers(res || []);
|
||||||
setTeacherUserId(undefined);
|
setTeacherUserId(undefined);
|
||||||
setTeacherRole('subject_teacher');
|
setTeacherRole('subject_teacher');
|
||||||
@@ -576,7 +576,7 @@ const ClassDetailPage: React.FC = () => {
|
|||||||
onOk={handleAddTeacher}
|
onOk={handleAddTeacher}
|
||||||
onCancel={() => setTeacherModalOpen(false)}
|
onCancel={() => setTeacherModalOpen(false)}
|
||||||
>
|
>
|
||||||
<Space orientation="vertical" style={{ width: '100%' }}>
|
<Space direction="vertical" style={{ width: '100%' }}>
|
||||||
<Select
|
<Select
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
placeholder="选择教师"
|
placeholder="选择教师"
|
||||||
|
|||||||
@@ -42,11 +42,6 @@ interface ClassFormValues {
|
|||||||
notes?: string;
|
notes?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ClassQueryParams {
|
|
||||||
status?: string;
|
|
||||||
classType?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ---- Constants ----
|
// ---- Constants ----
|
||||||
|
|
||||||
const STATUS_MAP: Record<string, { color: string; text: string }> = {
|
const STATUS_MAP: Record<string, { color: string; text: string }> = {
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ const RolesPage: React.FC = () => {
|
|||||||
</PermissionButton>
|
</PermissionButton>
|
||||||
</div>
|
</div>
|
||||||
<Table
|
<Table
|
||||||
|
columns={columns}
|
||||||
dataSource={data}
|
dataSource={data}
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
|
|||||||
@@ -39,6 +39,20 @@ const statusMap: Record<string, { text: string; color: string }> = {
|
|||||||
archived: { text: '已归档', color: '#999' },
|
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) {
|
function parseRoomNumber(input: string) {
|
||||||
const cleaned = input.replace(/[((].*?[))]/g, '').trim();
|
const cleaned = input.replace(/[((].*?[))]/g, '').trim();
|
||||||
const familyMatch = cleaned.match(/^(\d+)-(\d+)-(\d+)$/);
|
const familyMatch = cleaned.match(/^(\d+)-(\d+)-(\d+)$/);
|
||||||
@@ -166,7 +180,7 @@ const RoomsPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
const fetchBeds = useCallback(async (roomId: number) => {
|
const fetchBeds = useCallback(async (roomId: number) => {
|
||||||
try {
|
try {
|
||||||
const res = await api.get(`/rooms/${roomId}/beds`);
|
const res = await api.get<BedItem[]>(`/rooms/${roomId}/beds`);
|
||||||
setBeds(res);
|
setBeds(res);
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
const err = e as { message?: string };
|
const err = e as { message?: string };
|
||||||
@@ -176,7 +190,7 @@ const RoomsPage: React.FC = () => {
|
|||||||
|
|
||||||
const fetchLockers = useCallback(async (roomId: number) => {
|
const fetchLockers = useCallback(async (roomId: number) => {
|
||||||
try {
|
try {
|
||||||
const res = await api.get(`/rooms/${roomId}/lockers`);
|
const res = await api.get<LockerItem[]>(`/rooms/${roomId}/lockers`);
|
||||||
setLockers(res);
|
setLockers(res);
|
||||||
} catch (e: unknown) {
|
} catch (e: unknown) {
|
||||||
const err = e as { message?: string };
|
const err = e as { message?: string };
|
||||||
|
|||||||
Reference in New Issue
Block a user