feat: add admin dialogs context
This commit is contained in:
parent
0301549b75
commit
1538ea6426
18
app/hooks/admin/use-admin-dialogs.ts
Normal file
18
app/hooks/admin/use-admin-dialogs.ts
Normal 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;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user