diff --git a/src/frontend/src/hooks/UsePluginPanels.tsx b/src/frontend/src/hooks/UsePluginPanels.tsx new file mode 100644 index 0000000000..3f730c4d43 --- /dev/null +++ b/src/frontend/src/hooks/UsePluginPanels.tsx @@ -0,0 +1,58 @@ +import { useTimeout } from '@mantine/hooks'; +import { Icon24Hours } from '@tabler/icons-react'; +import { ReactNode, useEffect, useMemo, useState } from 'react'; + +import { PanelType } from '../components/nav/Panel'; + +export interface PluginPanelState extends PanelType { + pluginKey: string; + targetType: string; + targetId?: string | number | null; +} + +export function usePluginPanel({ + pluginKey, + panelName, + targetModel, + targetId +}: { + pluginKey: string; + panelName: string; + targetModel: string; + targetId?: string | number | null; +}): PluginPanelState { + // TODO: Query to fetch the "content" for the plugin + + const [loaded, setLoaded] = useState(false); + + const { start } = useTimeout(() => setLoaded(true), 5000); + + useEffect(() => { + start(); + console.log('starting timer!'); + }, []); + + const content = useMemo(() => { + return loaded ? ( + 'plugin content loaded!' + ) : ( +
+

Plugin content goes here...

+

Plugin Key: {pluginKey}

+

Panel Name: {panelName}

+

Target Model: {targetModel}

+

Target ID: {targetId}

+
+ ); + }, [loaded, pluginKey, panelName, targetModel, targetId]); + + return { + content: content, + name: panelName, + pluginKey: pluginKey, + targetType: targetModel, + targetId: targetId, + label: 'A plugin panel', + icon: + }; +}