38 lines
923 B
TypeScript
38 lines
923 B
TypeScript
|
|
import { create } from "zustand";
|
||
|
|
|
||
|
|
export type PanelContentType = "object-detail" | "ai-chat" | null;
|
||
|
|
|
||
|
|
export type PanelDetailTab = "details" | "activity" | "comments";
|
||
|
|
|
||
|
|
interface PanelState {
|
||
|
|
isOpen: boolean;
|
||
|
|
content: PanelContentType;
|
||
|
|
objectId: string | null;
|
||
|
|
activeTab: PanelDetailTab;
|
||
|
|
open: (type: Exclude<PanelContentType, null>, objectId?: string | null) => void;
|
||
|
|
close: () => void;
|
||
|
|
setActiveTab: (tab: PanelDetailTab) => void;
|
||
|
|
}
|
||
|
|
|
||
|
|
export const usePanelStore = create<PanelState>((set) => ({
|
||
|
|
isOpen: false,
|
||
|
|
content: null,
|
||
|
|
objectId: null,
|
||
|
|
activeTab: "details",
|
||
|
|
open: (type, objectId = null) =>
|
||
|
|
set({
|
||
|
|
isOpen: true,
|
||
|
|
content: type,
|
||
|
|
objectId: objectId ?? null,
|
||
|
|
activeTab: "details",
|
||
|
|
}),
|
||
|
|
close: () =>
|
||
|
|
set({
|
||
|
|
isOpen: false,
|
||
|
|
content: null,
|
||
|
|
objectId: null,
|
||
|
|
activeTab: "details",
|
||
|
|
}),
|
||
|
|
setActiveTab: (tab) => set({ activeTab: tab }),
|
||
|
|
}));
|