2025-03-25 17:34:20 +05:30
|
|
|
import { create } from "zustand";
|
|
|
|
|
|
|
|
|
|
// type Side = "top" | "bottom" | "left" | "right";
|
|
|
|
|
|
|
|
|
|
export interface Widget {
|
|
|
|
|
id: string;
|
|
|
|
|
type: string;
|
|
|
|
|
title: string;
|
|
|
|
|
panel: string;
|
|
|
|
|
data: any;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface Template {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
panelOrder: string[];
|
|
|
|
|
widgets: Widget[];
|
|
|
|
|
snapshot?: string | null; // Add an optional image property (base64)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface TemplateStore {
|
|
|
|
|
templates: Template[];
|
|
|
|
|
addTemplate: (template: Template) => void;
|
|
|
|
|
removeTemplate: (id: string) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const useTemplateStore = create<TemplateStore>((set) => ({
|
|
|
|
|
templates: [],
|
|
|
|
|
addTemplate: (template) =>
|
|
|
|
|
set((state) => ({
|
|
|
|
|
templates: [...state.templates, template],
|
|
|
|
|
})),
|
|
|
|
|
removeTemplate: (id) =>
|
|
|
|
|
set((state) => ({
|
|
|
|
|
templates: state.templates.filter((t) => t.id !== id),
|
|
|
|
|
})),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
export default useTemplateStore;
|