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: 일정 만들기 추가 구현 #55

Open
wants to merge 31 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
bedefe7
[feat] 썸네일 선택 후 대표 이미지 표시
Choi-Jinwook Nov 26, 2023
d0158b3
[feat] 사이드바 클릭 상태 설정
Choi-Jinwook Nov 27, 2023
5ec4709
[feat] constant 분리
Choi-Jinwook Nov 27, 2023
4e85caf
[fix] 사이드바 버그 수정
Choi-Jinwook Nov 27, 2023
5f3fa95
[feat] 사이드바 메뉴 클릭 시 해당 위치 이동 로직 추가
Choi-Jinwook Nov 27, 2023
8069dbf
Merge remote-tracking branch 'Catcher-origin/develop' into feat/makeplan
Choi-Jinwook Nov 27, 2023
1b1d7f2
[feat] 템플릿, 작성중 일정 msw 적용
Choi-Jinwook Nov 30, 2023
6c4f3e7
[feat] 템플릿, 작성 중 일정 타입 통일
Choi-Jinwook Nov 30, 2023
031c192
[feat] 불러온 데이터 적용
Choi-Jinwook Nov 30, 2023
63f25f8
[feat] 작성 중 일정이 없는 경우 핸들링
Choi-Jinwook Nov 30, 2023
93541bf
Merge remote-tracking branch 'Catcher-origin/develop' into feat/makeplan
Choi-Jinwook Nov 30, 2023
fe1f6e2
[fix] 다른 프로세스 이동 시 제목 날아가는 현상 수정
Choi-Jinwook Dec 4, 2023
28f3491
[feat] 사용하지 않는 리코일 제거
Choi-Jinwook Dec 4, 2023
d679a93
[feat] 상단 현재페이지 표시문구 관리 로직 변경
Choi-Jinwook Dec 4, 2023
4464110
[feat] 작성 중 일정 없을 때 프로세스 관리 로직 상위 컴포넌트로 이동
Choi-Jinwook Dec 4, 2023
e5f2497
[feat] 가독성을 위한 리코일 이름 변경
Choi-Jinwook Dec 4, 2023
5cd97e5
[feat] 타입 추가
Choi-Jinwook Dec 7, 2023
350bf01
[feat] API 요청 경로 추가
Choi-Jinwook Dec 7, 2023
99f16e6
[feat] 변경된 타입 적용
Choi-Jinwook Dec 7, 2023
c66d173
[feat] msw 타입, 경로 수정
Choi-Jinwook Dec 7, 2023
f1860e5
Merge remote-tracking branch 'Catcher-origin/develop' into feat/makeplan
Choi-Jinwook Dec 7, 2023
8d73ce3
[feat] interface key 통일
Choi-Jinwook Dec 8, 2023
8fd804a
[feat] 기본정보 임시저장 msw 적용
Choi-Jinwook Dec 8, 2023
618b669
[feat] 임시저장 post method 추가
Choi-Jinwook Dec 8, 2023
1052446
[feat] 지역 정보 추가
Choi-Jinwook Dec 10, 2023
162b2c5
[feat] default export 추가
Choi-Jinwook Dec 10, 2023
c1f354d
[feat] 지역 타입 추가
Choi-Jinwook Dec 10, 2023
0878aa6
[feat] 지역 선택 모달 세팅
Choi-Jinwook Dec 10, 2023
44c7b3e
[feat] 지역 선택 로직 구성
Choi-Jinwook Dec 10, 2023
2edc490
[feat] 기본정보 버튼 비활성화 추가
Choi-Jinwook Dec 10, 2023
4a8ef06
[feat] 기본정보 post method try-catch 적용
Choi-Jinwook Dec 10, 2023
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
5 changes: 4 additions & 1 deletion pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import Confirm from "@shared/modal/Confirm";
import Modal from "@shared/modal/Modal";
import "@shared/styles/globals.css";

if (process.env.NODE_ENV === "development" && process.env.MOCK === "true") {
if (
process.env.NEXT_PUBLIC_NODE_ENV === "development" &&
process.env.NEXT_PUBLIC_MOCK === "true"
) {
import("mock");
}

Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
35 changes: 33 additions & 2 deletions pages/create-schedule/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,43 @@
import { PlanContent, PlanSideBar } from "@create-schedule/components";
import axios from "axios";
import { GetServerSideProps } from "next";
import { ScheduleCardSection } from "@shared/types";

const CreateSchedule = () => {
interface CreateScheduleProps {
remains: ScheduleCardSection[];
templates: ScheduleCardSection[];
}

const CreateSchedule = ({ remains, templates }: CreateScheduleProps) => {
return (
<div className="w-full h-without-header mt-[78px]">
<PlanSideBar />
<PlanContent />
<PlanContent remains={remains} templates={templates} />
</div>
);
};

export default CreateSchedule;

export const getServerSideProps: GetServerSideProps = async () => {
try {
const [remainResponse, templateResponse] = await axios.all([
axios.get(`${process.env.NEXT_PUBLIC_BASE_URL}/remains`),
axios.get(`${process.env.NEXT_PUBLIC_BASE_URL}/templates`),
]);

return {
props: {
remains: remainResponse.data as ScheduleCardSection[],
templates: templateResponse.data as ScheduleCardSection[],
},
};
} catch (error) {
return {
props: {
remains: [],
templates: [],
},
};
}
};
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
33 changes: 25 additions & 8 deletions src/create-schedule/components/BasicInfo.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,48 @@
import { useState } from "react";
import { BASIC_INFO_TAG } from "@create-schedule/constants";
import { useEffect, useState } from "react";
import MenuContent from "./MenuContent";
import MenuContentContainer from "./MenuContentContainer";
import SideBarMenuBox from "./SideBarMenuBox";

interface BasicInfoProps {}
interface BasicInfoProps {
current: number;
currentTab: string;
handleTab: (value: string) => void;
}

const BasicInfo = ({}: BasicInfoProps) => {
const boxTitle = "기본정보";
const BasicInfo = ({ current, currentTab, handleTab }: BasicInfoProps) => {
const [isOpen, setIsOpen] = useState(false);

const handleToggle = () => {
setIsOpen((prev) => !prev);
};

useEffect(() => {
if (current === 2) {
setIsOpen(true);
}
}, [current]);

return (
<>
<SideBarMenuBox
title={boxTitle}
title="기본정보"
isOpen={isOpen}
isAccordion
handleToggle={handleToggle}
/>
{isOpen && (
<MenuContentContainer>
<MenuContent title="카테고리 태그 입력" boxTitle={boxTitle} />
<MenuContent title="시작일 종료일 설정" boxTitle={boxTitle} />
<MenuContent title="위치 선택" boxTitle={boxTitle} />
{BASIC_INFO_TAG.map((title) => (
<MenuContent
key={title}
title={title}
boxTitle="기본정보"
targetProgress={2}
currentTab={currentTab}
handleTab={handleTab}
/>
))}
</MenuContentContainer>
)}
</>
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
20 changes: 18 additions & 2 deletions src/create-schedule/components/FillPlan.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
import { useSetRecoilState } from "recoil";
import { currentPageName, currentProgress } from "@shared/recoil";
import SideBarMenuBox from "./SideBarMenuBox";

const FillPlan = () => {
interface FillPlanProps {
handleTab: (value: string) => void;
}

const FillPlan = ({ handleTab }: FillPlanProps) => {
const setCurrentPage = useSetRecoilState(currentPageName);
const setCurrentProgress = useSetRecoilState(currentProgress);

return (
<div className="border-b-2 border-[#F1F1F1]">
<div
className="border-b-2 border-[#F1F1F1]"
onClick={() => {
handleTab("일정 채우기");
setCurrentPage("일정 채우기");
setCurrentProgress(4);
}}
>
<SideBarMenuBox title="일정 채우기" />
</div>
);
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
36 changes: 30 additions & 6 deletions src/create-schedule/components/FinishWriting.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,52 @@
import { useState } from "react";
import { FINISH_WRITING_TAG } from "@create-schedule/constants";
import { useEffect, useState } from "react";
import MenuContent from "./MenuContent";
import MenuContentContainer from "./MenuContentContainer";
import SideBarMenuBox from "./SideBarMenuBox";

const FinishWriting = () => {
const boxTitle = "작성 마무리";
interface FinishWritingProps {
current: number;
currentTab: string;
handleTab: (value: string) => void;
}

const FinishWriting = ({
current,
currentTab,
handleTab,
}: FinishWritingProps) => {
const [isOpen, setIsOpen] = useState(false);

const handleToggle = () => {
setIsOpen((prev) => !prev);
};

useEffect(() => {
if (current === 5) {
setIsOpen(true);
}
}, [current]);

return (
<>
<SideBarMenuBox
title={boxTitle}
title="작성 마무리"
isOpen={isOpen}
isAccordion
handleToggle={handleToggle}
/>
{isOpen && (
<MenuContentContainer>
<MenuContent title="공개범위 설정" boxTitle={boxTitle} />
<MenuContent title="일정 소개" boxTitle={boxTitle} />
{FINISH_WRITING_TAG.map((title) => (
<MenuContent
key={title}
title={title}
boxTitle="작성 마무리"
targetProgress={5}
currentTab={currentTab}
handleTab={handleTab}
/>
))}
</MenuContentContainer>
)}
</>
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
25 changes: 19 additions & 6 deletions src/create-schedule/components/MenuContent.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
import { useSetRecoilState } from "recoil";
import { currentPageName } from "@shared/recoil";
import { currentPageName, currentProgress } from "@shared/recoil";
import { CurrentPageType } from "@shared/types";

interface MenuContentProps {
title: string;
boxTitle: CurrentPageType;
isClicked?: boolean;
targetProgress: number;
currentTab: string;
handleTab: (value: string) => void;
}

const MenuContent = ({ title, boxTitle, isClicked }: MenuContentProps) => {
const MenuContent = ({
title,
boxTitle,
targetProgress,
currentTab,
handleTab,
}: MenuContentProps) => {
const setCurrentPage = useSetRecoilState(currentPageName);
const setCurrentProgress = useSetRecoilState(currentProgress);

return (
<div
className={`${
isClicked ? "text-[#F864A1]" : "text-[#333333]"
currentTab === title ? "text-[#F864A1]" : "text-[#333333]"
} h-1/2 leading-[23px] py-[6px] cursor-pointer`}
onClick={() => setCurrentPage(boxTitle)}
onClick={() => {
handleTab(title);
setCurrentPage(boxTitle);
setCurrentProgress(targetProgress);
}}
>
{title}
<a href={`#${title}`}>{title}</a>
</div>
);
};
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
23 changes: 18 additions & 5 deletions src/create-schedule/components/PageContent.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
import { SUBTITLE, TITLE } from "@create-schedule/constants";
import { useRecoilValue } from "recoil";
import { useEffect } from "react";
import { useRecoilState } from "recoil";
import { currentProgress } from "@shared/recoil";
import { ScheduleCardSection } from "@shared/types";
import PlanDefaultInfo from "./PlanDefaultInfo";
import Remains from "./Remains";
import ScheduleTagTemplate from "./ScheduleTagTemplate";
import Title from "./Title";

const PageContent = () => {
const current = useRecoilValue(currentProgress);
interface PageContentProps {
remains: ScheduleCardSection[];
templates: ScheduleCardSection[];
}

const PageContent = ({ remains, templates }: PageContentProps) => {
const [current, setCurrent] = useRecoilState(currentProgress);

useEffect(() => {
if (remains.length === 0 && current !== 2) {
setCurrent(2);
}
}, [remains]);

return (
<>
Expand All @@ -17,7 +30,7 @@ const PageContent = () => {
title={TITLE.remains}
subTitle={SUBTITLE.fighting("명란마요")}
/>
<Remains />
<Remains remains={remains} />
</>
)}
{current === 2 && (
Expand All @@ -32,7 +45,7 @@ const PageContent = () => {
{current === 3 && (
<div className="w-[628px]">
<Title title={TITLE.tag} subTitle={SUBTITLE.withyou} />
<ScheduleTagTemplate />
<ScheduleTagTemplate templates={templates} />
</div>
)}
</>
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
10 changes: 8 additions & 2 deletions src/create-schedule/components/PlanContent.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import { ScheduleCardSection } from "@shared/types";
import CurrentPage from "./CurrentPage";
import PageContent from "./PageContent";

const PlanContent = () => {
interface PlanContentProps {
remains: ScheduleCardSection[];
templates: ScheduleCardSection[];
}

const PlanContent = ({ remains, templates }: PlanContentProps) => {
return (
<div className="absolute inline-block w-planContent h-planScrollbar px-[66px] py-[36px] overflow-FAQ">
<CurrentPage />
<PageContent />
<PageContent remains={remains} templates={templates} />
</div>
);
};
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
51 changes: 47 additions & 4 deletions src/create-schedule/components/PlanSideBar.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,60 @@
import {
BASIC_INFO_TAG,
FINISH_WRITING_TAG,
TAG_N_TEMPLATE_TAG,
} from "@create-schedule/constants";
import { useEffect, useState } from "react";
import { useRecoilValue } from "recoil";
import { currentProgress } from "@shared/recoil";
import BasicInfo from "./BasicInfo";
import FillPlan from "./FillPlan";
import FinishWriting from "./FinishWriting";
import SideBarIntro from "./SideBarIntro";
import TagNTemplate from "./TagNTemplate";

const PlanSideBar = () => {
const current = useRecoilValue(currentProgress);
const [currentTab, setCurrentTab] = useState("일정 제목 입력");

const handleTab = (value: string) => {
setCurrentTab(value);
};

useEffect(() => {
switch (current) {
case 2:
if (BASIC_INFO_TAG.includes(currentTab)) return;
return setCurrentTab("일정 제목 입력");
case 3:
if (TAG_N_TEMPLATE_TAG.includes(currentTab)) return;
return setCurrentTab("태그");
case 5:
if (FINISH_WRITING_TAG.includes(currentTab)) return;
return setCurrentTab("공개범위 설정");
default:
return setCurrentTab("");
}
}, [current]);

return (
<div className="inline-block w-[241px] h-full border-r-2 border-[#F1F1F1]">
<SideBarIntro />
<BasicInfo />
<TagNTemplate />
<FillPlan />
<FinishWriting />
<BasicInfo
current={current}
currentTab={currentTab}
handleTab={handleTab}
/>
<TagNTemplate
current={current}
currentTab={currentTab}
handleTab={handleTab}
/>
<FillPlan handleTab={handleTab} />
<FinishWriting
current={current}
currentTab={currentTab}
handleTab={handleTab}
/>
</div>
);
};
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion src/create-schedule/components/PlanTitleInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const PlanTitleInput = () => {
};

return (
<div className="mb-[30px]">
<div id="일정 제목 입력" className="mb-[30px]">
<ScheduleTitle title={SCHEDULE_TITLE.planTitle} />
<input
className="w-[628px] h-[55px] border border-[#E0E0E0] rounded-[5px] px-[26px]"
Choi-Jinwook marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Loading