Skip to content

Commit

Permalink
fix: api end point 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
suzinxix committed May 13, 2024
1 parent e2b8034 commit 2f80437
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions components/common/Card/Card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ function Card({ item, folderId, folderList }: Props) {
onCloseClick={closeModal}
/>

<FolderModal
{/* <FolderModal
isOpen={currentModal === MODALS.addLink}
link={url}
title="폴더에 추가"
buttonText="추가하기"
folderList={folderList}
onCloseClick={closeModal}
/>
/> */}
</>
);
}
Expand Down
10 changes: 7 additions & 3 deletions components/common/LoginCheck/LoginCheck.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,23 @@
import { useRouter } from "next/router";
import { PropsWithChildren, useEffect } from "react";
import { TOKEN } from "constants/auth";

import { ROUTE_PATHS } from "constants/route";

import useAuthStore from "store/authStore";

const LoginCheck = ({ children }: PropsWithChildren) => {
const accessToken = useAuthStore.getState().accessToken;

const router = useRouter();

useEffect(() => {
const accessToken = localStorage.getItem(TOKEN.access);
if (accessToken) {
router.push(ROUTE_PATHS.folder);
} else {
return;
}
}, []);

return <div>{children}</div>;
};

Expand Down
3 changes: 2 additions & 1 deletion constants/endPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ export const API_ENDPOINTS = {
FOLDER_DETAIL: (folderId: number) => `/folders/${folderId}`,

LINKS: "/links",
LINK_DETAIL: (folderId: number) => `/folders/${folderId}/links`,
FOLDER_LINKS_DETAIL: (folderId: number) => `/folders/${folderId}/links`,
LINK_DETAIL: (linkId: number) => `/links/${linkId}`,

USERS: "/users",
CHECK_EMAIL: "/users/check-email",
Expand Down
2 changes: 1 addition & 1 deletion hooks/useDeleteLink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import instance from "lib/axios";
import { QUERY_KEYS } from "constants/queryKey";
import { API_ENDPOINTS } from "constants/endPoint";

export const useDeleteLink = (folderId: number) => {
export const useDeleteLink = (folderId: number | null) => {
const deleteLink = async (linkId: number) => {
try {
await instance.delete(API_ENDPOINTS.LINK_DETAIL(linkId));
Expand Down
2 changes: 1 addition & 1 deletion hooks/useGetLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useGetLinks = (folderId: number | null) => {
const fetchLinks = async () => {
try {
const url = folderId
? API_ENDPOINTS.LINK_DETAIL(folderId)
? API_ENDPOINTS.FOLDER_LINKS_DETAIL(folderId)
: API_ENDPOINTS.LINKS;
const { data } = await instance.get<Link[]>(url);
return data;
Expand Down

0 comments on commit 2f80437

Please sign in to comment.