fix(admin): UX improvements — silent fetch failures, empty states, batch loading guards, dashboard refresh
- Replace console.error-only catches with message.error user-facing notifications
across Bills, Classes, ClassroomRentals, ClassroomSchedule, Classrooms, Deposits,
Expenses, OperationLogs, Permissions, Roles, RoomVisual, Rooms, Students,
Tenants, Users
- Add Empty component via Table locale prop on list pages: Bills, Classes,
ClassroomRentals, Classrooms, Deposits, Expenses (room+personal), Occupancies,
Rooms, Students, Tenants, Roles
- Add batchLoading state to batch delete/update operations: Bills (batchDelete,
batchUpdateStatus), Expenses (batchDeleteRoom, batchDeletePersonal),
Occupancies (batchCheckOut, batchDelete), Rooms (batchDelete),
Students (batchDelete)
- Add refreshLoading indicator to Dashboard header when re-fetching data
- Consistent error pattern: catch (e: unknown) { const err = e as { message?: string }; message.error(...); }
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import React, { useEffect, useState, useMemo, useCallback } from 'react';
|
||||
import {
|
||||
Table, Button, Input, Select, Space, Tag, Modal, Form, InputNumber,
|
||||
DatePicker, Popconfirm, message, Card, Switch,
|
||||
DatePicker, Popconfirm, message, Card, Switch, Empty,
|
||||
} from 'antd';
|
||||
import type { ColumnsType } from 'antd/es/table';
|
||||
import { PlusOutlined, SearchOutlined, TeamOutlined, InboxOutlined } from '@ant-design/icons';
|
||||
@@ -98,8 +98,9 @@ const ClassesPage: React.FC = () => {
|
||||
params.isArchived = showArchived;
|
||||
const res = await api.get<ClassItem[]>('/classes', { params } as Record<string, unknown>);
|
||||
setData(res);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} catch (e: any) {
|
||||
message.error(e?.message || '加载失败,请稍后重试');
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -266,6 +267,7 @@ const ClassesPage: React.FC = () => {
|
||||
dataSource={filtered}
|
||||
rowKey="id"
|
||||
loading={loading}
|
||||
locale={{ emptyText: <Empty description="暂无数据" /> }}
|
||||
pagination={{ pageSize: 20 }}
|
||||
scroll={{ x: 1100 }}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user