diff --git a/apps/app/constants/api-routes.ts b/apps/app/constants/api-routes.ts index 6c169484b..aa2fd82d6 100644 --- a/apps/app/constants/api-routes.ts +++ b/apps/app/constants/api-routes.ts @@ -15,7 +15,8 @@ export const MAGIC_LINK_SIGNIN = "/api/magic-sign-in/"; export const USER_ENDPOINT = "/api/users/me/"; export const CHANGE_PASSWORD = "/api/users/me/change-password/"; export const USER_ONBOARD_ENDPOINT = "/api/users/me/onboard/"; -export const USER_ISSUES_ENDPOINT = "/api/users/me/issues/"; +export const USER_ISSUES_ENDPOINT = (workspaceSlug: string) => + `/api/workspaces/${workspaceSlug}/my-issues/`; export const USER_WORKSPACES = "/api/users/me/workspaces"; // s3 file url @@ -33,8 +34,6 @@ export const JOIN_WORKSPACE = (workspaceSlug: string, invitationId: string) => export const JOIN_PROJECT = (workspaceSlug: string) => `/api/workspaces/${workspaceSlug}/projects/join/`; -export const USER_ISSUES = "/api/users/me/issues/"; - // workspaces export const WORKSPACES_ENDPOINT = "/api/workspaces/"; export const WORKSPACE_DETAIL = (workspaceSlug: string) => `/api/workspaces/${workspaceSlug}/`; diff --git a/apps/app/constants/fetch-keys.ts b/apps/app/constants/fetch-keys.ts index 9e3611024..76a3807ae 100644 --- a/apps/app/constants/fetch-keys.ts +++ b/apps/app/constants/fetch-keys.ts @@ -29,4 +29,4 @@ export const CYCLE_DETAIL = "CYCLE_DETAIL"; export const STATE_LIST = (projectId: string) => `STATE_LIST_${projectId}`; export const STATE_DETAIL = "STATE_DETAIL"; -export const USER_ISSUE = "USER_ISSUE"; +export const USER_ISSUE = (workspaceSlug: string) => `USER_ISSUE_${workspaceSlug}`; diff --git a/apps/app/lib/services/user.service.ts b/apps/app/lib/services/user.service.ts index 8266a617c..e4fe684fd 100644 --- a/apps/app/lib/services/user.service.ts +++ b/apps/app/lib/services/user.service.ts @@ -16,8 +16,8 @@ class UserService extends APIService { }; } - async userIssues(): Promise { - return this.get(USER_ISSUES_ENDPOINT) + async userIssues(workspaceSlug: string): Promise { + return this.get(USER_ISSUES_ENDPOINT(workspaceSlug)) .then((response) => { return response?.data; }) diff --git a/apps/app/pages/me/my-issues.tsx b/apps/app/pages/me/my-issues.tsx index 444b0f342..d98c63499 100644 --- a/apps/app/pages/me/my-issues.tsx +++ b/apps/app/pages/me/my-issues.tsx @@ -33,11 +33,11 @@ import { Menu, Transition } from "@headlessui/react"; const MyIssues: NextPage = () => { const [selectedWorkspace, setSelectedWorkspace] = useState(null); - const { user, workspaces } = useUser(); + const { user, workspaces, activeWorkspace } = useUser(); const { data: myIssues, mutate: mutateMyIssues } = useSWR( - user ? USER_ISSUE : null, - user ? () => userService.userIssues() : null + user && activeWorkspace ? USER_ISSUE(activeWorkspace.slug) : null, + user && activeWorkspace ? () => userService.userIssues(activeWorkspace.slug) : null ); const updateMyIssues = ( diff --git a/apps/app/pages/me/profile.tsx b/apps/app/pages/me/profile.tsx index fdf369310..b256b141d 100644 --- a/apps/app/pages/me/profile.tsx +++ b/apps/app/pages/me/profile.tsx @@ -49,7 +49,7 @@ const Profile: NextPage = () => { const [isImageUploading, setIsImageUploading] = useState(false); const [isEditing, setIsEditing] = useState(false); - const { user: myProfile, mutateUser, projects } = useUser(); + const { user: myProfile, mutateUser, projects, activeWorkspace } = useUser(); const { setToastAlert } = useToast(); @@ -86,8 +86,8 @@ const Profile: NextPage = () => { } = useForm({ defaultValues }); const { data: myIssues } = useSWR( - myProfile ? USER_ISSUE : null, - myProfile ? () => userService.userIssues() : null + myProfile && activeWorkspace ? USER_ISSUE(activeWorkspace.slug) : null, + myProfile && activeWorkspace ? () => userService.userIssues(activeWorkspace.slug) : null ); const { data: invitations } = useSWR(USER_WORKSPACE_INVITATIONS, () => @@ -103,7 +103,7 @@ const Profile: NextPage = () => { icon: RectangleStackIcon, title: "My Issues", number: myIssues?.length ?? 0, - description: "View the list of issues assigned to you across the workspace.", + description: "View the list of issues assigned to you for this workspace.", href: "/me/my-issues", }, { diff --git a/apps/app/pages/workspace/index.tsx b/apps/app/pages/workspace/index.tsx index 26779bd9b..578c3f4db 100644 --- a/apps/app/pages/workspace/index.tsx +++ b/apps/app/pages/workspace/index.tsx @@ -26,8 +26,8 @@ const Workspace: NextPage = () => { const { user, activeWorkspace, projects } = useUser(); const { data: myIssues } = useSWR( - user ? USER_ISSUE : null, - user ? () => userService.userIssues() : null + user && activeWorkspace ? USER_ISSUE(activeWorkspace.slug) : null, + user && activeWorkspace ? () => userService.userIssues(activeWorkspace.slug) : null ); const cards = [