From 721f4c778dd08cdb428342a434e26152ff67e82b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=80=E1=85=A5=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=B2?= Date: Sat, 2 Mar 2024 23:33:00 +0900 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=EC=BF=A0=ED=82=A4=EB=A1=9C=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EB=B0=A9=EC=8B=9D=EC=9D=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=ED=95=A8=EC=97=90=20=EB=94=B0=EB=9D=BC=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EC=97=AC=EB=B6=80=20=ED=99=95?= =?UTF-8?q?=EC=9D=B8=20=EB=A1=9C=EC=A7=81=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/app/(WithNavbar)/layout.tsx | 2 -- .../app/kanban/[generation]/detail/page.tsx | 2 -- frontend/app/page.tsx | 2 -- .../components/user/Validate.component.tsx | 23 ------------------- 4 files changed, 29 deletions(-) delete mode 100644 frontend/components/user/Validate.component.tsx diff --git a/frontend/app/(WithNavbar)/layout.tsx b/frontend/app/(WithNavbar)/layout.tsx index 47adf0b4..843e8ecd 100644 --- a/frontend/app/(WithNavbar)/layout.tsx +++ b/frontend/app/(WithNavbar)/layout.tsx @@ -1,5 +1,4 @@ import CommonNavbar from "@/components/common/navbar/Navbar"; -import Validate from "@/components/user/Validate.component"; import { PropsWithChildren } from "react"; import { headers } from "next/headers"; @@ -13,7 +12,6 @@ const ApplicantPage = ({ children }: WithNavbarLayout) => { return (
- { return (
- { @@ -13,7 +12,6 @@ const HomePage = () => { return (
-
econovation diff --git a/frontend/components/user/Validate.component.tsx b/frontend/components/user/Validate.component.tsx deleted file mode 100644 index d8d074fc..00000000 --- a/frontend/components/user/Validate.component.tsx +++ /dev/null @@ -1,23 +0,0 @@ -"use client"; - -import { localStorage } from "@/src/functions/localstorage"; -import { useRouter } from "next/navigation"; -import { useEffect } from "react"; - -const Validate = () => { - const router = useRouter(); - - useEffect(() => { - if ( - localStorage.get("accessToken", "") === "" || - localStorage.get("refreshToken", "") === "" - ) { - alert("로그인이 필요합니다."); - router.replace("/signin"); - return; - } - }, []); - return <>; -}; - -export default Validate; From fae52217c40bd072f7f66f1305bff97e026effdd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=80=E1=85=A5=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=B2?= Date: Sat, 2 Mar 2024 23:35:40 +0900 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=EC=BF=A0=ED=82=A4=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=ED=95=A8=EC=97=90=20=EB=94=B0=EB=9D=BC=20axi?= =?UTF-8?q?os=20=EB=A1=9C=EC=A7=81=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/apis/user/index.ts | 2 -- frontend/src/functions/axios.ts | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/src/apis/user/index.ts b/frontend/src/apis/user/index.ts index 08d59c40..d981b191 100644 --- a/frontend/src/apis/user/index.ts +++ b/frontend/src/apis/user/index.ts @@ -18,8 +18,6 @@ export const signIn = async ({ email, password }: SignInReq) => { alert("로그인이 성공하였습니다"); } - localStorage.set("accessToken", data.accessToken); - localStorage.set("refreshToken", data.refreshToken); return true; } catch (error) { return false; diff --git a/frontend/src/functions/axios.ts b/frontend/src/functions/axios.ts index d6c39126..3d5c46a6 100644 --- a/frontend/src/functions/axios.ts +++ b/frontend/src/functions/axios.ts @@ -4,6 +4,8 @@ const https = axios.create({ baseURL: process.env.NEXT_PUBLIC_API_URL, }); +https.defaults.withCredentials = true; + https.interceptors.request.use((config) => { const token = JSON.parse(localStorage.getItem("accessToken") ?? '""'); if (token) { @@ -20,8 +22,6 @@ https.interceptors.response.use( }, (error) => { if (error.response.status === 401 || error.response.status === 403) { - localStorage.removeItem("accessToken"); - localStorage.removeItem("refreshToken"); alert("로그인이 필요합니다."); window.location.href = "/signin"; } From 438d106686482e94612c46439ab89dd1f5cd2413 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=80=E1=85=A5=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=B2?= Date: Sat, 2 Mar 2024 23:38:20 +0900 Subject: [PATCH 3/6] =?UTF-8?q?feat:=20=EB=A6=AC=EB=8B=A4=EC=9D=B4?= =?UTF-8?q?=EB=A0=89=ED=8A=B8=EB=A5=BC=20middleware=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/app/(WithNavbar)/admin/page.tsx | 6 ------ frontend/app/(WithNavbar)/applicant/page.tsx | 6 ------ frontend/app/(WithNavbar)/interview/page.tsx | 6 ------ frontend/app/(WithNavbar)/kanban/page.tsx | 6 ------ frontend/middleware.ts | 13 +++++++++++-- 5 files changed, 11 insertions(+), 26 deletions(-) delete mode 100644 frontend/app/(WithNavbar)/admin/page.tsx delete mode 100644 frontend/app/(WithNavbar)/applicant/page.tsx delete mode 100644 frontend/app/(WithNavbar)/interview/page.tsx delete mode 100644 frontend/app/(WithNavbar)/kanban/page.tsx diff --git a/frontend/app/(WithNavbar)/admin/page.tsx b/frontend/app/(WithNavbar)/admin/page.tsx deleted file mode 100644 index 326c7a6a..00000000 --- a/frontend/app/(WithNavbar)/admin/page.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { CURRENT_GENERATION } from "@/src/constants"; -import { redirect } from "next/navigation"; - -const AdminPage = () => redirect(`/admin/${CURRENT_GENERATION}`); - -export default AdminPage; diff --git a/frontend/app/(WithNavbar)/applicant/page.tsx b/frontend/app/(WithNavbar)/applicant/page.tsx deleted file mode 100644 index 0b3bf3b5..00000000 --- a/frontend/app/(WithNavbar)/applicant/page.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { CURRENT_GENERATION } from "@/src/constants"; -import { redirect } from "next/navigation"; - -const ApplicantPage = () => redirect(`/applicant/${CURRENT_GENERATION}`); - -export default ApplicantPage; diff --git a/frontend/app/(WithNavbar)/interview/page.tsx b/frontend/app/(WithNavbar)/interview/page.tsx deleted file mode 100644 index 8691bc26..00000000 --- a/frontend/app/(WithNavbar)/interview/page.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { redirect } from "next/navigation"; -import { CURRENT_GENERATION } from "@/src/constants"; - -const InterviewPage = () => redirect(`/interview/${CURRENT_GENERATION}`); - -export default InterviewPage; diff --git a/frontend/app/(WithNavbar)/kanban/page.tsx b/frontend/app/(WithNavbar)/kanban/page.tsx deleted file mode 100644 index f7b2e690..00000000 --- a/frontend/app/(WithNavbar)/kanban/page.tsx +++ /dev/null @@ -1,6 +0,0 @@ -import { redirect } from "next/navigation"; -import { CURRENT_GENERATION } from "@/src/constants"; - -const ApplicationPage = () => redirect(`/kanban/${CURRENT_GENERATION}`); - -export default ApplicationPage; diff --git a/frontend/middleware.ts b/frontend/middleware.ts index b30e9b73..50bebd06 100644 --- a/frontend/middleware.ts +++ b/frontend/middleware.ts @@ -1,9 +1,18 @@ -import { NextResponse } from "next/server"; +import { NextRequest, NextResponse } from "next/server"; +import { CURRENT_GENERATION } from "./src/constants"; -export function middleware(request: Request) { +export function middleware(request: NextRequest) { const requestHeaders = new Headers(request.headers); requestHeaders.set("x-url", request.url); + const redirectUrl = (url: string) => { + return NextResponse.redirect(new URL(url, request.url)); + }; + const needValidatePath = ["/admin", "/applicant", "/interview", "/kanban"]; + const isRedirectPath = needValidatePath.includes(request.nextUrl.pathname); + if (isRedirectPath) + return redirectUrl(`${request.nextUrl.pathname}/${CURRENT_GENERATION}`); + return NextResponse.next({ request: { headers: requestHeaders, From 12e3d39f6fe458cbed931c0372404799f9812538 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=80=E1=85=A5=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=B2?= Date: Sat, 2 Mar 2024 23:53:20 +0900 Subject: [PATCH 4/6] =?UTF-8?q?refactor:=20=EC=83=81=EC=88=98=20=EB=8D=B0?= =?UTF-8?q?=EC=9D=B4=ED=84=B0=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/middleware.ts | 5 +++-- frontend/src/apis/user/index.ts | 1 - frontend/src/constants/index.ts | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/frontend/middleware.ts b/frontend/middleware.ts index 50bebd06..b1d47bfd 100644 --- a/frontend/middleware.ts +++ b/frontend/middleware.ts @@ -1,5 +1,5 @@ import { NextRequest, NextResponse } from "next/server"; -import { CURRENT_GENERATION } from "./src/constants"; +import { CURRENT_GENERATION, needValidatePath } from "./src/constants"; export function middleware(request: NextRequest) { const requestHeaders = new Headers(request.headers); @@ -8,8 +8,9 @@ export function middleware(request: NextRequest) { const redirectUrl = (url: string) => { return NextResponse.redirect(new URL(url, request.url)); }; - const needValidatePath = ["/admin", "/applicant", "/interview", "/kanban"]; + const isRedirectPath = needValidatePath.includes(request.nextUrl.pathname); + if (isRedirectPath) return redirectUrl(`${request.nextUrl.pathname}/${CURRENT_GENERATION}`); diff --git a/frontend/src/apis/user/index.ts b/frontend/src/apis/user/index.ts index d981b191..a6cf014a 100644 --- a/frontend/src/apis/user/index.ts +++ b/frontend/src/apis/user/index.ts @@ -1,5 +1,4 @@ import { https } from "@/src/functions/axios"; -import { localStorage } from "@/src/functions/localstorage"; interface SignInReq { email: string; diff --git a/frontend/src/constants/index.ts b/frontend/src/constants/index.ts index e9e5dd83..78589899 100644 --- a/frontend/src/constants/index.ts +++ b/frontend/src/constants/index.ts @@ -162,3 +162,10 @@ export const ORDER_MENU = { { type: "score", string: "점수순" }, ], } as const; + +export const needValidatePath = [ + "/admin", + "/applicant", + "/interview", + "/kanban", +]; From efcdd1b752bc94b66dde3158f9e14218a3e422b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=87=E1=85=A1=E1=86=A8=E1=84=80=E1=85=A5=E1=86=AB?= =?UTF-8?q?=E1=84=80=E1=85=B2?= Date: Sun, 3 Mar 2024 00:40:46 +0900 Subject: [PATCH 5/6] =?UTF-8?q?chore:=20=EB=B8=8C=EB=9E=9C=EC=B9=98=20?= =?UTF-8?q?=EC=B5=9C=EC=8B=A0=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../applicationNode/NextButton.component.tsx | 33 ++++++++--------- frontend/components/common/navbar/Button.tsx | 13 +++---- .../components/kanban/Navbar.component.tsx | 2 +- frontend/src/constants/kanban/27.ts | 35 +++++++++++++++++++ 4 files changed, 57 insertions(+), 26 deletions(-) create mode 100644 frontend/src/constants/kanban/27.ts diff --git a/frontend/components/application/applicationNode/NextButton.component.tsx b/frontend/components/application/applicationNode/NextButton.component.tsx index 0388b927..52edf877 100644 --- a/frontend/components/application/applicationNode/NextButton.component.tsx +++ b/frontend/components/application/applicationNode/NextButton.component.tsx @@ -13,34 +13,29 @@ interface ApplicationNextButtonProps { isLast?: boolean; } +// etc. 단순히 boolean이 아닌 어느 곳에서 터지는 지와 그 이유를 담은 객체를 반환하면 어떨까? // TODO: 질문의 이름마다 side effect가 있으니 주의하면 좋을 것 -const canNext = (applicationName: Array) => { - return applicationName.every((name) => { +const canNext = (applicationNames: Array) => { + return applicationNames.every((name) => { + const EMPTY_STRING: string = ""; + const localStorageValueFromName = localStorage.get(name, EMPTY_STRING); + if ( name === "personalInformationAgreeForPortfolio" || name === "personalInformationAgree" ) { - return ( - localStorage.get(name) !== "동의하지 않습니다." && - localStorage.get(name, "") !== "" - ); + return localStorageValueFromName === "동의합니다."; } if (name === "email") { - return isEmail(localStorage.get(name, "")); + return isEmail(localStorageValueFromName); } if (name === "check") { - return localStorage.get(name) === "확인했습니다"; - } - if (localStorage.get(name, "").length === 0) { - if ( - name === "channel" && - localStorage.get("channelEtc", "").length !== 0 - ) { - return true; - } - return false; + return localStorageValueFromName === "확인했습니다"; } - return true; + return ( + !(localStorageValueFromName.length === 0) || + (name === "channel" && localStorage.get("channelEtc", EMPTY_STRING).length !== 0) + ); }); }; @@ -57,7 +52,7 @@ const ApplicationNextButton = ({ ); if (!canNext(Array.from(applicationName))) { alert("필수 항목을 입력해주세요."); - return false; + return; } if (isLast) { diff --git a/frontend/components/common/navbar/Button.tsx b/frontend/components/common/navbar/Button.tsx index 867fa626..7d7530f5 100644 --- a/frontend/components/common/navbar/Button.tsx +++ b/frontend/components/common/navbar/Button.tsx @@ -2,6 +2,7 @@ import { KANBAN_MENU } from "@/src/constants/kanban/26"; import { KanbanSelectedButtonNumberState } from "@/src/stores/kanban/Navbar.atoms"; +import { cn } from "@/src/utils/cn"; import { useAtom } from "jotai"; type NavbarButtonProps = { @@ -14,19 +15,19 @@ const NavbarButton = ({ value }: NavbarButtonProps) => { const findmenuIndex = KANBAN_MENU.findIndex((menu) => menu.navTitle === value) + 1; - const buttonClassName = " py-2 px-6 rounded-lg min-w-fit "; + const buttonClassName = "py-2 px-6 rounded-lg min-w-fit"; const onClick = () => { setnavbarId(findmenuIndex.toString()); }; + const isButtonSelected = navbarId === findmenuIndex.toString(); return (