From 1538ea64261ce1ab2065b4e18d75321d208faadd Mon Sep 17 00:00:00 2001 From: rajun Date: Tue, 27 Oct 2026 16:28:53 +0530 Subject: [PATCH] feat: add admin dialogs context --- app/hooks/admin/use-admin-dialogs.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 app/hooks/admin/use-admin-dialogs.ts 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; +}