feat: add doctor_uuid support in authStore and update DoctorDetailPage to prioritize doctorUuid
This commit is contained in:
@@ -2159,7 +2159,8 @@ export default function DoctorDetailPage({ isOwnProfile = false }: { isOwnProfil
|
||||
const qc = useQueryClient();
|
||||
const primaryRole = useAuthStore(s => s.primaryRole);
|
||||
const dbUuid = useAuthStore(s => s.dbUuid);
|
||||
const uuid = isOwnProfile ? (dbUuid ?? undefined) : paramUuid;
|
||||
const doctorUuid = useAuthStore(s => s.doctorUuid);
|
||||
const uuid = isOwnProfile ? (doctorUuid ?? dbUuid ?? undefined) : paramUuid;
|
||||
|
||||
const [editOpen, setEditOpen] = useState(searchParams.get('edit') === '1');
|
||||
const [deleteOpen, setDeleteOpen] = useState(false);
|
||||
|
||||
@@ -6,6 +6,7 @@ export interface ContextItem {
|
||||
db_uuid: string;
|
||||
name: string;
|
||||
role: 'admin' | 'clinic' | 'doctor' | 'secretary' | 'user';
|
||||
doctor_uuid?: string;
|
||||
permissions?: Record<string, any>;
|
||||
}
|
||||
|
||||
@@ -18,6 +19,7 @@ interface AuthState {
|
||||
primaryRole: 'admin' | 'clinic' | 'doctor' | 'secretary' | 'user' | null;
|
||||
dbUuid: string | null;
|
||||
dbKey: string | null;
|
||||
doctorUuid: string | null;
|
||||
context: ContextItem | null;
|
||||
availableContexts: ContextItem[];
|
||||
|
||||
@@ -61,6 +63,7 @@ export const useAuthStore = create<AuthState>()(
|
||||
primaryRole: null,
|
||||
dbUuid: null,
|
||||
dbKey: null,
|
||||
doctorUuid: null,
|
||||
context: null,
|
||||
availableContexts: [],
|
||||
|
||||
@@ -79,6 +82,7 @@ export const useAuthStore = create<AuthState>()(
|
||||
primaryRole: null,
|
||||
dbUuid: null,
|
||||
dbKey: null,
|
||||
doctorUuid: null,
|
||||
context: null,
|
||||
availableContexts: [],
|
||||
}),
|
||||
@@ -94,6 +98,7 @@ export const useAuthStore = create<AuthState>()(
|
||||
primaryRole: d.primary_role ?? null,
|
||||
dbUuid: d.db_uuid ?? null,
|
||||
dbKey: d.db_key ?? null,
|
||||
doctorUuid: d.doctor_uuid ?? null,
|
||||
context: d.context ?? null,
|
||||
availableContexts: d.available_contexts ?? [],
|
||||
});
|
||||
@@ -111,6 +116,7 @@ export const useAuthStore = create<AuthState>()(
|
||||
set({
|
||||
dbUuid: res.data.db_uuid,
|
||||
dbKey: res.data.db_key,
|
||||
doctorUuid: res.data.context?.doctor_uuid ?? get().doctorUuid,
|
||||
context: res.data.context,
|
||||
primaryRole: res.data.context?.role ?? null,
|
||||
});
|
||||
@@ -128,6 +134,7 @@ export const useAuthStore = create<AuthState>()(
|
||||
primaryRole: s.primaryRole,
|
||||
dbUuid: s.dbUuid,
|
||||
dbKey: s.dbKey,
|
||||
doctorUuid: s.doctorUuid,
|
||||
context: s.context,
|
||||
availableContexts: s.availableContexts,
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user