import { action, makeObservable, observable } from "mobx";
// types
import { RootStore } from "store/root.store";
import { IUserLite } from "@plane/types";
import { IProjectMemberStore, ProjectMemberStore } from "./project-member.store";
import { IWorkspaceMemberStore, WorkspaceMemberStore } from "./workspace-member.store";
export interface IMemberRootStore {
// observables
memberMap: Record<string, IUserLite>;
// computed actions
getUserDetails: (userId: string) => IUserLite | undefined;
// sub-stores
workspace: IWorkspaceMemberStore;
project: IProjectMemberStore;
}
export class MemberRootStore implements IMemberRootStore {
memberMap: Record<string, IUserLite> = {};
constructor(_rootStore: RootStore) {
makeObservable(this, {
memberMap: observable,
getUserDetails: action,
});
this.workspace = new WorkspaceMemberStore(this, _rootStore);
this.project = new ProjectMemberStore(this, _rootStore);
/**
* @description get user details rom userId
* @param userId
*/
getUserDetails = (userId: string): IUserLite | undefined => this.memberMap?.[userId] ?? undefined;