diff --git a/web/components/profile/profile-issues.tsx b/web/components/profile/profile-issues.tsx index e63f5714d..11974caaa 100644 --- a/web/components/profile/profile-issues.tsx +++ b/web/components/profile/profile-issues.tsx @@ -1,12 +1,8 @@ -import React, { ReactElement } from "react"; +import React from "react"; import { useRouter } from "next/router"; import useSWR from "swr"; import { observer } from "mobx-react-lite"; -// layouts -import { AppLayout } from "layouts/app-layout"; -import { ProfileAuthWrapper } from "layouts/user-profile-layout"; // components -import { UserProfileHeader } from "components/headers"; import { ProfileIssuesListLayout } from "components/issues/issue-layouts/list/roots/profile-issues-root"; import { ProfileIssuesKanBanLayout } from "components/issues/issue-layouts/kanban/roots/profile-issues-root"; import { ProfileIssuesAppliedFiltersRoot } from "components/issues"; @@ -31,12 +27,15 @@ export const ProfileIssuesPage = observer((props: IProfileIssuesPage) => { workspaceProfileIssuesFilter: { issueFilters, fetchFilters }, }: RootStore = useMobxStore(); - useSWR(workspaceSlug && userId ? `CURRENT_WORKSPACE_PROFILE_ISSUES_${workspaceSlug}_${userId}` : null, async () => { - if (workspaceSlug && userId) { - await fetchFilters(workspaceSlug); - await fetchIssues(workspaceSlug, userId, getIssues ? "mutation" : "init-loader", props.type); + useSWR( + workspaceSlug && userId ? `CURRENT_WORKSPACE_PROFILE_ISSUES_${workspaceSlug}_${userId}_${props.type}` : null, + async () => { + if (workspaceSlug && userId) { + await fetchFilters(workspaceSlug); + await fetchIssues(workspaceSlug, userId, getIssues ? "mutation" : "init-loader", props.type); + } } - }); + ); const activeLayout = issueFilters?.displayFilters?.layout || undefined; diff --git a/web/store/issues/profile/filter.store.ts b/web/store/issues/profile/filter.store.ts index a947b8d23..771368a78 100644 --- a/web/store/issues/profile/filter.store.ts +++ b/web/store/issues/profile/filter.store.ts @@ -5,7 +5,7 @@ import { IIssueDisplayFilterOptions, IIssueDisplayProperties, IIssueFilterOption import { EFilterType } from "store/issues/types"; import { handleIssueQueryParamsByLayout } from "helpers/issue.helper"; import { IssueFilterBaseStore } from "../project-issues/base-issue-filter.store"; -import { isEmpty } from "lodash"; +import isEmpty from "lodash/isEmpty"; interface IProjectIssuesFiltersOptions { filters: IIssueFilterOptions; @@ -199,14 +199,14 @@ export class ProfileIssuesFilterStore extends IssueFilterBaseStore implements IP try { const displayProperties: IIssueDisplayProperties = { assignee: true, - start_date: true, - due_date: true, - labels: false, - key: false, + start_date: false, + due_date: false, + labels: true, + key: true, priority: true, state: false, - sub_issue_count: true, - link: true, + sub_issue_count: false, + link: false, attachment_count: false, estimate: false, created_on: false, diff --git a/web/store/issues/profile/issue.store.ts b/web/store/issues/profile/issue.store.ts index 911096324..92c34c319 100644 --- a/web/store/issues/profile/issue.store.ts +++ b/web/store/issues/profile/issue.store.ts @@ -19,7 +19,7 @@ export interface IProfileIssuesStore { loader: TLoader; issues: { [user_id: string]: IProfileIssueTabTypes } | undefined; currentUserId: string | null; - currentUserIssueTab: "assigned" | "created" | "subscribed" | null; + currentUserIssueTab: "assigned" | "created" | "subscribed" | undefined; // computed getIssues: IIssueResponse | undefined; getIssuesIds: IGroupedIssues | ISubGroupedIssues | TUnGroupedIssues | undefined; @@ -51,7 +51,7 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues loader: TLoader = "init-loader"; issues: { [user_id: string]: IProfileIssueTabTypes } | undefined = undefined; currentUserId: string | null = null; - currentUserIssueTab: "assigned" | "created" | "subscribed" | null = null; + currentUserIssueTab: "assigned" | "created" | "subscribed" | undefined = undefined; // root store rootStore; // service @@ -86,7 +86,9 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues if (!workspaceSlug || !this.currentUserId || !this.currentUserIssueTab) return; const userFilters = this.rootStore?.workspaceProfileIssuesFilter?.issueFilters?.filters; - if (userFilters) this.fetchIssues(workspaceSlug, this.currentUserId, "mutation", this.currentUserIssueTab); + if (userFilters) { + this.fetchIssues(workspaceSlug, this.currentUserId, "mutation", this.currentUserIssueTab); + } }); } @@ -196,20 +198,12 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues createIssue = async (workspaceSlug: string, userId: string, data: Partial) => { try { const projectId = data.project; - const moduleId = data.module_id; - const cycleId = data.cycle_id; if (!projectId) return; let response = {} as IIssue; response = await this.rootStore.projectIssues.createIssue(workspaceSlug, projectId, data); - // if (moduleId) - // response = await this.rootStore.moduleIssues.addIssueToModule(workspaceSlug, projectId, moduleId, response); - - // if (cycleId) - // response = await this.rootStore.cycleIssues.addIssueToCycle(workspaceSlug, projectId, cycleId, response); - let _issues = this.issues; if (!_issues) _issues = {}; if (!_issues[userId]) _issues[userId] = { assigned: {}, created: {}, subscribed: {} }; @@ -237,8 +231,8 @@ export class ProfileIssuesStore extends IssueBaseStore implements IProfileIssues let _issues = { ...this.issues }; if (!_issues) _issues = {}; if (!_issues[userId]) _issues[userId] = { assigned: {}, created: {}, subscribed: {} }; - _issues[projectId][this.currentUserIssueTab][userId] = { - ..._issues[projectId][this.currentUserIssueTab][userId], + _issues[userId][this.currentUserIssueTab][userId] = { + ..._issues[userId][this.currentUserIssueTab][userId], ...data, }; diff --git a/web/store/issues/project-issues/archived/issue.store.ts b/web/store/issues/project-issues/archived/issue.store.ts index a2fa7bd37..6e1abab8e 100644 --- a/web/store/issues/project-issues/archived/issue.store.ts +++ b/web/store/issues/project-issues/archived/issue.store.ts @@ -119,8 +119,17 @@ export class ProjectArchivedIssuesStore extends IssueBaseStore implements IProje removeIssue = async (workspaceSlug: string, projectId: string, issueId: string) => { try { - await this.archivedIssueService.unarchiveIssue(workspaceSlug, projectId, issueId); - return; + let _issues = { ...this.issues }; + if (!_issues) _issues = {}; + if (!_issues[projectId]) _issues[projectId] = {}; + delete _issues?.[projectId]?.[issueId]; + + runInAction(() => { + this.issues = _issues; + }); + + const response = await this.archivedIssueService.deleteArchivedIssue(workspaceSlug, projectId, issueId); + return response; } catch (error) { throw error; } @@ -128,8 +137,17 @@ export class ProjectArchivedIssuesStore extends IssueBaseStore implements IProje removeIssueFromArchived = async (workspaceSlug: string, projectId: string, issueId: string) => { try { - await this.archivedIssueService.deleteArchivedIssue(workspaceSlug, projectId, issueId); - return; + let _issues = { ...this.issues }; + if (!_issues) _issues = {}; + if (!_issues[projectId]) _issues[projectId] = {}; + delete _issues?.[projectId]?.[issueId]; + + runInAction(() => { + this.issues = _issues; + }); + + const response = await this.archivedIssueService.unarchiveIssue(workspaceSlug, projectId, issueId); + return response; } catch (error) { throw error; }