2023-11-02 18:27:44 +00:00
|
|
|
import { ReactElement } from "react";
|
2023-11-02 10:55:44 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import useSWR from "swr";
|
|
|
|
// store
|
|
|
|
import { observer } from "mobx-react-lite";
|
|
|
|
import { useMobxStore } from "lib/mobx/store-provider";
|
2023-07-28 08:09:42 +00:00
|
|
|
// layouts
|
2023-10-25 10:18:57 +00:00
|
|
|
import { AppLayout } from "layouts/app-layout";
|
2023-07-31 11:27:28 +00:00
|
|
|
import { ProfileAuthWrapper } from "layouts/profile-layout";
|
2023-07-28 08:09:42 +00:00
|
|
|
// components
|
2023-10-25 10:18:57 +00:00
|
|
|
import { UserProfileHeader } from "components/headers";
|
2023-11-02 10:55:44 +00:00
|
|
|
import { ProfileIssuesListLayout } from "components/issues/issue-layouts/list/roots/profile-issues-root";
|
|
|
|
import { ProfileIssuesKanBanLayout } from "components/issues/issue-layouts/kanban/roots/profile-issues-root";
|
2023-11-03 07:47:52 +00:00
|
|
|
import { Spinner } from "@plane/ui";
|
2023-07-28 08:09:42 +00:00
|
|
|
// types
|
2023-11-02 18:27:44 +00:00
|
|
|
import { NextPageWithLayout } from "types/app";
|
2023-07-28 08:09:42 +00:00
|
|
|
|
2023-11-02 18:27:44 +00:00
|
|
|
const ProfileCreatedIssuesPage: NextPageWithLayout = () => {
|
2023-11-02 10:55:44 +00:00
|
|
|
const {
|
|
|
|
workspace: workspaceStore,
|
|
|
|
project: projectStore,
|
|
|
|
profileIssueFilters: profileIssueFiltersStore,
|
|
|
|
profileIssues: profileIssuesStore,
|
|
|
|
} = useMobxStore();
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
2023-11-02 18:27:44 +00:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{isLoading ? (
|
2023-11-03 07:47:52 +00:00
|
|
|
<div className="flex justify-center items-center w-full h-full">
|
|
|
|
<Spinner />
|
|
|
|
</div>
|
2023-11-02 18:27:44 +00:00
|
|
|
) : (
|
|
|
|
<div className="w-full h-full relative overflow-auto -z-1">
|
|
|
|
{activeLayout === "list" ? (
|
|
|
|
<ProfileIssuesListLayout />
|
|
|
|
) : activeLayout === "kanban" ? (
|
|
|
|
<ProfileIssuesKanBanLayout />
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
ProfileCreatedIssuesPage.getLayout = function getLayout(page: ReactElement) {
|
2023-11-02 10:55:44 +00:00
|
|
|
return (
|
2023-11-03 10:09:36 +00:00
|
|
|
<AppLayout header={<UserProfileHeader title="Created" />}>
|
2023-11-02 18:27:44 +00:00
|
|
|
<ProfileAuthWrapper showProfileIssuesFilter>{page}</ProfileAuthWrapper>
|
2023-11-02 10:55:44 +00:00
|
|
|
</AppLayout>
|
|
|
|
);
|
|
|
|
};
|
2023-07-28 08:09:42 +00:00
|
|
|
|
2023-11-02 18:27:44 +00:00
|
|
|
export default observer(ProfileCreatedIssuesPage);
|