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
+5 -1
View File
@@ -13,6 +13,7 @@ import { toast } from 'sonner';
import { api } from '../lib/api';
import type { ApiResponse } from '../lib/api';
import SearchableSelect from '../components/ui/SearchableSelect';
import { useAuthStore } from '../stores/authStore';
// ── Types ────────────────────────────────────────────────────────────────────
@@ -253,6 +254,9 @@ function SpecialtyPicker({ selected, onChange, specialties }: {
export default function DoctorFormPage() {
const navigate = useNavigate();
const primaryRole = useAuthStore(s => s.primaryRole);
const createDoctorEndpoint =
primaryRole === 'representation' ? '/api/v1/representation/doctor' : '/api/v1/admin/doctors';
const [selectedSpecialties, setSelectedSpecialties] = useState<number[]>([]);
const [gender, setGender] = useState<'man' | 'woman' | ''>('');
@@ -273,7 +277,7 @@ export default function DoctorFormPage() {
const createMut = useMutation({
mutationFn: (values: FormValues) =>
api.post<ApiResponse<{ uuid: string }>>('/api/v1/admin/doctors', {
api.post<ApiResponse<{ uuid: string }>>(createDoctorEndpoint, {
mobile: values.mobile,
name: values.name,
gender: gender || undefined,