feat(patients): default to card view, match tauri /files CardView pixel-for-pixel

- default view is now the card grid (was table), matching tauri /files
  (viewMode='card').
- rebuild the patient card to mirror tauri files/list/CardView exactly:
  avatar-in-circle + name + ⋮ actions menu (view/edit) header, شماره پرونده /
  موبایل rows, برچسب‌ها footer with the inline tag popover. Same Tailwind
  classes/colors/spacing (rounded-[6px], #EDEDED/#E0E0E0 borders,
  grid md:grid-cols-4 gap-[12px]).
- per-view page size like tauri: 16 for card, 12 for table; reset page on
  view switch.
- empty state text 'بیماری یافت نشد'.

Frontend only; no API change. Tests updated (default card, ⋮ menu, table
toggle, tag popover, filter apply) — all green.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-07-15 09:31:50 +03:30
co-authored by Claude Opus 4.8
parent 99047458b6
commit 8697c94886
2 changed files with 98 additions and 33 deletions
+17 -7
View File
@@ -31,21 +31,31 @@ beforeEach(() => {
});
describe('PatientsListPage (پرونده‌ها)', () => {
it('renders the records table with the create button', async () => {
it('renders records as cards by default', async () => {
renderWithProviders(<PatientsListPage />, { route: '/admin/patients' });
expect(await screen.findByText('دنیا خلیلی')).toBeInTheDocument();
expect(screen.getByText('علی بدیعی زاده')).toBeInTheDocument();
// card-only labels (with colon) — proves the default view is the card grid
expect(screen.getAllByText('شماره پرونده:').length).toBe(2);
expect(screen.getByRole('button', { name: /تشکیل پرونده/ })).toBeInTheDocument();
// record with no tags shows the inline "add" trigger
expect(screen.getByText('اضافه کردن')).toBeInTheDocument();
// default card view: requests 16 per page
expect(get.mock.calls.some(([u]) => String(u).includes('limit=16'))).toBe(true);
});
it('switches to the card view', async () => {
it('opens the card ⋮ menu with view/edit actions', async () => {
renderWithProviders(<PatientsListPage />, { route: '/admin/patients' });
await screen.findByText('دنیا خلیلی');
fireEvent.click(screen.getByLabelText('نمایش کارتی'));
expect(screen.getByText('دنیا خلیلی')).toBeInTheDocument();
expect(screen.getAllByText('مشاهده').length).toBeGreaterThan(0);
fireEvent.click(screen.getAllByLabelText('عملیات')[0]);
expect(await screen.findByText('مشاهده')).toBeInTheDocument();
expect(screen.getByText('ویرایش')).toBeInTheDocument();
});
it('switches to the table view', async () => {
renderWithProviders(<PatientsListPage />, { route: '/admin/patients' });
await screen.findByText('دنیا خلیلی');
fireEvent.click(screen.getByLabelText('نمایش جدولی'));
expect(await screen.findByText('مراجعه کننده')).toBeInTheDocument(); // table header
expect(get.mock.calls.some(([u]) => String(u).includes('limit=12'))).toBe(true);
});
it('assigns a tag inline through the برچسب‌ها popover', async () => {