feat: add ROLE_REPRESENTATION access to admin panel for managing doctors and clinics

- Updated authStore to include 'representation' role.
- Modified DoctorFormPage and DoctorsPage to handle different endpoints based on user role.
- Created new RepresentationActionController for handling doctor and clinic creation by representatives.
- Added new API endpoints for representatives to manage doctors, clinics, and view appointments.
- Updated documentation to reflect new role and API changes.
This commit is contained in:
hamed
2026-06-19 13:20:40 +03:30
parent a8d36d7455
commit fe73fa1a05
14 changed files with 778 additions and 19 deletions
+6 -1
View File
@@ -13,6 +13,7 @@ import { formatDate, formatNumber } from '../lib/utils';
import ConfirmDialog from '../components/ui/ConfirmDialog';
import Pagination from '../components/ui/Pagination';
import SearchableSelect from '../components/ui/SearchableSelect';
import { useAuthStore } from '../stores/authStore';
// ── Types ─────────────────────────────────────────────────────────────────
@@ -91,6 +92,8 @@ function DoctorAvatar({ name, id, image, size = 'sm' }: {
export default function DoctorsPage() {
const navigate = useNavigate();
const qc = useQueryClient();
const primaryRole = useAuthStore(s => s.primaryRole);
const isRepresentation = primaryRole === 'representation';
const [page, setPage] = useState(1);
const [limit] = useState(25);
@@ -114,6 +117,7 @@ export default function DoctorsPage() {
queryKey: ['doctors-stats'],
queryFn: () => api.get<ApiResponse<DoctorStats>>('/api/v1/admin/doctors/stats'),
staleTime: 30_000,
enabled: !isRepresentation,
});
const specialtiesQ = useQuery({
@@ -129,7 +133,8 @@ export default function DoctorsPage() {
if (search) p.set('search', search);
if (status) p.set('status', status);
if (specialtyId) p.set('specialty_id', specialtyId);
return api.get<PaginatedResponse<AdminDoctor>>(`/api/v1/admin/doctors?${p}`);
const base = isRepresentation ? '/api/v1/doctors' : '/api/v1/admin/doctors';
return api.get<PaginatedResponse<AdminDoctor>>(`${base}?${p}`);
},
});