feat(appointment): add Enter key functionality for mobile search in appointment modal

This commit is contained in:
hamed
2026-07-15 18:29:59 +03:30
parent 5d5089244b
commit 0dc1ab949a
2 changed files with 12 additions and 0 deletions
@@ -43,6 +43,17 @@ describe('NewAppointmentModal — جستجوی موبایل‌محور', () => {
await waitFor(() => expect(get).toHaveBeenCalledWith('/api/v1/my/appointment/patient-lookup?mobile=09123456789'));
});
it('searches on Enter key in the mobile field', async () => {
get.mockResolvedValue({ success: true, data: { found: false } });
renderWithProviders(<NewAppointmentModal slot={slot} onClose={() => {}} onSuccess={() => {}} />);
const input = screen.getByPlaceholderText('مثال: 09123456789');
fireEvent.change(input, { target: { value: '09121234567' } });
fireEvent.keyDown(input, { key: 'Enter' });
await waitFor(() => expect(get).toHaveBeenCalledWith('/api/v1/my/appointment/patient-lookup?mobile=09121234567'));
});
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(<NewAppointmentModal slot={slot} onClose={() => {}} onSuccess={() => {}} />);
+1
View File
@@ -192,6 +192,7 @@ export function NewAppointmentModal({
maxLength={11}
value={mobile}
onChange={e => onMobileChange(e.target.value)}
onKeyDown={e => { if (e.key === 'Enter' && mobileValid && !search.isPending) search.mutate(); }}
placeholder="مثال: 09123456789"
style={{ ...inputSx, direction: 'ltr' }}
autoFocus