refactor: user profile store setup and bug fixes (#2586)
* fix: autorun not working when filters are changed * fix: filter/display on overview page * refactor: store implementation & loader in 'created' & 'subscribed' page
This commit is contained in:
parent
7f3dbe298c
commit
2cda47dc8a
7 changed files with 126 additions and 30 deletions
|
|
@ -30,7 +30,7 @@ const ProfileAssignedIssues: NextPage = observer(() => {
|
|||
userId: string;
|
||||
};
|
||||
|
||||
useSWR(`PROFILE_ISSUES_${workspaceSlug}_${userId}`, async () => {
|
||||
const { isLoading } = useSWR(`PROFILE_ISSUES_${workspaceSlug}_${userId}`, async () => {
|
||||
if (workspaceSlug && userId) {
|
||||
// workspace labels
|
||||
workspaceStore.setWorkspaceSlug(workspaceSlug);
|
||||
|
|
@ -46,8 +46,8 @@ const ProfileAssignedIssues: NextPage = observer(() => {
|
|||
|
||||
return (
|
||||
<AppLayout header={<UserProfileHeader />}>
|
||||
<ProfileAuthWrapper>
|
||||
{profileIssuesStore.loader ? (
|
||||
<ProfileAuthWrapper showProfileIssuesFilter>
|
||||
{isLoading ? (
|
||||
<div>Loading...</div>
|
||||
) : (
|
||||
<div className="w-full h-full relative overflow-auto -z-1">
|
||||
|
|
|
|||
|
|
@ -1,20 +1,61 @@
|
|||
import React from "react";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
import useSWR from "swr";
|
||||
// store
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// layouts
|
||||
import { AppLayout } from "layouts/app-layout";
|
||||
import { ProfileAuthWrapper } from "layouts/profile-layout";
|
||||
// components
|
||||
import { UserProfileHeader } from "components/headers";
|
||||
import { ProfileIssuesView } from "components/profile";
|
||||
import { ProfileIssuesListLayout } from "components/issues/issue-layouts/list/roots/profile-issues-root";
|
||||
import { ProfileIssuesKanBanLayout } from "components/issues/issue-layouts/kanban/roots/profile-issues-root";
|
||||
// types
|
||||
import type { NextPage } from "next";
|
||||
|
||||
const ProfileCreatedIssues: NextPage = () => (
|
||||
<AppLayout header={<UserProfileHeader />}>
|
||||
<ProfileAuthWrapper>
|
||||
<ProfileIssuesView />
|
||||
</ProfileAuthWrapper>
|
||||
</AppLayout>
|
||||
);
|
||||
const ProfileCreatedIssues: NextPage = () => {
|
||||
const {
|
||||
workspace: workspaceStore,
|
||||
project: projectStore,
|
||||
profileIssueFilters: profileIssueFiltersStore,
|
||||
profileIssues: profileIssuesStore,
|
||||
} = useMobxStore();
|
||||
|
||||
export default ProfileCreatedIssues;
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, userId } = router.query;
|
||||
|
||||
const { isLoading } = useSWR(`PROFILE_ISSUES_CREATED_${workspaceSlug}_${userId}`, async () => {
|
||||
if (workspaceSlug && userId) {
|
||||
// workspace labels
|
||||
workspaceStore.setWorkspaceSlug(workspaceSlug.toString());
|
||||
await workspaceStore.fetchWorkspaceLabels(workspaceSlug.toString());
|
||||
await projectStore.fetchProjects(workspaceSlug.toString());
|
||||
|
||||
//profile issues
|
||||
await profileIssuesStore.fetchIssues(workspaceSlug.toString(), userId.toString(), "created");
|
||||
}
|
||||
});
|
||||
|
||||
const activeLayout = profileIssueFiltersStore.userDisplayFilters.layout;
|
||||
|
||||
return (
|
||||
<AppLayout header={<UserProfileHeader />}>
|
||||
<ProfileAuthWrapper showProfileIssuesFilter>
|
||||
{isLoading ? (
|
||||
<div>Loading...</div>
|
||||
) : (
|
||||
<div className="w-full h-full relative overflow-auto -z-1">
|
||||
{activeLayout === "list" ? (
|
||||
<ProfileIssuesListLayout />
|
||||
) : activeLayout === "kanban" ? (
|
||||
<ProfileIssuesKanBanLayout />
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
</ProfileAuthWrapper>
|
||||
</AppLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default observer(ProfileCreatedIssues);
|
||||
|
|
|
|||
|
|
@ -1,20 +1,61 @@
|
|||
import React from "react";
|
||||
|
||||
import { useRouter } from "next/router";
|
||||
import useSWR from "swr";
|
||||
// store
|
||||
import { observer } from "mobx-react-lite";
|
||||
import { useMobxStore } from "lib/mobx/store-provider";
|
||||
// layouts
|
||||
import { AppLayout } from "layouts/app-layout";
|
||||
import { ProfileAuthWrapper } from "layouts/profile-layout";
|
||||
// components
|
||||
import { UserProfileHeader } from "components/headers";
|
||||
import { ProfileIssuesView } from "components/profile";
|
||||
import { ProfileIssuesListLayout } from "components/issues/issue-layouts/list/roots/profile-issues-root";
|
||||
import { ProfileIssuesKanBanLayout } from "components/issues/issue-layouts/kanban/roots/profile-issues-root";
|
||||
// types
|
||||
import type { NextPage } from "next";
|
||||
|
||||
const ProfileSubscribedIssues: NextPage = () => (
|
||||
<AppLayout header={<UserProfileHeader />}>
|
||||
<ProfileAuthWrapper>
|
||||
<ProfileIssuesView />
|
||||
</ProfileAuthWrapper>
|
||||
</AppLayout>
|
||||
);
|
||||
const ProfileSubscribedIssues: NextPage = () => {
|
||||
const {
|
||||
workspace: workspaceStore,
|
||||
project: projectStore,
|
||||
profileIssueFilters: profileIssueFiltersStore,
|
||||
profileIssues: profileIssuesStore,
|
||||
} = useMobxStore();
|
||||
|
||||
export default ProfileSubscribedIssues;
|
||||
const router = useRouter();
|
||||
const { workspaceSlug, userId } = router.query;
|
||||
|
||||
const { isLoading } = useSWR(`PROFILE_ISSUES_SUBSCRIBED_${workspaceSlug}_${userId}`, async () => {
|
||||
if (workspaceSlug && userId) {
|
||||
// workspace labels
|
||||
workspaceStore.setWorkspaceSlug(workspaceSlug.toString());
|
||||
await workspaceStore.fetchWorkspaceLabels(workspaceSlug.toString());
|
||||
await projectStore.fetchProjects(workspaceSlug.toString());
|
||||
|
||||
//profile issues
|
||||
await profileIssuesStore.fetchIssues(workspaceSlug.toString(), userId.toString(), "subscribed");
|
||||
}
|
||||
});
|
||||
|
||||
const activeLayout = profileIssueFiltersStore.userDisplayFilters.layout;
|
||||
|
||||
return (
|
||||
<AppLayout header={<UserProfileHeader />}>
|
||||
<ProfileAuthWrapper showProfileIssuesFilter>
|
||||
{isLoading ? (
|
||||
<div>Loading...</div>
|
||||
) : (
|
||||
<div className="w-full h-full relative overflow-auto -z-1">
|
||||
{activeLayout === "list" ? (
|
||||
<ProfileIssuesListLayout />
|
||||
) : activeLayout === "kanban" ? (
|
||||
<ProfileIssuesKanBanLayout />
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
</ProfileAuthWrapper>
|
||||
</AppLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default observer(ProfileSubscribedIssues);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue