feat: init
This commit is contained in:
3
apps/web/core/hooks/store/estimates/index.ts
Normal file
3
apps/web/core/hooks/store/estimates/index.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from "./use-project-estimate";
|
||||
export * from "./use-estimate";
|
||||
export * from "./use-estimate-point";
|
||||
16
apps/web/core/hooks/store/estimates/use-estimate-point.ts
Normal file
16
apps/web/core/hooks/store/estimates/use-estimate-point.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// mobx store
|
||||
import type { IEstimatePoint } from "@/store/estimates/estimate-point";
|
||||
|
||||
export const useEstimatePoint = (
|
||||
estimateId: string | undefined,
|
||||
estimatePointId: string | undefined
|
||||
): IEstimatePoint => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useEstimatePoint must be used within StoreProvider");
|
||||
if (!estimateId || !estimatePointId) return {} as IEstimatePoint;
|
||||
|
||||
return context.projectEstimate.estimates?.[estimateId]?.estimatePoints?.[estimatePointId] || {};
|
||||
};
|
||||
13
apps/web/core/hooks/store/estimates/use-estimate.ts
Normal file
13
apps/web/core/hooks/store/estimates/use-estimate.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// mobx store
|
||||
import type { IEstimate } from "@/plane-web/store/estimates/estimate";
|
||||
|
||||
export const useEstimate = (estimateId: string | undefined): IEstimate => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useEstimate must be used within StoreProvider");
|
||||
if (!estimateId) return {} as IEstimate;
|
||||
|
||||
return context.projectEstimate.estimates?.[estimateId] ?? {};
|
||||
};
|
||||
12
apps/web/core/hooks/store/estimates/use-project-estimate.ts
Normal file
12
apps/web/core/hooks/store/estimates/use-project-estimate.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { useContext } from "react";
|
||||
// context
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// mobx store
|
||||
import type { IProjectEstimateStore } from "@/store/estimates/project-estimate.store";
|
||||
|
||||
export const useProjectEstimates = (): IProjectEstimateStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useProjectPage must be used within StoreProvider");
|
||||
|
||||
return context.projectEstimate;
|
||||
};
|
||||
2
apps/web/core/hooks/store/notifications/index.ts
Normal file
2
apps/web/core/hooks/store/notifications/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./use-workspace-notifications";
|
||||
export * from "./use-notification";
|
||||
13
apps/web/core/hooks/store/notifications/use-notification.ts
Normal file
13
apps/web/core/hooks/store/notifications/use-notification.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// mobx store
|
||||
import type { INotification } from "@/store/notifications/notification";
|
||||
|
||||
export const useNotification = (notificationId: string | undefined): INotification => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useNotification must be used within StoreProvider");
|
||||
if (!notificationId) return {} as INotification;
|
||||
|
||||
return context.workspaceNotification.notifications?.[notificationId] ?? {};
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { useContext } from "react";
|
||||
// context
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// mobx store
|
||||
import type { IWorkspaceNotificationStore } from "@/store/notifications/workspace-notifications.store";
|
||||
|
||||
export const useWorkspaceNotifications = (): IWorkspaceNotificationStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useWorkspaceNotifications must be used within StoreProvider");
|
||||
|
||||
return context.workspaceNotification;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-analytics.ts
Normal file
11
apps/web/core/hooks/store/use-analytics.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IAnalyticsStore } from "@/plane-web/store/analytics.store";
|
||||
|
||||
export const useAnalytics = (): IAnalyticsStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useAnalytics must be used within StoreProvider");
|
||||
return context.analytics;
|
||||
};
|
||||
10
apps/web/core/hooks/store/use-app-theme.ts
Normal file
10
apps/web/core/hooks/store/use-app-theme.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useContext } from "react";
|
||||
// store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
import type { IThemeStore } from "@/store/theme.store";
|
||||
|
||||
export const useAppTheme = (): IThemeStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useAppTheme must be used within StoreProvider");
|
||||
return context.theme;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-calendar-view.ts
Normal file
11
apps/web/core/hooks/store/use-calendar-view.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { ICalendarStore } from "@/store/issue/issue_calendar_view.store";
|
||||
|
||||
export const useCalendarView = (): ICalendarStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useLabel must be used within StoreProvider");
|
||||
return context.issue.issueCalendarView;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-command-palette.ts
Normal file
11
apps/web/core/hooks/store/use-command-palette.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { ICommandPaletteStore } from "@/plane-web/store/command-palette.store";
|
||||
|
||||
export const useCommandPalette = (): ICommandPaletteStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useCommandPalette must be used within StoreProvider");
|
||||
return context.commandPalette;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-cycle-filter.ts
Normal file
11
apps/web/core/hooks/store/use-cycle-filter.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { ICycleFilterStore } from "@/store/cycle_filter.store";
|
||||
|
||||
export const useCycleFilter = (): ICycleFilterStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useCycleFilter must be used within StoreProvider");
|
||||
return context.cycleFilter;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-cycle.ts
Normal file
11
apps/web/core/hooks/store/use-cycle.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { ICycleStore } from "@/plane-web/store/cycle";
|
||||
|
||||
export const useCycle = (): ICycleStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useCycle must be used within StoreProvider");
|
||||
return context.cycle;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-dashboard.ts
Normal file
11
apps/web/core/hooks/store/use-dashboard.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IDashboardStore } from "@/store/dashboard.store";
|
||||
|
||||
export const useDashboard = (): IDashboardStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useDashboard must be used within StoreProvider");
|
||||
return context.dashboard;
|
||||
};
|
||||
10
apps/web/core/hooks/store/use-editor-asset.ts
Normal file
10
apps/web/core/hooks/store/use-editor-asset.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useContext } from "react";
|
||||
// store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
import type { IEditorAssetStore } from "@/store/editor/asset.store";
|
||||
|
||||
export const useEditorAsset = (): IEditorAssetStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useEditorAsset must be used within StoreProvider");
|
||||
return context.editorAssetStore;
|
||||
};
|
||||
10
apps/web/core/hooks/store/use-favorite.ts
Normal file
10
apps/web/core/hooks/store/use-favorite.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
import type { IFavoriteStore } from "@/store/favorite.store";
|
||||
|
||||
export const useFavorite = (): IFavoriteStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useFavorites must be used within StoreProvider");
|
||||
return context.favorite;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-global-view.ts
Normal file
11
apps/web/core/hooks/store/use-global-view.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IGlobalViewStore } from "@/plane-web/store/global-view.store";
|
||||
|
||||
export const useGlobalView = (): IGlobalViewStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useGlobalView must be used within StoreProvider");
|
||||
return context.globalView;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-home.ts
Normal file
11
apps/web/core/hooks/store/use-home.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IHomeStore } from "@/store/workspace/home";
|
||||
|
||||
export const useHome = (): IHomeStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useDashboard must be used within StoreProvider");
|
||||
return context.workspaceRoot.home;
|
||||
};
|
||||
10
apps/web/core/hooks/store/use-inbox-issues.ts
Normal file
10
apps/web/core/hooks/store/use-inbox-issues.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
import type { IInboxIssueStore } from "@/store/inbox/inbox-issue.store";
|
||||
|
||||
export const useInboxIssues = (inboxIssueId: string): IInboxIssueStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useInboxIssues must be used within StoreProvider");
|
||||
return context.projectInbox.getIssueInboxByIssueId(inboxIssueId);
|
||||
};
|
||||
10
apps/web/core/hooks/store/use-instance.ts
Normal file
10
apps/web/core/hooks/store/use-instance.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useContext } from "react";
|
||||
// store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
import type { IInstanceStore } from "@/store/instance.store";
|
||||
|
||||
export const useInstance = (): IInstanceStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useInstance must be used within StoreProvider");
|
||||
return context.instance;
|
||||
};
|
||||
14
apps/web/core/hooks/store/use-issue-detail.ts
Normal file
14
apps/web/core/hooks/store/use-issue-detail.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { useContext } from "react";
|
||||
import type { TIssueServiceType } from "@plane/types";
|
||||
import { EIssueServiceType } from "@plane/types";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IIssueDetail } from "@/plane-web/store/issue/issue-details/root.store";
|
||||
|
||||
export const useIssueDetail = (serviceType: TIssueServiceType = EIssueServiceType.ISSUES): IIssueDetail => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useIssueDetail must be used within StoreProvider");
|
||||
if (serviceType === EIssueServiceType.EPICS) return context.issue.epicDetail;
|
||||
else return context.issue.issueDetail;
|
||||
};
|
||||
157
apps/web/core/hooks/store/use-issues.ts
Normal file
157
apps/web/core/hooks/store/use-issues.ts
Normal file
@@ -0,0 +1,157 @@
|
||||
import { useContext } from "react";
|
||||
import { merge } from "lodash-es";
|
||||
import type { TIssueMap } from "@plane/types";
|
||||
import { EIssuesStoreType } from "@plane/types";
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// plane web types
|
||||
import type { IProjectEpics, IProjectEpicsFilter } from "@/plane-web/store/issue/epic";
|
||||
// types
|
||||
import type { ITeamIssues, ITeamIssuesFilter } from "@/plane-web/store/issue/team";
|
||||
import type { ITeamProjectWorkItemsFilter, ITeamProjectWorkItems } from "@/plane-web/store/issue/team-project";
|
||||
import type { ITeamViewIssues, ITeamViewIssuesFilter } from "@/plane-web/store/issue/team-views";
|
||||
import type { IWorkspaceIssues } from "@/plane-web/store/issue/workspace/issue.store";
|
||||
import type { IArchivedIssues, IArchivedIssuesFilter } from "@/store/issue/archived";
|
||||
import type { ICycleIssues, ICycleIssuesFilter } from "@/store/issue/cycle";
|
||||
import type { IModuleIssues, IModuleIssuesFilter } from "@/store/issue/module";
|
||||
import type { IProfileIssues, IProfileIssuesFilter } from "@/store/issue/profile";
|
||||
import type { IProjectIssues, IProjectIssuesFilter } from "@/store/issue/project";
|
||||
import type { IProjectViewIssues, IProjectViewIssuesFilter } from "@/store/issue/project-views";
|
||||
import type { IWorkspaceIssuesFilter } from "@/store/issue/workspace";
|
||||
import type { IWorkspaceDraftIssues, IWorkspaceDraftIssuesFilter } from "@/store/issue/workspace-draft";
|
||||
// constants
|
||||
|
||||
type defaultIssueStore = {
|
||||
issueMap: TIssueMap;
|
||||
};
|
||||
|
||||
export type TStoreIssues = {
|
||||
[EIssuesStoreType.GLOBAL]: defaultIssueStore & {
|
||||
issues: IWorkspaceIssues;
|
||||
issuesFilter: IWorkspaceIssuesFilter;
|
||||
};
|
||||
[EIssuesStoreType.WORKSPACE_DRAFT]: defaultIssueStore & {
|
||||
issues: IWorkspaceDraftIssues;
|
||||
issuesFilter: IWorkspaceDraftIssuesFilter;
|
||||
};
|
||||
[EIssuesStoreType.PROFILE]: defaultIssueStore & {
|
||||
issues: IProfileIssues;
|
||||
issuesFilter: IProfileIssuesFilter;
|
||||
};
|
||||
[EIssuesStoreType.TEAM]: defaultIssueStore & {
|
||||
issues: ITeamIssues;
|
||||
issuesFilter: ITeamIssuesFilter;
|
||||
};
|
||||
[EIssuesStoreType.PROJECT]: defaultIssueStore & {
|
||||
issues: IProjectIssues;
|
||||
issuesFilter: IProjectIssuesFilter;
|
||||
};
|
||||
[EIssuesStoreType.CYCLE]: defaultIssueStore & {
|
||||
issues: ICycleIssues;
|
||||
issuesFilter: ICycleIssuesFilter;
|
||||
};
|
||||
[EIssuesStoreType.MODULE]: defaultIssueStore & {
|
||||
issues: IModuleIssues;
|
||||
issuesFilter: IModuleIssuesFilter;
|
||||
};
|
||||
[EIssuesStoreType.TEAM_VIEW]: defaultIssueStore & {
|
||||
issues: ITeamViewIssues;
|
||||
issuesFilter: ITeamViewIssuesFilter;
|
||||
};
|
||||
[EIssuesStoreType.PROJECT_VIEW]: defaultIssueStore & {
|
||||
issues: IProjectViewIssues;
|
||||
issuesFilter: IProjectViewIssuesFilter;
|
||||
};
|
||||
[EIssuesStoreType.ARCHIVED]: defaultIssueStore & {
|
||||
issues: IArchivedIssues;
|
||||
issuesFilter: IArchivedIssuesFilter;
|
||||
};
|
||||
[EIssuesStoreType.DEFAULT]: defaultIssueStore & {
|
||||
issues: IProjectIssues;
|
||||
issuesFilter: IProjectIssuesFilter;
|
||||
};
|
||||
[EIssuesStoreType.EPIC]: defaultIssueStore & {
|
||||
issues: IProjectEpics;
|
||||
issuesFilter: IProjectEpicsFilter;
|
||||
};
|
||||
[EIssuesStoreType.TEAM_PROJECT_WORK_ITEMS]: defaultIssueStore & {
|
||||
issues: ITeamProjectWorkItems;
|
||||
issuesFilter: ITeamProjectWorkItemsFilter;
|
||||
};
|
||||
};
|
||||
|
||||
export const useIssues = <T extends EIssuesStoreType>(storeType?: T): TStoreIssues[T] => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useIssues must be used within StoreProvider");
|
||||
|
||||
const defaultStore: defaultIssueStore = {
|
||||
issueMap: context.issue.issues.issuesMap,
|
||||
};
|
||||
|
||||
switch (storeType) {
|
||||
case EIssuesStoreType.GLOBAL:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.workspaceIssues,
|
||||
issuesFilter: context.issue.workspaceIssuesFilter,
|
||||
}) as TStoreIssues[T];
|
||||
case EIssuesStoreType.WORKSPACE_DRAFT:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.workspaceDraftIssues,
|
||||
issuesFilter: context.issue.workspaceDraftIssuesFilter,
|
||||
}) as TStoreIssues[T];
|
||||
case EIssuesStoreType.PROFILE:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.profileIssues,
|
||||
issuesFilter: context.issue.profileIssuesFilter,
|
||||
}) as TStoreIssues[T];
|
||||
case EIssuesStoreType.TEAM:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.teamIssues,
|
||||
issuesFilter: context.issue.teamIssuesFilter,
|
||||
}) as TStoreIssues[T];
|
||||
case EIssuesStoreType.PROJECT:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.projectIssues,
|
||||
issuesFilter: context.issue.projectIssuesFilter,
|
||||
}) as TStoreIssues[T];
|
||||
case EIssuesStoreType.CYCLE:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.cycleIssues,
|
||||
issuesFilter: context.issue.cycleIssuesFilter,
|
||||
}) as TStoreIssues[T];
|
||||
case EIssuesStoreType.MODULE:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.moduleIssues,
|
||||
issuesFilter: context.issue.moduleIssuesFilter,
|
||||
}) as TStoreIssues[T];
|
||||
case EIssuesStoreType.TEAM_VIEW:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.teamViewIssues,
|
||||
issuesFilter: context.issue.teamViewIssuesFilter,
|
||||
}) as TStoreIssues[T];
|
||||
case EIssuesStoreType.PROJECT_VIEW:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.projectViewIssues,
|
||||
issuesFilter: context.issue.projectViewIssuesFilter,
|
||||
}) as TStoreIssues[T];
|
||||
case EIssuesStoreType.ARCHIVED:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.archivedIssues,
|
||||
issuesFilter: context.issue.archivedIssuesFilter,
|
||||
}) as TStoreIssues[T];
|
||||
case EIssuesStoreType.EPIC:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.projectEpics,
|
||||
issuesFilter: context.issue.projectEpicsFilter,
|
||||
}) as TStoreIssues[T];
|
||||
case EIssuesStoreType.TEAM_PROJECT_WORK_ITEMS:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.teamProjectWorkItems,
|
||||
issuesFilter: context.issue.teamProjectWorkItemsFilter,
|
||||
}) as TStoreIssues[T];
|
||||
default:
|
||||
return merge(defaultStore, {
|
||||
issues: context.issue.projectIssues,
|
||||
issuesFilter: context.issue.projectIssuesFilter,
|
||||
}) as TStoreIssues[T];
|
||||
}
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-kanban-view.ts
Normal file
11
apps/web/core/hooks/store/use-kanban-view.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IIssueKanBanViewStore } from "@/store/issue/issue_kanban_view.store";
|
||||
|
||||
export const useKanbanView = (): IIssueKanBanViewStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useLabel must be used within StoreProvider");
|
||||
return context.issue.issueKanBanView;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-label.ts
Normal file
11
apps/web/core/hooks/store/use-label.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { ILabelStore } from "@/store/label.store";
|
||||
|
||||
export const useLabel = (): ILabelStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useLabel must be used within StoreProvider");
|
||||
return context.label;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-member.ts
Normal file
11
apps/web/core/hooks/store/use-member.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types;
|
||||
import type { IMemberRootStore } from "@/store/member";
|
||||
|
||||
export const useMember = (): IMemberRootStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useMember must be used within StoreProvider");
|
||||
return context.memberRoot;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-module-filter.ts
Normal file
11
apps/web/core/hooks/store/use-module-filter.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IModuleFilterStore } from "@/store/module_filter.store";
|
||||
|
||||
export const useModuleFilter = (): IModuleFilterStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useModuleFilter must be used within StoreProvider");
|
||||
return context.moduleFilter;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-module.ts
Normal file
11
apps/web/core/hooks/store/use-module.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IModuleStore } from "@/store/module.store";
|
||||
|
||||
export const useModule = (): IModuleStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useModule must be used within StoreProvider");
|
||||
return context.module;
|
||||
};
|
||||
9
apps/web/core/hooks/store/use-multiple-select-store.ts
Normal file
9
apps/web/core/hooks/store/use-multiple-select-store.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import { useContext } from "react";
|
||||
// store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
|
||||
export const useMultipleSelectStore = () => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useMultipleSelectStore must be used within StoreProvider");
|
||||
return context.multipleSelect;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-project-filter.ts
Normal file
11
apps/web/core/hooks/store/use-project-filter.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IProjectFilterStore } from "@/store/project/project_filter.store";
|
||||
|
||||
export const useProjectFilter = (): IProjectFilterStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useProjectFilter must be used within StoreProvider");
|
||||
return context.projectRoot.projectFilter;
|
||||
};
|
||||
10
apps/web/core/hooks/store/use-project-inbox.ts
Normal file
10
apps/web/core/hooks/store/use-project-inbox.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
import type { IProjectInboxStore } from "@/plane-web/store/project-inbox.store";
|
||||
|
||||
export const useProjectInbox = (): IProjectInboxStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useProjectInbox must be used within StoreProvider");
|
||||
return context.projectInbox;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-project-publish.ts
Normal file
11
apps/web/core/hooks/store/use-project-publish.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IProjectPublishStore } from "@/store/project/project-publish.store";
|
||||
|
||||
export const useProjectPublish = (): IProjectPublishStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useProjectPublish must be used within StoreProvider");
|
||||
return context.projectRoot.publish;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-project-state.ts
Normal file
11
apps/web/core/hooks/store/use-project-state.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// Plane-web
|
||||
import type { IStateStore } from "@/plane-web/store/state.store";
|
||||
|
||||
export const useProjectState = (): IStateStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useProjectState must be used within StoreProvider");
|
||||
return context.state;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-project-view.ts
Normal file
11
apps/web/core/hooks/store/use-project-view.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IProjectViewStore } from "@/plane-web/store/project-view.store";
|
||||
|
||||
export const useProjectView = (): IProjectViewStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useProjectView must be used within StoreProvider");
|
||||
return context.projectView;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-project.ts
Normal file
11
apps/web/core/hooks/store/use-project.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IProjectStore } from "@/store/project/project.store";
|
||||
|
||||
export const useProject = (): IProjectStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useProject must be used within StoreProvider");
|
||||
return context.projectRoot.project;
|
||||
};
|
||||
10
apps/web/core/hooks/store/use-router-params.ts
Normal file
10
apps/web/core/hooks/store/use-router-params.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { useContext } from "react";
|
||||
// store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
import type { IRouterStore } from "@/store/router.store";
|
||||
|
||||
export const useRouterParams = (): IRouterStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useRouterParams must be used within StoreProvider");
|
||||
return context.router;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-transient.ts
Normal file
11
apps/web/core/hooks/store/use-transient.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { ITransientStore } from "@/store/transient.store";
|
||||
|
||||
export const useTransient = (): ITransientStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useTransient must be used within StoreProvider");
|
||||
return context.transient;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-webhook.ts
Normal file
11
apps/web/core/hooks/store/use-webhook.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IWebhookStore } from "@/store/workspace/webhook.store";
|
||||
|
||||
export const useWebhook = (): IWebhookStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useWebhook must be used within StoreProvider");
|
||||
return context.workspaceRoot.webhook;
|
||||
};
|
||||
11
apps/web/core/hooks/store/use-workspace.ts
Normal file
11
apps/web/core/hooks/store/use-workspace.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IWorkspaceRootStore } from "@/store/workspace";
|
||||
|
||||
export const useWorkspace = (): IWorkspaceRootStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useWorkspace must be used within StoreProvider");
|
||||
return context.workspaceRoot;
|
||||
};
|
||||
4
apps/web/core/hooks/store/user/index.ts
Normal file
4
apps/web/core/hooks/store/user/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from "./user-user";
|
||||
export * from "./user-user-profile";
|
||||
export * from "./user-user-settings";
|
||||
export * from "./user-permissions";
|
||||
12
apps/web/core/hooks/store/user/user-permissions.ts
Normal file
12
apps/web/core/hooks/store/user/user-permissions.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// plane web imports
|
||||
import type { IUserPermissionStore } from "@/plane-web/store/user/permission.store";
|
||||
|
||||
export const useUserPermissions = (): IUserPermissionStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useUserPermissions must be used within StoreProvider");
|
||||
|
||||
return context.user.permission;
|
||||
};
|
||||
11
apps/web/core/hooks/store/user/user-user-profile.ts
Normal file
11
apps/web/core/hooks/store/user/user-user-profile.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IUserProfileStore } from "@/store/user/profile.store";
|
||||
|
||||
export const useUserProfile = (): IUserProfileStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useUserProfile must be used within StoreProvider");
|
||||
return context.user.userProfile;
|
||||
};
|
||||
11
apps/web/core/hooks/store/user/user-user-settings.ts
Normal file
11
apps/web/core/hooks/store/user/user-user-settings.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IUserSettingsStore } from "@/store/user/settings.store";
|
||||
|
||||
export const useUserSettings = (): IUserSettingsStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useUserSettings must be used within StoreProvider");
|
||||
return context.user.userSettings;
|
||||
};
|
||||
11
apps/web/core/hooks/store/user/user-user.ts
Normal file
11
apps/web/core/hooks/store/user/user-user.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IUserStore } from "@/store/user";
|
||||
|
||||
export const useUser = (): IUserStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useUser must be used within StoreProvider");
|
||||
return context.user;
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
// plane imports
|
||||
import type { IWorkItemFilterInstance } from "@plane/shared-state";
|
||||
import type { EIssuesStoreType } from "@plane/types";
|
||||
// local imports
|
||||
import { useWorkItemFilters } from "./use-work-item-filters";
|
||||
|
||||
export const useWorkItemFilterInstance = (
|
||||
entityType: EIssuesStoreType,
|
||||
entityId: string
|
||||
): IWorkItemFilterInstance | undefined => {
|
||||
const { getFilter } = useWorkItemFilters();
|
||||
return getFilter(entityType, entityId);
|
||||
};
|
||||
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// plane imports
|
||||
import type { IWorkItemFilterStore } from "@plane/shared-state";
|
||||
// context
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
|
||||
export const useWorkItemFilters = (): IWorkItemFilterStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useWorkItemFilters must be used within StoreProvider");
|
||||
return context.workItemFilters;
|
||||
};
|
||||
2
apps/web/core/hooks/store/workspace-draft/index.ts
Normal file
2
apps/web/core/hooks/store/workspace-draft/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./use-workspace-draft-issue";
|
||||
export * from "./use-workspace-draft-issue-filters";
|
||||
@@ -0,0 +1,12 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IWorkspaceDraftIssues } from "@/store/issue/workspace-draft";
|
||||
|
||||
export const useWorkspaceDraftIssueFilters = (): IWorkspaceDraftIssues => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useWorkspaceDraftIssueFilters must be used within StoreProvider");
|
||||
|
||||
return context.issue.workspaceDraftIssues;
|
||||
};
|
||||
@@ -0,0 +1,12 @@
|
||||
import { useContext } from "react";
|
||||
// mobx store
|
||||
import { StoreContext } from "@/lib/store-context";
|
||||
// types
|
||||
import type { IWorkspaceDraftIssues } from "@/store/issue/workspace-draft";
|
||||
|
||||
export const useWorkspaceDraftIssues = (): IWorkspaceDraftIssues => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useWorkspaceDraftIssues must be used within StoreProvider");
|
||||
|
||||
return context.issue.workspaceDraftIssues;
|
||||
};
|
||||
Reference in New Issue
Block a user