forked from rajun/ar-test
19 lines
753 B
TypeScript
19 lines
753 B
TypeScript
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<AdminDialogs | null>(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;
|
|
}
|