fix(dashboard): make the staff dashboard show the operator's actual work
Every number on it was zero. "نوبتهای امروز من" counted appointments where appointments.staff_id matches — a column no booking path fills by default, and which is NULL on every row in the database. "سرویسهای من" read only direct service assignment, so an operator whose whole job comes from a treatment protocol was told they had no services. The landing page of the only role that has one data page said, in effect, that they had nothing to do — while they had two sessions booked that day. Today's work now comes from TreatmentSessionRepository::findTodayForStaff, the same queue rule the sessions page uses, so there is one definition of "my work today" rather than two that disagree. Services are the union of direct assignment and protocol authorisation. The two stat cards are links to the pages they name; a number with no destination made the user hunt the sidebar for a page the card had just mentioned. Each row of the work list opens that session. The avatar moves from its own full-width card into the header — two lines of text were costing a card and pushing the day's work below the fold on mobile. The assigned-appointments table renders only when it has rows. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -188,3 +188,60 @@ describe('DashboardPage (ported clinic dashboard)', () => {
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('داشبورد پرسنل', () => {
|
||||
const staffPayload = {
|
||||
success: true,
|
||||
data: {
|
||||
scope: 'clinic',
|
||||
staff: { uuid: 'st-1', full_name: 'پرسنل۱', job_title: 'پرسنل لیزر' },
|
||||
owner: { name: 'مدیسا' },
|
||||
stats: { today_sessions: 2, today_appointments: 0, services: 1 },
|
||||
services: [{ uuid: 'svc-1', name: 'لیزر توتال', section_name: 'لیزر', price_rials: 10_000_000, duration_minutes: 40 }],
|
||||
today_sessions: [
|
||||
{ uuid: 'ses-1', session_number: 1, total_sessions: 3, status: 'in_progress', service_name: 'لیزر توتال', patient_name: 'محمد رسولی', slot_start: 1_786_084_200 },
|
||||
{ uuid: 'ses-2', session_number: 1, total_sessions: 3, status: 'done', service_name: 'لیزر توتال', patient_name: 'محمد رستمی', slot_start: 1_786_080_600 },
|
||||
],
|
||||
today_appointments: [],
|
||||
},
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
get.mockReset();
|
||||
useAuthStore.setState({ primaryRole: 'staff' } as never);
|
||||
get.mockResolvedValue(staffPayload);
|
||||
});
|
||||
|
||||
/** کارِ اپراتور جلسهٔ درمان است؛ `appointments.staff_id` را هیچ مسیری پر نمیکند. */
|
||||
it('کار امروز را از جلسات درمان میسازد، نه نوبتهای اختصاصیافته', async () => {
|
||||
renderWithProviders(<DashboardPage />);
|
||||
|
||||
expect(await screen.findByText('محمد رسولی')).toBeInTheDocument();
|
||||
expect(screen.getByText('محمد رستمی')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('کارتهای آمار به صفحهٔ کار خودشان لینکاند', async () => {
|
||||
renderWithProviders(<DashboardPage />);
|
||||
|
||||
const sessions = (await screen.findByText('جلسات امروز من')).closest('a');
|
||||
expect(sessions).toHaveAttribute('href', '/admin/my-sessions');
|
||||
|
||||
const services = screen.getByText('سرویسهای من').closest('a');
|
||||
expect(services).toHaveAttribute('href', '/admin/my-services');
|
||||
});
|
||||
|
||||
it('هر ردیف کار به همان جلسه میرود', async () => {
|
||||
renderWithProviders(<DashboardPage />);
|
||||
|
||||
const row = (await screen.findByText('محمد رسولی')).closest('a');
|
||||
expect(row).toHaveAttribute('href', '/admin/my-sessions/ses-1');
|
||||
});
|
||||
|
||||
/** جدولِ همیشه-خالی زیر کارِ واقعی فقط صفحه را بلند میکرد. */
|
||||
it('نوبتهای اختصاصیافته وقتی خالی است اصلاً نمیآید', async () => {
|
||||
renderWithProviders(<DashboardPage />);
|
||||
await screen.findByText('محمد رسولی');
|
||||
|
||||
expect(screen.queryByText('نوبتهای اختصاصیافته به من')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user