feat(appointment): add Enter key functionality for mobile search in appointment modal
This commit is contained in:
@@ -43,6 +43,17 @@ describe('NewAppointmentModal — جستجوی موبایلمحور', () => {
|
|||||||
await waitFor(() => expect(get).toHaveBeenCalledWith('/api/v1/my/appointment/patient-lookup?mobile=09123456789'));
|
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 () => {
|
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' } });
|
get.mockResolvedValue({ success: true, data: { found: true, name: 'علی محمدی', mobile: '09121234567', national_code: '0012345678' } });
|
||||||
renderWithProviders(<NewAppointmentModal slot={slot} onClose={() => {}} onSuccess={() => {}} />);
|
renderWithProviders(<NewAppointmentModal slot={slot} onClose={() => {}} onSuccess={() => {}} />);
|
||||||
|
|||||||
@@ -192,6 +192,7 @@ export function NewAppointmentModal({
|
|||||||
maxLength={11}
|
maxLength={11}
|
||||||
value={mobile}
|
value={mobile}
|
||||||
onChange={e => onMobileChange(e.target.value)}
|
onChange={e => onMobileChange(e.target.value)}
|
||||||
|
onKeyDown={e => { if (e.key === 'Enter' && mobileValid && !search.isPending) search.mutate(); }}
|
||||||
placeholder="مثال: 09123456789"
|
placeholder="مثال: 09123456789"
|
||||||
style={{ ...inputSx, direction: 'ltr' }}
|
style={{ ...inputSx, direction: 'ltr' }}
|
||||||
autoFocus
|
autoFocus
|
||||||
|
|||||||
Reference in New Issue
Block a user