diff --git a/assets/admin/pages/AppointmentBookingModal.test.tsx b/assets/admin/pages/AppointmentBookingModal.test.tsx index 4c8e4e95..bd68f090 100644 --- a/assets/admin/pages/AppointmentBookingModal.test.tsx +++ b/assets/admin/pages/AppointmentBookingModal.test.tsx @@ -26,6 +26,7 @@ beforeEach(() => { describe('NewAppointmentModal — جستجوی موبایل‌محور', () => { it('submit stays disabled until a mobile search is done', () => { renderWithProviders( {}} onSuccess={() => {}} />); + fireEvent.click(screen.getByRole('button', { name: 'شماره موبایل' })); fireEvent.change(screen.getByPlaceholderText('مثال: 09123456789'), { target: { value: '09121234567' } }); // بدون جستجو، ثبت نوبت غیرفعال است expect(screen.getByRole('button', { name: 'ثبت نوبت' })).toBeDisabled(); @@ -34,6 +35,7 @@ describe('NewAppointmentModal — جستجوی موبایل‌محور', () => { it('converts Persian digits to English and searches by the normalized mobile', async () => { get.mockResolvedValue({ success: true, data: { found: false } }); renderWithProviders( {}} onSuccess={() => {}} />); + fireEvent.click(screen.getByRole('button', { name: 'شماره موبایل' })); const input = screen.getByPlaceholderText('مثال: 09123456789') as HTMLInputElement; fireEvent.change(input, { target: { value: '۰۹۱۲۳۴۵۶۷۸۹' } }); @@ -46,6 +48,7 @@ describe('NewAppointmentModal — جستجوی موبایل‌محور', () => { it('searches on Enter key in the mobile field', async () => { get.mockResolvedValue({ success: true, data: { found: false } }); renderWithProviders( {}} onSuccess={() => {}} />); + fireEvent.click(screen.getByRole('button', { name: 'شماره موبایل' })); const input = screen.getByPlaceholderText('مثال: 09123456789'); fireEvent.change(input, { target: { value: '09121234567' } }); @@ -57,6 +60,7 @@ describe('NewAppointmentModal — جستجوی موبایل‌محور', () => { it('found patient with national code books directly without extra fields', async () => { get.mockResolvedValue({ success: true, data: { found: true, name: 'علی محمدی', mobile: '09121234567', national_code: '0012345678' } }); renderWithProviders( {}} onSuccess={() => {}} />); + fireEvent.click(screen.getByRole('button', { name: 'شماره موبایل' })); fireEvent.change(screen.getByPlaceholderText('مثال: 09123456789'), { target: { value: '09121234567' } }); fireEvent.click(screen.getByRole('button', { name: 'جستجو' })); @@ -78,6 +82,7 @@ describe('NewAppointmentModal — جستجوی موبایل‌محور', () => { it('unknown mobile reveals national code + name fields and books the new patient', async () => { get.mockResolvedValue({ success: true, data: { found: false } }); renderWithProviders( {}} onSuccess={() => {}} />); + fireEvent.click(screen.getByRole('button', { name: 'شماره موبایل' })); fireEvent.change(screen.getByPlaceholderText('مثال: 09123456789'), { target: { value: '09990001122' } }); fireEvent.click(screen.getByRole('button', { name: 'جستجو' })); diff --git a/assets/admin/pages/AppointmentsPage.tsx b/assets/admin/pages/AppointmentsPage.tsx index 6c5a13cf..c69616db 100644 --- a/assets/admin/pages/AppointmentsPage.tsx +++ b/assets/admin/pages/AppointmentsPage.tsx @@ -118,8 +118,8 @@ export function NewAppointmentModal({ const [lookup, setLookup] = useState(null); const [patientName, setPatientName] = useState(''); const [nationalCode, setNationalCode] = useState(''); - // معیار جستجوی بیمار: موبایل یا کد ملی. - const [searchBy, setSearchBy] = useState<'mobile' | 'national'>('mobile'); + // معیار جستجوی بیمار: کد ملی (پیش‌فرض) یا موبایل. + const [searchBy, setSearchBy] = useState<'mobile' | 'national'>('national'); const [pick, setPick] = useState<{ serviceUuids: string[]; slot: { start: number; end: number } | null }>({ serviceUuids: [], slot: null }); const role = useAuthStore(s => s.primaryRole); @@ -292,7 +292,7 @@ export function NewAppointmentModal({ {/* انتخاب معیار جستجو: موبایل یا کد ملی */}
- {(['mobile', 'national'] as const).map(mode => ( + {(['national', 'mobile'] as const).map(mode => (