Files
nexus-hub/stores/componentStore.ts
2025-03-20 14:53:02 +00:00

29 lines
743 B
TypeScript

import { DraggablePropsType } from "@/components/Draggable/Draggable";
import { makeAutoObservable } from "mobx";
class ComponentsStore {
components:DraggablePropsType[] = [];
constructor() {
makeAutoObservable(this);
}
initComponent(componentsList:DraggablePropsType[]) {
this.components = componentsList || [];
}
changeComponent(componentsList:DraggablePropsType) {
this.components = this.components.map(item => {
if (item.id !== componentsList.id) {
return item;
}
return componentsList;
})
}
delectComponent(componentsList:DraggablePropsType) {
this.components = this.components.filter(item => item.id !== componentsList.id);
}
}
export default new ComponentsStore();