feat(representation): add endpoints for doctor statistics and toggling doctor status

This commit is contained in:
hamed
2026-06-24 12:24:53 +03:30
parent 8b419d0272
commit b7df8cf9ee
3 changed files with 113 additions and 4 deletions
+11 -4
View File
@@ -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'] });