socket added for 3d and floating Widget
This commit is contained in:
33
app/src/store/useZone3DWidgetStore.ts
Normal file
33
app/src/store/useZone3DWidgetStore.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { create } from "zustand";
|
||||
|
||||
type WidgetData = {
|
||||
id: string;
|
||||
type: string;
|
||||
position: [number, number, number];
|
||||
};
|
||||
|
||||
type ZoneWidgetStore = {
|
||||
zoneWidgetData: Record<string, WidgetData[]>;
|
||||
setZoneWidgetData: (zoneId: string, widgets: WidgetData[]) => void;
|
||||
addWidget: (zoneId: string, widget: WidgetData) => void;
|
||||
};
|
||||
|
||||
export const useZoneWidgetStore = create<ZoneWidgetStore>((set) => ({
|
||||
zoneWidgetData: {},
|
||||
|
||||
setZoneWidgetData: (zoneId, widgets) =>
|
||||
set((state) => ({
|
||||
zoneWidgetData: {
|
||||
...state.zoneWidgetData,
|
||||
[zoneId]: widgets,
|
||||
},
|
||||
})),
|
||||
|
||||
addWidget: (zoneId, widget) =>
|
||||
set((state) => ({
|
||||
zoneWidgetData: {
|
||||
...state.zoneWidgetData,
|
||||
[zoneId]: [...(state.zoneWidgetData[zoneId] || []), widget],
|
||||
},
|
||||
})),
|
||||
}));
|
||||
Reference in New Issue
Block a user