Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: current generation 업데이트 #157

Merged
merged 15 commits into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions frontend/app/(WithNavbar)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import CommonNavbar from "@/components/common/navbar/Navbar";
import { PropsWithChildren } from "react";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type import를 사용해봅시다 :)

Suggested change
import { PropsWithChildren } from "react";
import { type PropsWithChildren } from "react";

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 수정하겠습니다!

import { headers } from "next/headers";

interface WithNavbarLayout extends PropsWithChildren {}

const ApplicantPage = ({ children }: WithNavbarLayout) => {
const headersList = headers();
const header_url = headersList.get("x-url") || "";
const [_, __, ___, generation, ____] = header_url.split(/[/?]+/);

return (
<div className="px-24 min-w-[1280px] flex p-12">
<CommonNavbar generation={generation} />
<CommonNavbar />
{children}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/kanban/[generation]/detail/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const KanbanBoardDetailPage = ({
return (
<main className="flex mt-8 overflow-auto pt-12 pl-12">
<KanbanColumnDetailCard
columnIndex={+columnIndex ?? 0}
columnIndex={+(columnIndex ?? 0)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 바꾸기 전 코드와 바꾼 코드 둘 다 문자형을 숫자형으로 바꿔준다고 생각하는데 어떤 차이가 있나요?

  • KanbanColumnDetailCard 컴포넌트에서 columnIndex가 0으로 넘겨받는다면 useQuery에 enabled 속성을 넣어서 api 호출을 안하는게 좋아보입니다.

  • page.tsx에서 columnIndex를 props로 넘기는 것 대신에 KanbanColumnDetailCard 컴포넌트에서 아래와 같이 사용하면 props를 지울 수 있을 것 같아요

const searchParams = useSearchParams();
searchParams.get("columnIndex");

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아이고 맞네요.. 수정하도록 하겠습니다!

제가 이전에 몇번의 삽질을 했었는데요,
그때 CURRENT_GENERATION 상수값을 .env로 관리하는 게 어떨지 생각하면서 변경했었습니다.
이렇게 되면 CURRENT_GENERATION의 값이 undefined가 될 수 있어서, 단순히 +columnIndex 를 하면 NaN 이 나올 수 있기에 위와같이 수정했었습니다.
결론적으로 현재는 .env로 관리하지 않기 때문에 해당 코드를 불필요하게 좋지 않은 방향으로 변경하게 되었네요..

generation={generation}
cardId={cardId}
applicantId={applicantId}
Expand Down
17 changes: 8 additions & 9 deletions frontend/components/common/navbar/Navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import NavbarUserInfo from "./UserInfo";
import { NavbarOperation } from "./NavbarOperation";
import Link from "next/link";
import { usePathname } from "next/navigation";
import { NavbarToggle } from "./NavbarToggle";

interface CommonNavbarProps {
generation: string;
}

const CommonNavbar = ({ generation }: CommonNavbarProps) => {
const currentPath = usePathname().split("/")[1];
const isShort = currentPath === "kanban";
const CommonNavbar = () => {
const currentPath = usePathname();
const isShort = currentPath.split("/")[1] === "kanban";
const generation = currentPath.split("/")[2];

return (
<nav className="flex flex-col transition-all">
Expand All @@ -25,10 +23,11 @@ const CommonNavbar = ({ generation }: CommonNavbarProps) => {
<div>{generation}th</div>
</Link>
<div className="flex flex-col gap-8 mt-8 text-xl">
{MainNavbar.map((item) => (
{MainNavbar(+generation).map((item) => (
<CommonNavbarCell key={item.type} item={item} />
))}
<NavbarOperation generation={generation} />
<NavbarToggle />
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Toggle이라.. 맞는거 같지만 더 좋은 이름이 없을까유?? 항상 이런 부분이 어려운거 같네요 ㅠㅠ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

맞아요.. 사실 토글이긴 한데 보여질 기수를 변경해주는 토글이니 NavbarGenerationToggle 은 어떠신가요..?

<NavbarOperation />
</div>
<NavbarUserInfo />
</nav>
Expand Down
2 changes: 2 additions & 0 deletions frontend/components/common/navbar/NavbarCell.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const CommonNavbarCell = ({ item }: CommonNavbarCellProps) => {
const currentType = currentPath.split("/")[1];
const isShort = currentType === "kanban";

const generation = currentPath.split("/")[2];

const linkButtonClassName =
"flex justify-between p-4 hover:bg-secondary-100 hover:text-white rounded-lg";

Expand Down
13 changes: 4 additions & 9 deletions frontend/components/common/navbar/NavbarOperation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,11 @@
import { useQuery } from "@tanstack/react-query";
import CommonNavbarCell from "./NavbarCell";
import { getMyInfo } from "@/src/apis/interview";
import { usePathname } from "next/navigation";

interface NavbarOperationProps {
generation: string;
isShort?: boolean;
}

export const NavbarOperation = ({
generation,
isShort = false,
}: NavbarOperationProps) => {
export const NavbarOperation = () => {
const currentPath = usePathname();
const generation = currentPath.split("/")[2];
const { data: userData } = useQuery(["user"], getMyInfo);
if (!userData) {
return <div></div>;
Expand Down
30 changes: 30 additions & 0 deletions frontend/components/common/navbar/NavbarToggle.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { usePathname } from "next/navigation";
import CommonNavbarCell from "./NavbarCell";
import { CURRENT_GENERATION } from "@/src/constants";

export const NavbarToggle = () => {
const currentPath = usePathname();
const selectedGeneration = +currentPath.split("/")[2];

const isCurrentGeneration = selectedGeneration === CURRENT_GENERATION;
const generation = isCurrentGeneration
? CURRENT_GENERATION - 1
: CURRENT_GENERATION;

const short_title = isCurrentGeneration ? "지난 모집" : "현재 모집";
const title = isCurrentGeneration
? "지난 신입모집 보기"
: "현재 신입모집 보기";

return (
<CommonNavbarCell
item={{
href: `/kanban/${generation}`,
short_title,
title,
target: "_self",
type: "toggle",
}}
/>
);
};
86 changes: 41 additions & 45 deletions frontend/src/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export const CURRENT_GENERATION = process.env.NEXT_PUBLIC_CURRENT_GENERATION;
export const CURRENT_GENERATION: number = +(
process.env.NEXT_PUBLIC_CURRENT_GENERATION ?? 0
);

export const MAIN_MENU = [
{
Expand Down Expand Up @@ -33,50 +35,44 @@ export const MAIN_MENU = [
},
] as const;

export const MainNavbar = [
{
title: "신입모집 신청 페이지",
short_title: "신청",
type: "apply",
target: "_blank",
href: `/application`,
},
{
title: "신입모집 칸반보드",
short_title: "칸반보드",
type: "kanban",
target: "none",
href: `/kanban/${CURRENT_GENERATION}`,
},
{
title: "신입모집 면접 기록",
short_title: "면접기록",
type: "interview",
target: "none",
href: `/interview/${CURRENT_GENERATION}`,
},
{
title: "신입모집 지원현황",
short_title: "지원현황",
type: "applicant",
target: "none",
href: `/applicant/${CURRENT_GENERATION}`,
},
{
title: "신입모집 쉐어 포인트",
short_title: "쉐어포인트",
type: "sharepoint",
target: "_blank",
href: "https://ejnu.sharepoint.com/sites/msteams_bbf640/Shared%20Documents/Forms/AllItems.aspx?id=%2Fsites%2Fmsteams_bbf640%2FShared%20Documents%2F2023%EB%85%84%2F1%ED%95%99%EA%B8%B0%2F%EC%8B%A0%EC%9E%85%EB%AA%A8%EC%A7%91&p=true&ga=1",
},
{
title: "지난 신입모집",
short_title: "지난 모집",
type: "history",
target: "_blank",
href: "https://trello.com/b/ioPTFCHN/2023-econovation-1%ED%95%99%EA%B8%B0-%EC%8B%A0%EC%9E%85%EB%AA%A8%EC%A7%91-tf%ED%8C%80",
},
] as const;
export const MainNavbar = (generation: number) =>
[
{
title: "신입모집 신청 페이지",
short_title: "신청",
type: "apply",
target: "_blank",
href: `/application`,
},
{
title: "신입모집 칸반보드",
short_title: "칸반보드",
type: "kanban",
target: "none",
href: `/kanban/${generation}`,
},
{
title: "신입모집 면접 기록",
short_title: "면접기록",
type: "interview",
target: "none",
href: `/interview/${generation}`,
},
{
title: "신입모집 지원현황",
short_title: "지원현황",
type: "applicant",
target: "none",
href: `/applicant/${generation}`,
},
{
title: "신입모집 쉐어 포인트",
short_title: "쉐어포인트",
type: "sharepoint",
target: "_blank",
href: "https://ejnu.sharepoint.com/sites/msteams_bbf640/Shared%20Documents/Forms/AllItems.aspx?id=%2Fsites%2Fmsteams_bbf640%2FShared%20Documents%2F2023%EB%85%84%2F1%ED%95%99%EA%B8%B0%2F%EC%8B%A0%EC%9E%85%EB%AA%A8%EC%A7%91&p=true&ga=1",
},
] as const;

export const APPLICANT_KEYS = [
"field",
Expand Down