plane/web/store/application/router.store.ts

67 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-12-11 14:45:07 +00:00
import { action, makeObservable, observable } from "mobx";
2023-12-12 07:39:30 +00:00
import { ParsedUrlQuery } from "querystring";
2023-12-11 14:45:07 +00:00
export interface IRouterStore {
2023-12-12 07:39:30 +00:00
query: ParsedUrlQuery;
setQuery: (query: ParsedUrlQuery) => void;
workspaceSlug: string | undefined;
projectId: string | undefined;
cycleId: string | undefined;
moduleId: string | undefined;
viewId: string | undefined;
userId: string | undefined;
peekId: string | undefined;
2023-12-11 14:45:07 +00:00
}
export class RouterStore implements IRouterStore {
2023-12-12 07:39:30 +00:00
query: ParsedUrlQuery = {};
2023-12-11 14:45:07 +00:00
constructor() {
makeObservable(this, {
query: observable,
setQuery: action,
2023-12-12 07:39:30 +00:00
//computed
workspaceSlug: action,
projectId: action,
cycleId: action,
moduleId: action,
viewId: action,
userId: action,
peekId: action,
2023-12-11 14:45:07 +00:00
});
}
2023-12-12 07:39:30 +00:00
setQuery(query: ParsedUrlQuery) {
2023-12-11 14:45:07 +00:00
this.query = query;
}
2023-12-12 07:39:30 +00:00
get workspaceSlug() {
return this.query?.workspace_slug?.toString();
}
get projectId() {
return this.query?.projectId?.toString();
}
get moduleId() {
return this.query?.moduleId?.toString();
}
get cycleId() {
return this.query?.cycleId?.toString();
}
get viewId() {
return this.query?.viewId?.toString();
}
get userId() {
return this.query?.userId?.toString();
}
get peekId() {
return this.query?.peekId?.toString();
}
2023-12-11 14:45:07 +00:00
}