feat(representation): add endpoints for doctor statistics and toggling doctor status
This commit is contained in:
@@ -114,10 +114,14 @@ export default function DoctorsPage() {
|
||||
// ── Queries ──
|
||||
|
||||
const statsQ = useQuery({
|
||||
queryKey: ['doctors-stats'],
|
||||
queryFn: () => api.get<ApiResponse<DoctorStats>>('/api/v1/admin/doctors/stats'),
|
||||
queryKey: ['doctors-stats', isRepresentation],
|
||||
queryFn: () => {
|
||||
const url = isRepresentation
|
||||
? '/api/v1/representation/doctors/stats'
|
||||
: '/api/v1/admin/doctors/stats';
|
||||
return api.get<ApiResponse<DoctorStats>>(url);
|
||||
},
|
||||
staleTime: 30_000,
|
||||
enabled: !isRepresentation,
|
||||
});
|
||||
|
||||
const specialtiesQ = useQuery({
|
||||
@@ -163,7 +167,10 @@ export default function DoctorsPage() {
|
||||
});
|
||||
|
||||
const toggleMut = useMutation({
|
||||
mutationFn: (uuid: string) => api.post<ApiResponse<{ is_active: boolean }>>(`/api/v1/admin/doctors/${uuid}/status`, {}),
|
||||
mutationFn: (uuid: string) => {
|
||||
const base = isRepresentation ? '/api/v1/representation/doctors' : '/api/v1/admin/doctors';
|
||||
return api.post<ApiResponse<{ is_active: boolean }>>(`${base}/${uuid}/status`, {});
|
||||
},
|
||||
onSuccess: () => {
|
||||
toast.success('وضعیت پزشک تغییر کرد');
|
||||
qc.invalidateQueries({ queryKey: ['admin-doctors'] });
|
||||
|
||||
Reference in New Issue
Block a user