feat(representation): add representation management for doctors, including attach and update functionality
This commit is contained in:
@@ -44,18 +44,24 @@ interface UserStats {
|
||||
const HUES_LIST = [256, 205, 162, 295, 272];
|
||||
|
||||
const ROLE_META: Record<string, { label: string; badgeCls: string }> = {
|
||||
admin: { label: 'ادمین', badgeCls: 'violet' },
|
||||
doctor: { label: 'پزشک', badgeCls: 'blue' },
|
||||
secretary: { label: 'منشی', badgeCls: 'amber' },
|
||||
clinic: { label: 'کلینیک', badgeCls: 'green' },
|
||||
patient: { label: 'بیمار', badgeCls: 'gray' },
|
||||
admin: { label: 'ادمین', badgeCls: 'violet' },
|
||||
doctor: { label: 'پزشک', badgeCls: 'blue' },
|
||||
secretary: { label: 'منشی', badgeCls: 'amber' },
|
||||
clinic: { label: 'کلینیک', badgeCls: 'green' },
|
||||
representation: { label: 'نماینده', badgeCls: 'red' },
|
||||
patient: { label: 'بیمار', badgeCls: 'gray' },
|
||||
};
|
||||
|
||||
// نقشهایی که از این صفحه قابل تغییرِ مستقیماند (backend `roleMap`). «نماینده» از اینجا ست نمیشود
|
||||
// چون ساخت نماینده رکورد Representation هم میخواهد؛ فقط برای نمایش badge/فیلتر تعریف شده است.
|
||||
const ASSIGNABLE_ROLES = ['admin', 'doctor', 'secretary', 'clinic', 'patient'];
|
||||
|
||||
function getPrimaryRole(roles: string[]): string {
|
||||
if (roles.includes('ROLE_ADMIN')) return 'admin';
|
||||
if (roles.includes('ROLE_DOCTOR')) return 'doctor';
|
||||
if (roles.includes('ROLE_SECRETARY')) return 'secretary';
|
||||
if (roles.includes('ROLE_CLINIC')) return 'clinic';
|
||||
if (roles.includes('ROLE_ADMIN')) return 'admin';
|
||||
if (roles.includes('ROLE_DOCTOR')) return 'doctor';
|
||||
if (roles.includes('ROLE_SECRETARY')) return 'secretary';
|
||||
if (roles.includes('ROLE_CLINIC')) return 'clinic';
|
||||
if (roles.includes('ROLE_REPRESENTATION')) return 'representation';
|
||||
return 'patient';
|
||||
}
|
||||
|
||||
@@ -114,7 +120,7 @@ function ChangeRoleModal({ user, onClose, onSave, loading }: {
|
||||
<div className="modal-body">
|
||||
<p className="muted" style={{ fontSize: 13, marginBottom: 16 }}>{user.name || user.mobile_number}</p>
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 8 }}>
|
||||
{Object.entries(ROLE_META).map(([key, meta]) => (
|
||||
{Object.entries(ROLE_META).filter(([key]) => ASSIGNABLE_ROLES.includes(key)).map(([key, meta]) => (
|
||||
<label
|
||||
key={key}
|
||||
style={{
|
||||
@@ -154,6 +160,7 @@ const ROLE_TABS = [
|
||||
{ key: 'doctor', label: 'پزشک' },
|
||||
{ key: 'secretary', label: 'منشی' },
|
||||
{ key: 'clinic', label: 'کلینیک' },
|
||||
{ key: 'representation', label: 'نماینده' },
|
||||
{ key: 'patient', label: 'بیمار' },
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user