feat(clinic): allow representation role to view clinic details without edit permissions
This commit is contained in:
@@ -165,7 +165,7 @@ export default function App() {
|
||||
<Route path="my-clinic" element={<RoleRoute roles={['clinic']}><MyClinicPage /></RoleRoute>} />
|
||||
|
||||
{/* ادمین + کلینیک */}
|
||||
<Route path="clinics/:uuid" element={<RoleRoute roles={['admin', 'clinic']}><ClinicDetailPage /></RoleRoute>} />
|
||||
<Route path="clinics/:uuid" element={<RoleRoute roles={['admin', 'clinic', 'representation']}><ClinicDetailPage /></RoleRoute>} />
|
||||
|
||||
{/* فقط ادمین — کلینیک از طریق دعوتنامه در صفحه کلینیک خود دکتر اضافه میکند */}
|
||||
<Route path="representation-settlement" element={<RoleRoute roles={['representation']}><RepresentationSettlementPage /></RoleRoute>} />
|
||||
|
||||
@@ -480,6 +480,8 @@ export default function ClinicDetailPage() {
|
||||
const dbUuid = useAuthStore(s => s.dbUuid);
|
||||
const authToken = useAuthStore(s => s.token);
|
||||
const isOwner = primaryRole === 'clinic' && dbUuid === uuid;
|
||||
// نماینده فقط مشاهده میکند؛ هیچ بخشی قابل ویرایش نیست.
|
||||
const isReadOnly = primaryRole === 'representation';
|
||||
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
@@ -759,9 +761,11 @@ export default function ClinicDetailPage() {
|
||||
</div>
|
||||
</div>
|
||||
<div style={{ display: 'flex', gap: 8 }}>
|
||||
<button className="btn ghost sm" onClick={() => openEdit()}>
|
||||
<PencilIcon style={{ width: 15, height: 15 }} /> ویرایش
|
||||
</button>
|
||||
{!isReadOnly && (
|
||||
<button className="btn ghost sm" onClick={() => openEdit()}>
|
||||
<PencilIcon style={{ width: 15, height: 15 }} /> ویرایش
|
||||
</button>
|
||||
)}
|
||||
{primaryRole === 'admin' && (
|
||||
<>
|
||||
<button className={`btn sm ${clinic.is_active ? 'soft' : 'primary'}`}
|
||||
@@ -794,16 +798,20 @@ export default function ClinicDetailPage() {
|
||||
{clinic.name?.[0] ?? '?'}
|
||||
</div>
|
||||
)}
|
||||
<button onClick={() => logoInputRef.current?.click()} disabled={logoUploading}
|
||||
style={{
|
||||
position: 'absolute', insetInlineEnd: -6, bottom: -6, width: 24, height: 24,
|
||||
borderRadius: '50%', background: 'var(--primary)', border: '2px solid var(--surface)',
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer',
|
||||
}}>
|
||||
<CameraIcon style={{ width: 12, height: 12, color: '#fff' }} />
|
||||
</button>
|
||||
<input ref={logoInputRef} type="file" accept="image/*" style={{ display: 'none' }}
|
||||
onChange={e => e.target.files?.[0] && handleLogoUpload(e.target.files[0])} />
|
||||
{!isReadOnly && (
|
||||
<>
|
||||
<button onClick={() => logoInputRef.current?.click()} disabled={logoUploading}
|
||||
style={{
|
||||
position: 'absolute', insetInlineEnd: -6, bottom: -6, width: 24, height: 24,
|
||||
borderRadius: '50%', background: 'var(--primary)', border: '2px solid var(--surface)',
|
||||
display: 'flex', alignItems: 'center', justifyContent: 'center', cursor: 'pointer',
|
||||
}}>
|
||||
<CameraIcon style={{ width: 12, height: 12, color: '#fff' }} />
|
||||
</button>
|
||||
<input ref={logoInputRef} type="file" accept="image/*" style={{ display: 'none' }}
|
||||
onChange={e => e.target.files?.[0] && handleLogoUpload(e.target.files[0])} />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ fontSize: 20, fontWeight: 700 }}>{clinic.name}</div>
|
||||
@@ -847,9 +855,11 @@ export default function ClinicDetailPage() {
|
||||
دعوتنامهها ({formatNumber(invitationList.length)})
|
||||
</button>
|
||||
</div>
|
||||
<button className="btn primary sm" onClick={() => setInviteOpen(true)}>
|
||||
<EnvelopeIcon style={{ width: 14, height: 14 }} /> دعوت پزشک
|
||||
</button>
|
||||
{!isReadOnly && (
|
||||
<button className="btn primary sm" onClick={() => setInviteOpen(true)}>
|
||||
<EnvelopeIcon style={{ width: 14, height: 14 }} /> دعوت پزشک
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Doctors tab */}
|
||||
@@ -937,36 +947,38 @@ export default function ClinicDetailPage() {
|
||||
<span className={`badge ${isExpired ? 'gray' : statusInfo.cls}`} style={{ fontSize: 11 }}>
|
||||
<span className="bdot" />{isExpired ? 'منقضی' : statusInfo.label}
|
||||
</span>
|
||||
<div style={{ display: 'flex', gap: 4 }}>
|
||||
{inv.status === 'pending' && (
|
||||
{!isReadOnly && (
|
||||
<div style={{ display: 'flex', gap: 4 }}>
|
||||
{inv.status === 'pending' && (
|
||||
<button
|
||||
className="mini-btn"
|
||||
title="ارسال مجدد"
|
||||
disabled={resendInvMut.isPending}
|
||||
onClick={() => resendInvMut.mutate(inv.uuid)}
|
||||
>
|
||||
<ArrowPathIcon style={{ width: 13, height: 13 }} />
|
||||
</button>
|
||||
)}
|
||||
{inv.status !== 'removed' && inv.status !== 'accepted' && (
|
||||
<button
|
||||
className="mini-btn"
|
||||
title="تعلیق"
|
||||
disabled={changeInvStatusMut.isPending}
|
||||
onClick={() => changeInvStatusMut.mutate({ invUuid: inv.uuid, status: inv.status === 'suspended' ? 'pending' : 'suspended' })}
|
||||
>
|
||||
<NoSymbolIcon style={{ width: 13, height: 13 }} />
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="mini-btn"
|
||||
title="ارسال مجدد"
|
||||
disabled={resendInvMut.isPending}
|
||||
onClick={() => resendInvMut.mutate(inv.uuid)}
|
||||
className="mini-btn danger"
|
||||
title="حذف"
|
||||
disabled={deleteInvMut.isPending}
|
||||
onClick={() => deleteInvMut.mutate(inv.uuid)}
|
||||
>
|
||||
<ArrowPathIcon style={{ width: 13, height: 13 }} />
|
||||
<TrashIcon style={{ width: 13, height: 13 }} />
|
||||
</button>
|
||||
)}
|
||||
{inv.status !== 'removed' && inv.status !== 'accepted' && (
|
||||
<button
|
||||
className="mini-btn"
|
||||
title="تعلیق"
|
||||
disabled={changeInvStatusMut.isPending}
|
||||
onClick={() => changeInvStatusMut.mutate({ invUuid: inv.uuid, status: inv.status === 'suspended' ? 'pending' : 'suspended' })}
|
||||
>
|
||||
<NoSymbolIcon style={{ width: 13, height: 13 }} />
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className="mini-btn danger"
|
||||
title="حذف"
|
||||
disabled={deleteInvMut.isPending}
|
||||
onClick={() => deleteInvMut.mutate(inv.uuid)}
|
||||
>
|
||||
<TrashIcon style={{ width: 13, height: 13 }} />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
@@ -982,13 +994,17 @@ export default function ClinicDetailPage() {
|
||||
<b style={{ fontSize: 14 }}>
|
||||
گالری تصاویر ({formatNumber((clinic.images_clinic ?? []).filter(i => i?.url).length)}/{formatNumber(MAX_GALLERY_IMAGES)})
|
||||
</b>
|
||||
<button className="btn ghost sm" onClick={() => galleryInputRef.current?.click()}
|
||||
disabled={galleryUploading || (clinic.images_clinic ?? []).filter(i => i?.url).length >= MAX_GALLERY_IMAGES}>
|
||||
<PlusIcon style={{ width: 14, height: 14 }} />
|
||||
{galleryUploading ? 'در حال آپلود...' : 'افزودن تصویر'}
|
||||
</button>
|
||||
<input ref={galleryInputRef} type="file" accept="image/*" multiple style={{ display: 'none' }}
|
||||
onChange={e => e.target.files?.length && handleGalleryUpload(e.target.files)} />
|
||||
{!isReadOnly && (
|
||||
<>
|
||||
<button className="btn ghost sm" onClick={() => galleryInputRef.current?.click()}
|
||||
disabled={galleryUploading || (clinic.images_clinic ?? []).filter(i => i?.url).length >= MAX_GALLERY_IMAGES}>
|
||||
<PlusIcon style={{ width: 14, height: 14 }} />
|
||||
{galleryUploading ? 'در حال آپلود...' : 'افزودن تصویر'}
|
||||
</button>
|
||||
<input ref={galleryInputRef} type="file" accept="image/*" multiple style={{ display: 'none' }}
|
||||
onChange={e => e.target.files?.length && handleGalleryUpload(e.target.files)} />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{(clinic.images_clinic ?? []).length === 0 ? (
|
||||
<div className="empty" style={{ padding: '20px 0' }}>
|
||||
@@ -999,15 +1015,17 @@ export default function ClinicDetailPage() {
|
||||
{clinic.images_clinic.filter(img => img?.url).map((img, i) => (
|
||||
<div key={i} style={{ position: 'relative', borderRadius: 8, overflow: 'hidden', aspectRatio: '1', background: 'var(--surface-2, var(--bg))' }}>
|
||||
<img src={img.url} alt="" style={{ width: '100%', height: '100%', objectFit: 'cover' }} />
|
||||
<button
|
||||
type="button"
|
||||
className="mini-btn danger"
|
||||
title="حذف تصویر"
|
||||
onClick={() => setDeleteImageConfirm(img.url)}
|
||||
style={{ position: 'absolute', top: 6, left: 6 }}
|
||||
>
|
||||
<TrashIcon style={{ width: 14, height: 14 }} />
|
||||
</button>
|
||||
{!isReadOnly && (
|
||||
<button
|
||||
type="button"
|
||||
className="mini-btn danger"
|
||||
title="حذف تصویر"
|
||||
onClick={() => setDeleteImageConfirm(img.url)}
|
||||
style={{ position: 'absolute', top: 6, left: 6 }}
|
||||
>
|
||||
<TrashIcon style={{ width: 14, height: 14 }} />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
@@ -1036,9 +1054,11 @@ export default function ClinicDetailPage() {
|
||||
<div className="card card-pad">
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 12 }}>
|
||||
<b style={{ fontSize: 13 }}>تخصصها، بیمه و خدمات</b>
|
||||
<button className="btn ghost sm" style={{ fontSize: 12 }} onClick={() => openEdit()}>
|
||||
<PencilIcon style={{ width: 13, height: 13 }} /> ویرایش
|
||||
</button>
|
||||
{!isReadOnly && (
|
||||
<button className="btn ghost sm" style={{ fontSize: 12 }} onClick={() => openEdit()}>
|
||||
<PencilIcon style={{ width: 13, height: 13 }} /> ویرایش
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div style={{ display: 'flex', flexDirection: 'column', gap: 14 }}>
|
||||
@@ -1091,7 +1111,7 @@ export default function ClinicDetailPage() {
|
||||
)}
|
||||
|
||||
{/* Clinic Addresses Section */}
|
||||
{(isOwner || primaryRole === 'admin') && (
|
||||
{(isOwner || primaryRole === 'admin' || isReadOnly) && (
|
||||
<div className="card">
|
||||
<div className="toolbar" style={{ padding: '12px 16px' }}>
|
||||
<div style={{ fontWeight: 600, fontSize: 14 }}>
|
||||
|
||||
Reference in New Issue
Block a user