fix: my issues mutation (#1753)

* fix: my issues mutation

* fix: activity message and icon return value
This commit is contained in:
Aaryan Khandelwal 2023-08-01 18:40:04 +05:30 committed by GitHub
parent d22e4b8212
commit 2cd431b4a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 8 deletions

View File

@ -481,7 +481,7 @@ const activityDetails: {
};
export const ActivityIcon = ({ activity }: { activity: IIssueActivity }) => (
<>{activityDetails[activity.field as keyof typeof activityDetails].icon}</>
<>{activityDetails[activity.field as keyof typeof activityDetails]?.icon}</>
);
export const ActivityMessage = ({
@ -492,6 +492,6 @@ export const ActivityMessage = ({
showIssue?: boolean;
}) => (
<>
{activityDetails[activity.field as keyof typeof activityDetails].message(activity, showIssue)}
{activityDetails[activity.field as keyof typeof activityDetails]?.message(activity, showIssue)}
</>
);

View File

@ -18,6 +18,7 @@ import useToast from "hooks/use-toast";
import useInboxView from "hooks/use-inbox-view";
import useSpreadsheetIssuesView from "hooks/use-spreadsheet-issues-view";
import useProjects from "hooks/use-projects";
import useMyIssues from "hooks/my-issues/use-my-issues";
// components
import { IssueForm } from "components/issues";
// types
@ -85,6 +86,8 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
const { user } = useUser();
const { projects } = useProjects();
const { groupedIssues, mutateMyIssues } = useMyIssues(workspaceSlug?.toString());
const { setToastAlert } = useToast();
if (cycleId) prePopulateData = { ...prePopulateData, cycle: cycleId as string };
@ -243,6 +246,7 @@ export const CreateUpdateIssueModal: React.FC<IssuesModalProps> = ({
if (issueView === "calendar") mutate(calendarFetchKey);
if (issueView === "gantt_chart") mutate(ganttFetchKey);
if (issueView === "spreadsheet") mutate(spreadsheetFetchKey);
if (groupedIssues) mutateMyIssues();
setToastAlert({
type: "success",

View File

@ -8,6 +8,7 @@ import useSWR from "swr";
import { DropResult } from "react-beautiful-dnd";
// services
import issuesService from "services/issues.service";
import userService from "services/user.service";
// hooks
import useProfileIssues from "hooks/use-profile-issues";
import useUser from "hooks/use-user";
@ -19,7 +20,7 @@ import { orderArrayBy } from "helpers/array.helper";
// types
import { IIssue, IIssueFilterOptions } from "types";
// fetch-keys
import { WORKSPACE_LABELS } from "constants/fetch-keys";
import { USER_PROFILE_PROJECT_SEGREGATION, WORKSPACE_LABELS } from "constants/fetch-keys";
export const ProfileIssuesView = () => {
// create issue modal
@ -60,6 +61,16 @@ export const ProfileIssuesView = () => {
params,
} = useProfileIssues(workspaceSlug?.toString(), userId?.toString());
const { data: profileData } = useSWR(
workspaceSlug && userId
? USER_PROFILE_PROJECT_SEGREGATION(workspaceSlug.toString(), userId.toString())
: null,
workspaceSlug && userId
? () =>
userService.getUserProfileProjectsSegregation(workspaceSlug.toString(), userId.toString())
: null
);
const { data: labels } = useSWR(
workspaceSlug && (filters?.labels ?? []).length > 0
? WORKSPACE_LABELS(workspaceSlug.toString())
@ -268,10 +279,10 @@ export const ProfileIssuesView = () => {
dragDisabled={groupByProperty !== "priority"}
emptyState={{
title: router.pathname.includes("assigned")
? `Issues assigned to ${user?.first_name} ${user?.last_name} will appear here`
? `Issues assigned to ${profileData?.user_data.first_name} ${profileData?.user_data.last_name} will appear here`
: router.pathname.includes("created")
? `Issues created by ${user?.first_name} ${user?.last_name} will appear here`
: `Issues subscribed by ${user?.first_name} ${user?.last_name} will appear here`,
? `Issues created by ${profileData?.user_data.first_name} ${profileData?.user_data.last_name} will appear here`
: `Issues subscribed by ${profileData?.user_data.first_name} ${profileData?.user_data.last_name} will appear here`,
}}
handleOnDragEnd={handleOnDragEnd}
handleIssueAction={handleIssueAction}

View File

@ -1,5 +1,7 @@
import { useMemo } from "react";
import { useRouter } from "next/router";
import useSWR from "swr";
// services
@ -12,6 +14,8 @@ import { IIssue } from "types";
import { USER_ISSUES } from "constants/fetch-keys";
const useMyIssues = (workspaceSlug: string | undefined) => {
const router = useRouter();
const { filters, groupBy, orderBy } = useMyIssuesFilters(workspaceSlug);
const params: any = {
@ -27,8 +31,12 @@ const useMyIssues = (workspaceSlug: string | undefined) => {
};
const { data: myIssues, mutate: mutateMyIssues } = useSWR(
workspaceSlug ? USER_ISSUES(workspaceSlug.toString(), params) : null,
workspaceSlug ? () => userService.userIssues(workspaceSlug.toString(), params) : null
workspaceSlug && router.pathname.includes("my-issues")
? USER_ISSUES(workspaceSlug.toString(), params)
: null,
workspaceSlug && router.pathname.includes("my-issues")
? () => userService.userIssues(workspaceSlug.toString(), params)
: null
);
const groupedIssues: