feat: init
This commit is contained in:
2
apps/space/core/hooks/store/publish/index.ts
Normal file
2
apps/space/core/hooks/store/publish/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from "./use-publish-list";
|
||||
export * from "./use-publish";
|
||||
11
apps/space/core/hooks/store/publish/use-publish-list.ts
Normal file
11
apps/space/core/hooks/store/publish/use-publish-list.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { IPublishListStore } from "@/store/publish/publish_list.store";
|
||||
|
||||
export const usePublishList = (): IPublishListStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("usePublishList must be used within StoreProvider");
|
||||
return context.publishList;
|
||||
};
|
||||
11
apps/space/core/hooks/store/publish/use-publish.ts
Normal file
11
apps/space/core/hooks/store/publish/use-publish.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { PublishStore } from "@/store/publish/publish.store";
|
||||
|
||||
export const usePublish = (anchor: string): PublishStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("usePublish must be used within StoreProvider");
|
||||
return context.publishList.publishMap?.[anchor] ?? {};
|
||||
};
|
||||
11
apps/space/core/hooks/store/use-cycle.ts
Normal file
11
apps/space/core/hooks/store/use-cycle.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { ICycleStore } from "@/store/cycle.store";
|
||||
|
||||
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/space/core/hooks/store/use-instance.ts
Normal file
11
apps/space/core/hooks/store/use-instance.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { IInstanceStore } from "@/store/instance.store";
|
||||
|
||||
export const useInstance = (): IInstanceStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useUserProfile must be used within StoreProvider");
|
||||
return context.instance;
|
||||
};
|
||||
11
apps/space/core/hooks/store/use-issue-details.tsx
Normal file
11
apps/space/core/hooks/store/use-issue-details.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { IIssueDetailStore } from "@/store/issue-detail.store";
|
||||
|
||||
export const useIssueDetails = (): IIssueDetailStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useUserProfile must be used within StoreProvider");
|
||||
return context.issueDetail;
|
||||
};
|
||||
11
apps/space/core/hooks/store/use-issue-filter.ts
Normal file
11
apps/space/core/hooks/store/use-issue-filter.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { IIssueFilterStore } from "@/store/issue-filters.store";
|
||||
|
||||
export const useIssueFilter = (): IIssueFilterStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useUserProfile must be used within StoreProvider");
|
||||
return context.issueFilter;
|
||||
};
|
||||
11
apps/space/core/hooks/store/use-issue.ts
Normal file
11
apps/space/core/hooks/store/use-issue.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { IIssueStore } from "@/store/issue.store";
|
||||
|
||||
export const useIssue = (): IIssueStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useIssue must be used within StoreProvider");
|
||||
return context.issue;
|
||||
};
|
||||
11
apps/space/core/hooks/store/use-label.ts
Normal file
11
apps/space/core/hooks/store/use-label.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { IIssueLabelStore } from "@/store/label.store";
|
||||
|
||||
export const useLabel = (): IIssueLabelStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useLabel must be used within StoreProvider");
|
||||
return context.label;
|
||||
};
|
||||
11
apps/space/core/hooks/store/use-member.ts
Normal file
11
apps/space/core/hooks/store/use-member.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { IIssueMemberStore } from "@/store/members.store";
|
||||
|
||||
export const useMember = (): IIssueMemberStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useMember must be used within StoreProvider");
|
||||
return context.member;
|
||||
};
|
||||
11
apps/space/core/hooks/store/use-module.ts
Normal file
11
apps/space/core/hooks/store/use-module.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { IIssueModuleStore } from "@/store/module.store";
|
||||
|
||||
export const useModule = (): IIssueModuleStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useModule must be used within StoreProvider");
|
||||
return context.module;
|
||||
};
|
||||
11
apps/space/core/hooks/store/use-state.ts
Normal file
11
apps/space/core/hooks/store/use-state.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { IStateStore } from "@/store/state.store";
|
||||
|
||||
export const useStates = (): IStateStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useState must be used within StoreProvider");
|
||||
return context.state;
|
||||
};
|
||||
11
apps/space/core/hooks/store/use-user-profile.ts
Normal file
11
apps/space/core/hooks/store/use-user-profile.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { IProfileStore } from "@/store/profile.store";
|
||||
|
||||
export const useUserProfile = (): IProfileStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useUserProfile must be used within StoreProvider");
|
||||
return context.user.profile;
|
||||
};
|
||||
11
apps/space/core/hooks/store/use-user.ts
Normal file
11
apps/space/core/hooks/store/use-user.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { useContext } from "react";
|
||||
// lib
|
||||
import { StoreContext } from "@/lib/store-provider";
|
||||
// store
|
||||
import type { IUserStore } from "@/store/user.store";
|
||||
|
||||
export const useUser = (): IUserStore => {
|
||||
const context = useContext(StoreContext);
|
||||
if (context === undefined) throw new Error("useUser must be used within StoreProvider");
|
||||
return context.user;
|
||||
};
|
||||
Reference in New Issue
Block a user