feat: add mobile number change functionality for doctors and clinics
- Implemented PATCH endpoints for changing the login mobile number of doctors and clinics. - Added ChangeLoginMobileModal component for handling mobile number updates in the UI. - Updated ClinicsPage and DoctorsPage to include buttons for changing mobile numbers. - Enhanced AdminApiController to manage mobile number changes with validation. - Created tests to ensure proper functionality and validation for mobile number changes. - Updated API documentation to reflect new endpoints and their usage.
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
MagnifyingGlassIcon,
|
||||
PlusIcon,
|
||||
BuildingOffice2Icon,
|
||||
DevicePhoneMobileIcon,
|
||||
} from '@heroicons/react/24/outline';
|
||||
import { toast } from 'sonner';
|
||||
import { useForm } from 'react-hook-form';
|
||||
@@ -21,6 +22,7 @@ import Portal from '../components/ui/Portal';
|
||||
import { formatDate, formatNumber, iranMobileSchema } from '../lib/utils';
|
||||
import Pagination from '../components/ui/Pagination';
|
||||
import ConfirmDialog from '../components/ui/ConfirmDialog';
|
||||
import ChangeLoginMobileModal from '../components/ChangeLoginMobileModal';
|
||||
import { latinDigitsField } from '../lib/forms';
|
||||
|
||||
const HUES_LIST = [256, 205, 162, 295, 272];
|
||||
@@ -41,6 +43,7 @@ export default function ClinicsPage() {
|
||||
const [search, setSearch] = useState('');
|
||||
const [statusFilter, setStatusFilter] = useState('');
|
||||
const [deleteTarget, setDeleteTarget] = useState<Clinic | null>(null);
|
||||
const [mobileTarget, setMobileTarget] = useState<{ uuid: string; name: string; mobile_number?: string | null } | null>(null);
|
||||
const [addOpen, setAddOpen] = useState(false);
|
||||
const limit = 15;
|
||||
|
||||
@@ -217,6 +220,13 @@ export default function ClinicsPage() {
|
||||
>
|
||||
<EyeIcon style={{ width: 15, height: 15 }} />
|
||||
</button>
|
||||
<button
|
||||
className="mini-btn"
|
||||
title="تغییر شماره ورود"
|
||||
onClick={() => setMobileTarget({ uuid: c.uuid, name: c.name, mobile_number: c.owner_mobile })}
|
||||
>
|
||||
<DevicePhoneMobileIcon style={{ width: 15, height: 15 }} />
|
||||
</button>
|
||||
<button
|
||||
className={`mini-btn${c.is_active ? '' : ' active'}`}
|
||||
title={c.is_active ? 'غیرفعال کردن' : 'فعال کردن'}
|
||||
@@ -303,6 +313,13 @@ export default function ClinicsPage() {
|
||||
onConfirm={() => deleteTarget && deleteMutation.mutate(deleteTarget)}
|
||||
onCancel={() => setDeleteTarget(null)}
|
||||
/>
|
||||
|
||||
<ChangeLoginMobileModal
|
||||
target={mobileTarget}
|
||||
resource="clinic"
|
||||
queryKey={['clinics']}
|
||||
onClose={() => setMobileTarget(null)}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user