fix: 404 for my issues endpoint

since api endpoint was changed it was causing 404 for my issues, the new endpoint sends issues isolated to the workspace
This commit is contained in:
Dakshesh Jain 2022-12-13 11:25:33 +05:30
parent 8af3777afd
commit b540c884c5
6 changed files with 14 additions and 15 deletions

View File

@ -15,7 +15,8 @@ export const MAGIC_LINK_SIGNIN = "/api/magic-sign-in/";
export const USER_ENDPOINT = "/api/users/me/"; export const USER_ENDPOINT = "/api/users/me/";
export const CHANGE_PASSWORD = "/api/users/me/change-password/"; export const CHANGE_PASSWORD = "/api/users/me/change-password/";
export const USER_ONBOARD_ENDPOINT = "/api/users/me/onboard/"; 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"; export const USER_WORKSPACES = "/api/users/me/workspaces";
// s3 file url // s3 file url
@ -33,8 +34,6 @@ export const JOIN_WORKSPACE = (workspaceSlug: string, invitationId: string) =>
export const JOIN_PROJECT = (workspaceSlug: string) => export const JOIN_PROJECT = (workspaceSlug: string) =>
`/api/workspaces/${workspaceSlug}/projects/join/`; `/api/workspaces/${workspaceSlug}/projects/join/`;
export const USER_ISSUES = "/api/users/me/issues/";
// workspaces // workspaces
export const WORKSPACES_ENDPOINT = "/api/workspaces/"; export const WORKSPACES_ENDPOINT = "/api/workspaces/";
export const WORKSPACE_DETAIL = (workspaceSlug: string) => `/api/workspaces/${workspaceSlug}/`; export const WORKSPACE_DETAIL = (workspaceSlug: string) => `/api/workspaces/${workspaceSlug}/`;

View File

@ -29,4 +29,4 @@ export const CYCLE_DETAIL = "CYCLE_DETAIL";
export const STATE_LIST = (projectId: string) => `STATE_LIST_${projectId}`; export const STATE_LIST = (projectId: string) => `STATE_LIST_${projectId}`;
export const STATE_DETAIL = "STATE_DETAIL"; export const STATE_DETAIL = "STATE_DETAIL";
export const USER_ISSUE = "USER_ISSUE"; export const USER_ISSUE = (workspaceSlug: string) => `USER_ISSUE_${workspaceSlug}`;

View File

@ -16,8 +16,8 @@ class UserService extends APIService {
}; };
} }
async userIssues(): Promise<any> { async userIssues(workspaceSlug: string): Promise<any> {
return this.get(USER_ISSUES_ENDPOINT) return this.get(USER_ISSUES_ENDPOINT(workspaceSlug))
.then((response) => { .then((response) => {
return response?.data; return response?.data;
}) })

View File

@ -33,11 +33,11 @@ import { Menu, Transition } from "@headlessui/react";
const MyIssues: NextPage = () => { const MyIssues: NextPage = () => {
const [selectedWorkspace, setSelectedWorkspace] = useState<string | null>(null); const [selectedWorkspace, setSelectedWorkspace] = useState<string | null>(null);
const { user, workspaces } = useUser(); const { user, workspaces, activeWorkspace } = useUser();
const { data: myIssues, mutate: mutateMyIssues } = useSWR<IIssue[]>( const { data: myIssues, mutate: mutateMyIssues } = useSWR<IIssue[]>(
user ? USER_ISSUE : null, user && activeWorkspace ? USER_ISSUE(activeWorkspace.slug) : null,
user ? () => userService.userIssues() : null user && activeWorkspace ? () => userService.userIssues(activeWorkspace.slug) : null
); );
const updateMyIssues = ( const updateMyIssues = (

View File

@ -49,7 +49,7 @@ const Profile: NextPage = () => {
const [isImageUploading, setIsImageUploading] = useState(false); const [isImageUploading, setIsImageUploading] = useState(false);
const [isEditing, setIsEditing] = useState(false); const [isEditing, setIsEditing] = useState(false);
const { user: myProfile, mutateUser, projects } = useUser(); const { user: myProfile, mutateUser, projects, activeWorkspace } = useUser();
const { setToastAlert } = useToast(); const { setToastAlert } = useToast();
@ -86,8 +86,8 @@ const Profile: NextPage = () => {
} = useForm<IUser>({ defaultValues }); } = useForm<IUser>({ defaultValues });
const { data: myIssues } = useSWR<IIssue[]>( const { data: myIssues } = useSWR<IIssue[]>(
myProfile ? USER_ISSUE : null, myProfile && activeWorkspace ? USER_ISSUE(activeWorkspace.slug) : null,
myProfile ? () => userService.userIssues() : null myProfile && activeWorkspace ? () => userService.userIssues(activeWorkspace.slug) : null
); );
const { data: invitations } = useSWR(USER_WORKSPACE_INVITATIONS, () => const { data: invitations } = useSWR(USER_WORKSPACE_INVITATIONS, () =>
@ -103,7 +103,7 @@ const Profile: NextPage = () => {
icon: RectangleStackIcon, icon: RectangleStackIcon,
title: "My Issues", title: "My Issues",
number: myIssues?.length ?? 0, 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", href: "/me/my-issues",
}, },
{ {

View File

@ -26,8 +26,8 @@ const Workspace: NextPage = () => {
const { user, activeWorkspace, projects } = useUser(); const { user, activeWorkspace, projects } = useUser();
const { data: myIssues } = useSWR<IIssue[]>( const { data: myIssues } = useSWR<IIssue[]>(
user ? USER_ISSUE : null, user && activeWorkspace ? USER_ISSUE(activeWorkspace.slug) : null,
user ? () => userService.userIssues() : null user && activeWorkspace ? () => userService.userIssues(activeWorkspace.slug) : null
); );
const cards = [ const cards = [