issue data store

This commit is contained in:
rahulramesha 2024-03-05 15:53:06 +05:30
parent 1fffc90cea
commit 5a23cf373e
2 changed files with 39 additions and 0 deletions

View File

@ -1,10 +1,13 @@
import { IIssueData, IssueData } from "./issue.data.store";
import { IWorkspaceData, WorkspaceData } from "./workspace.data.store";
export class DataStore {
workspace: IWorkspaceData;
issue: IIssueData;
constructor() {
this.workspace = new WorkspaceData(this);
this.issue = new IssueData(this);
}
resetOnSignout() {}

View File

@ -0,0 +1,36 @@
import { makeObservable, observable } from "mobx";
import { DataStore } from ".";
import { TIssue } from "@plane/types";
import { set } from "lodash";
export interface IIssueData {
issueMap: Record<string, any>;
addIssue: (issue: TIssue) => void;
deleteIssue: (issueId: string) => void;
getIssuebyId: (issueId: string) => any | undefined;
}
export class IssueData implements IIssueData {
issueMap: Record<string, any> = {};
// data store
dataStore;
constructor(_dataStore: DataStore) {
makeObservable(this, {
issueMap: observable,
});
this.dataStore = _dataStore;
}
addIssue = (issue: TIssue) => {
set(this.issueMap, [issue.id], "");
};
deleteIssue = (issueId: string) => {
delete this.issueMap[issueId];
};
getIssuebyId = (issueId: string) => this.issueMap[issueId];
}