From 90b8a175093c69e38c265f88e9b21d7f7a5f4a9a Mon Sep 17 00:00:00 2001 From: Kim Min Jeong Date: Tue, 2 Apr 2024 12:19:11 +0900 Subject: [PATCH 01/28] =?UTF-8?q?Refactor:=20api=20=EA=B3=B5=ED=86=B5=20?= =?UTF-8?q?=EB=B6=80=EB=B6=84=20=ED=95=A8=EC=88=98=EB=A1=9C=20=EB=AC=B6?= =?UTF-8?q?=EC=96=B4=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/api.ts | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/api/api.ts b/api/api.ts index a4be6efc9..eb39c62c0 100644 --- a/api/api.ts +++ b/api/api.ts @@ -1,44 +1,32 @@ const BASE_URL = "https://bootcamp-api.codeit.kr/api/"; -export const getFolderInfo = async () => { +const fetchJson = async (url: string) => { try { - const response = await fetch(`${BASE_URL}sample/folder`); - const result = await response.json(); // 재사용성을 위해 response.json()으로 끝맺는게 좋음 + const response = await fetch(url); + const result = await response.json(); return result; } catch (error) { console.log(error); } }; +export const getFolderInfo = async () => { + const url = `${BASE_URL}sample/folder`; + return await fetchJson(url); +}; + export const getUserInfo = async () => { - try { - const response = await fetch(`${BASE_URL}sample/user`); - const result = await response.json(); - return result; - } catch (error) { - console.log(error); - } + const url = `${BASE_URL}sample/user`; + return await fetchJson(url); }; export const getFolderList = async () => { - try { - const response = await fetch(`${BASE_URL}users/1/folders`); - const result = await response.json(); // 재사용성을 위해 response.json()으로 끝맺는게 좋음 - // console.log(result); - return result; - } catch (error) { - console.log(error); - } + const url = `${BASE_URL}users/1/folders`; + return fetchJson(url); }; export const getAllLinkData = async (id: string) => { const url = id ? `${BASE_URL}users/1/folders/${id}` : `${BASE_URL}users/1/links`; - try { - const response = await fetch(url); - const result = await response.json(); // 재사용성을 위해 response.json()으로 끝맺는게 좋음 - return result; - } catch (error) { - console.log(error); - } + return fetchJson(url); }; From 57880c7f9ab0909dbafd89d3405df55769163e3e Mon Sep 17 00:00:00 2001 From: Kim Min Jeong Date: Tue, 2 Apr 2024 12:20:29 +0900 Subject: [PATCH 02/28] =?UTF-8?q?Refactor:=20let=20=EB=B3=80=EC=88=98?= =?UTF-8?q?=EB=A5=BC=20const=20=EC=83=81=EC=88=98=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=20=ED=9B=84=20||=20=EB=A5=BC=20=ED=86=B5=ED=95=9C=20?= =?UTF-8?q?=EA=B0=92=20=ED=95=A0=EB=8B=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/common/FolderItem.tsx | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/components/common/FolderItem.tsx b/components/common/FolderItem.tsx index e0db3e2a3..80d7cde03 100644 --- a/components/common/FolderItem.tsx +++ b/components/common/FolderItem.tsx @@ -24,16 +24,9 @@ function FolderItem({ const { created_at, favorite, image_source } = item; const [isPopOverVisible, setIsPopOverVisible] = useState(false); - let time = ""; - let img_src: string; - - if (created_at) { - time = CalcTime(created_at); - img_src = image_source ?? ""; - } else { - time = CalcTime(createdAt); - img_src = imageSource ?? ""; - } + const time = CalcTime(created_at || createdAt); + const img_src = image_source || imageSource; + return ( From 368d2000f037f3dd5e02c09fe86ddab3f5d13553 Mon Sep 17 00:00:00 2001 From: Kim Min Jeong Date: Tue, 2 Apr 2024 12:29:04 +0900 Subject: [PATCH 03/28] =?UTF-8?q?Refactor:=20=EB=8B=A8=EC=9D=BC=20?= =?UTF-8?q?=ED=83=9C=EA=B7=B8=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/SignIn_Up/EmailPwdInput.tsx | 2 +- components/common/BlueButton.tsx | 2 +- components/common/FolderItem.tsx | 6 +++--- components/common/FolderList.tsx | 2 +- components/common/HeaderElement.tsx | 4 ++-- components/common/modals/AddFolderModal.tsx | 4 ++-- components/common/modals/AddToFolder.tsx | 2 +- components/common/modals/DeleteModal.tsx | 2 +- components/common/modals/EditNameModal.tsx | 2 +- components/common/modals/PopOver.tsx | 4 ++-- components/common/modals/SharedModal.tsx | 2 +- components/folder/FolderInput.tsx | 2 +- components/shared/SharedSection.tsx | 5 +---- pages/Folder.tsx | 24 +++++++++++---------- pages/Shared.tsx | 6 +++--- 15 files changed, 34 insertions(+), 35 deletions(-) diff --git a/components/SignIn_Up/EmailPwdInput.tsx b/components/SignIn_Up/EmailPwdInput.tsx index 437be48aa..da0bc7b4a 100644 --- a/components/SignIn_Up/EmailPwdInput.tsx +++ b/components/SignIn_Up/EmailPwdInput.tsx @@ -15,7 +15,7 @@ const EmailPwdInput = ({ title, type, isEyeIcon }: EmailPwdInputPropsType) => { {isEyeIcon && ( - eye_off_icon + eye_off_icon )} diff --git a/components/common/BlueButton.tsx b/components/common/BlueButton.tsx index a7ca8f684..dfddb7671 100644 --- a/components/common/BlueButton.tsx +++ b/components/common/BlueButton.tsx @@ -21,7 +21,7 @@ export const BlueButton = ({ color={COLORS.White} fontSize={fontSize} radius={radius} - onClick={() => (onBtnHandle ? onBtnHandle() : null)} + onClick={() => onBtnHandle?.()} > {text} diff --git a/components/common/FolderItem.tsx b/components/common/FolderItem.tsx index 80d7cde03..94f82988d 100644 --- a/components/common/FolderItem.tsx +++ b/components/common/FolderItem.tsx @@ -32,7 +32,7 @@ function FolderItem({ {img_src ? ( - 이미지 + 이미지 ) : ( logo @@ -48,7 +48,7 @@ function FolderItem({ e.preventDefault(); setIsPopOverVisible(!isPopOverVisible); }} - > + /> + /> {description} diff --git a/components/common/FolderList.tsx b/components/common/FolderList.tsx index 8d6fc7a13..1f9d74ff5 100644 --- a/components/common/FolderList.tsx +++ b/components/common/FolderList.tsx @@ -24,7 +24,7 @@ function FolderList({ key={item.id} $isModalVisible={$isModalVisible} setIsModalVisible={setIsModalVisible} - > + /> ); } })} diff --git a/components/common/HeaderElement.tsx b/components/common/HeaderElement.tsx index 712e95282..df2852d5c 100644 --- a/components/common/HeaderElement.tsx +++ b/components/common/HeaderElement.tsx @@ -27,14 +27,14 @@ function HeaderElement({ $positionval }: propTypes) { height={28} src={profileImageSource} alt="myProfile-img" - > + /> ) : ( myProfile-img + /> )} {email} diff --git a/components/common/modals/AddFolderModal.tsx b/components/common/modals/AddFolderModal.tsx index f5652e6e2..0ede85b0c 100644 --- a/components/common/modals/AddFolderModal.tsx +++ b/components/common/modals/AddFolderModal.tsx @@ -9,7 +9,7 @@ export const AddFolderModal = ({ setIsModalVisible, }: CommonModalProps) => { const handleCloseBtn = () => { - setIsModalVisible(null); + setIsModalVisible(""); }; return ( @@ -28,7 +28,7 @@ export const AddFolderModal = ({ padding="16px 20px" fontSize="16px" radius="8px" - > + /> ); diff --git a/components/common/modals/AddToFolder.tsx b/components/common/modals/AddToFolder.tsx index a2783d970..b9d399912 100644 --- a/components/common/modals/AddToFolder.tsx +++ b/components/common/modals/AddToFolder.tsx @@ -53,7 +53,7 @@ export const AddToFolder = ({ padding="16px 20px" fontSize="16px" radius="8px" - > + /> ); diff --git a/components/common/modals/DeleteModal.tsx b/components/common/modals/DeleteModal.tsx index 9aff6fed7..f9d7b10b8 100644 --- a/components/common/modals/DeleteModal.tsx +++ b/components/common/modals/DeleteModal.tsx @@ -35,7 +35,7 @@ export const DeleteModal = ({ padding="16px 20px" fontSize="16px" radius="8px" - > + /> ); diff --git a/components/common/modals/EditNameModal.tsx b/components/common/modals/EditNameModal.tsx index c5fcae786..d4f2404d6 100644 --- a/components/common/modals/EditNameModal.tsx +++ b/components/common/modals/EditNameModal.tsx @@ -28,7 +28,7 @@ export const EditNameModal = ({ padding="16px 20px" fontSize="16px" radius="8px" - > + /> ); diff --git a/components/common/modals/PopOver.tsx b/components/common/modals/PopOver.tsx index 53b9f68af..23b36449a 100644 --- a/components/common/modals/PopOver.tsx +++ b/components/common/modals/PopOver.tsx @@ -27,11 +27,11 @@ export const PopOver = ({ + /> + /> {$options.map((option, index) => (