feat: add admin dialogs context

This commit is contained in:
rajun 2026-10-27 16:28:53 +05:30
parent 0301549b75
commit 1538ea6426

View File

@ -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<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;
}