diff --git a/app/hooks/admin/use-admin-dialogs.ts b/app/hooks/admin/use-admin-dialogs.ts new file mode 100644 index 0000000..c5df16a --- /dev/null +++ b/app/hooks/admin/use-admin-dialogs.ts @@ -0,0 +1,18 @@ +import { createContext, useContext } from 'react'; +import type { ArAsset } from '~/types/asset'; +import type { Project } from '~/types/project'; + +export interface AdminDialogs { + openProject: (project?: Project) => void; + openAsset: (options?: { asset?: ArAsset; projectId?: string }) => void; + confirmDeleteAsset: (asset: ArAsset, onDeleted?: () => void) => void; +} + +export const AdminDialogsContext = createContext(null); + +// Opens the shared project / asset dialogs rendered once by the admin layout +export function useAdminDialogs(): AdminDialogs { + const dialogs = useContext(AdminDialogsContext); + if (!dialogs) throw new Error('useAdminDialogs must be used inside AdminDialogsProvider'); + return dialogs; +}