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

[민우] - 계획 작성 페이지 분리 및 구현 #281

Merged
merged 26 commits into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9eb6879
✨ : #256 - 세션 스토리지 사용 유틸 훅 useSessionStorage 정의
MinwooP Dec 15, 2023
744182f
✨ : #256 - useSessionStorage 훅 초기값 세션 저장 로직 추가
MinwooP Dec 16, 2023
34362bf
✨ : #256 - 계획 작성 페이지 및 계획 작성 1단계, 2단계 컴포넌트 기본 로직 구현
MinwooP Dec 17, 2023
977ed33
✨ : #256 - 계획 작성 페이지 3단계 컴포넌트 기본 로직 구현
MinwooP Dec 17, 2023
0b2b43a
✨ : #256 - 계획 작성 페이지 4단계 - 리마인드 메세지 컴포넌트 기본 state 구현
MinwooP Dec 17, 2023
c39b81b
✨ : #256 - 계획 작성 페이지 4단계 - 리마인드 메세지 컴포넌트 기본 로직 구현
MinwooP Dec 18, 2023
c516751
✨ : #256 - 계획 리마인드 관련 type, constants 정의 및 위치 이동
MinwooP Dec 18, 2023
7de5a7f
✨ : #256 - 계획 작성 이전단계, 다음단계 버튼 StepButtonGroup 컴포넌트로 변경
MinwooP Dec 18, 2023
aac7f5e
✨ : #256 - 계획 작성 2단계 계획 내용 부분 내부 컴포넌트 연결
MinwooP Dec 18, 2023
b0d5dc5
✨ : #256 - 리마인드 날짜 확정 모달 로직 추가
MinwooP Dec 18, 2023
961c377
✨ : #256 - 세션 스토리지 접근 시 상수 key 사용하도록 변경
MinwooP Dec 18, 2023
22c2c85
✨ : #256 - 계획 작성 시 진행도 표시 CreatePlanStepper 컴포넌트 구현
MinwooP Dec 19, 2023
38480e2
💄 : #256 - CreatePlanIcon 컴포넌트 기본 디자인 구현
MinwooP Dec 19, 2023
6f1d82e
💄 : #256 - CreatePlanIconExample 컴포넌트 구현
MinwooP Dec 19, 2023
ab32473
✨ : #256 - 아이콘 선택 모달 ModalSelectIcon 컴포넌트 구현
MinwooP Dec 19, 2023
f5b1521
💄 : #256 - CreatePlanContent 컴포넌트 디자인 작업
MinwooP Dec 19, 2023
976a2d5
💄 : #256 - CreateRemindDate 컴포넌트 내 요소들 위치 및 크기 조정
MinwooP Dec 19, 2023
86582d2
💄 : #256 - Dropdown Icon 크기 조정 및 리마인드 작성 내 Dropdown 끼리 겹치는 문제 z-index…
MinwooP Dec 19, 2023
c297db7
✨ : #256 - 리마인드 날짜 확정 모달 구현
MinwooP Dec 20, 2023
d712fb2
💄 : #256 - WritableRemindItem 컴포넌트 및 계획 작성 4단계 컴포넌트 디자인 수정
MinwooP Dec 20, 2023
a366de3
✨ : #256 - 동일한 메세지 로직 에러 해결 및 4단계 작성 여부 검사 로직 수정
MinwooP Dec 20, 2023
ff8d4cb
💄 : #256 - 동일한 리마인드 메세지 받기 모달 디자인 구현
MinwooP Dec 20, 2023
0dce105
✨ : #256 - 계획 작성 API 임시 연결
MinwooP Dec 20, 2023
f5b5d37
♻️ : #256 - 기존 creaet 폴더 내 파일 => newCreate 폴더 내 파일로 교체
MinwooP Dec 20, 2023
4a7d2b2
♻️ : #256 - component export index 파일에 추가
MinwooP Dec 20, 2023
e6fdc1d
✨ : #256 - stepper 구분선 안 보이는 문제 해결
MinwooP Dec 20, 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
336 changes: 331 additions & 5 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"react": "^18",
"react-circular-progressbar": "^2.1.0",
"react-dom": "^18",
"react-form-stepper": "^2.0.3",
"react-hot-toast": "^2.4.1",
"react-infinite-scroller": "^1.2.6",
"react-spinners": "^0.13.8",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react';
import { Stepper } from 'react-form-stepper';
import './index.scss';

interface CreatePlanStepperProps {
nowStep: number;
}

export default function CreatePlanStepper({ nowStep }: CreatePlanStepperProps) {
return (
<Stepper
steps={[{ label: '' }, { label: '' }, { label: '' }, { label: '' }]}
activeStep={nowStep}
connectorStateColors={true}
connectorStyleConfig={{
size: 1.5,
style: 'solid',
completedColor: '#f76c5e',
activeColor: '#f76c5e',
disabledColor: '#eee',
}}
styleConfig={{
size: '2rem',
circleFontSize: '1rem',
labelFontSize: '1rem',
borderRadius: '50%',
fontWeight: '500',
activeBgColor: '#f76c5e',
completedBgColor: '#f76c5e',
inactiveBgColor: '#eee',
activeTextColor: '#ffffff',
completedTextColor: '#ffffff',
inactiveTextColor: '#ffffff',
}}
className={'stepper'}
stepClassName={'stepper__step'}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.stepper{
width: 100%;
padding: 2rem 1.5rem;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
'use client';

import { Button } from '@/components';
import { ajajaToast } from '@/components/Toaster/customToast';
import { SESSION_STORAGE_KEY } from '@/constants';
import { usePostNewPlanMutation } from '@/hooks/apis/usePostNewPlanMutation';
import { PlanContentType } from '@/types/Plan';
import { RemindItemType, RemindOptionType } from '@/types/Remind';
import { PostNewPlanRequestBody } from '@/types/apis/plan/PostNewPlan';
import { changeRemindTimeToString } from '@/utils/changeRemindTimeToString';
import classNames from 'classnames';
import { useRouter } from 'next/navigation';
import React from 'react';
import './index.scss';

interface StepButtonGroupProps {
nowStep: number;
goToPreviousStep: () => void;
goToNextStep: () => void;
goToLastStep: () => void;
isFirstStepDataAllExist: boolean;
isSecondStepDataAllExist: boolean;
isLastStepDataAllExist: boolean;
}

export default function StepButtonGroup({
nowStep,
goToPreviousStep,
goToNextStep,
goToLastStep,
isFirstStepDataAllExist,
isSecondStepDataAllExist,
isLastStepDataAllExist,
}: StepButtonGroupProps) {
const router = useRouter();

const isEveryStepDataAllExist =
isFirstStepDataAllExist &&
isSecondStepDataAllExist &&
isLastStepDataAllExist;

const exitCreatePlanPage = () => {
router.back();
};

const handleClickGoToNextStep = (isEachStepDataAllExist: boolean) => {
if (isEachStepDataAllExist) {
goToNextStep();
} else {
ajajaToast.error('모든 항목을 입력해주세요!');
}
};

const { mutate: createNewPlanAPI } = usePostNewPlanMutation();

const handleClickCreatePlan = (isEveryStepDataAllExist: boolean) => {
const planIconItem = sessionStorage.getItem(SESSION_STORAGE_KEY.STEP_1);
const planContentItem = sessionStorage.getItem(SESSION_STORAGE_KEY.STEP_2);
const remindDateItem = sessionStorage.getItem(SESSION_STORAGE_KEY.STEP_3);
const remindMessageItem = sessionStorage.getItem(
SESSION_STORAGE_KEY.STEP_4,
);

if (
isEveryStepDataAllExist &&
planIconItem &&
planContentItem &&
remindDateItem &&
remindMessageItem
) {
const planIcon = JSON.parse(planIconItem) as number;
const planContent = JSON.parse(planContentItem) as PlanContentType;
const remindDate = JSON.parse(remindDateItem) as RemindOptionType;
const remindMessage = JSON.parse(remindMessageItem) as RemindItemType[];

const data: PostNewPlanRequestBody = {
iconNumber: planIcon,
isPublic: planContent.isPublic,
title: planContent.title,
description: planContent.description,
tags: planContent.tags,

remindTotalPeriod: remindDate.TotalPeriod,
remindTerm: remindDate.Term,
remindDate: remindDate.Date,
remindTime: changeRemindTimeToString(remindDate.Time),
messages: remindMessage.map((messageItem) => {
return messageItem.message;
}),
};

createNewPlanAPI(data);
ajajaToast.success('계획 작성 API 실행');
router.push('/home');
} else {
ajajaToast.error('모든 항목을 입력해주세요!');
}
};

return (
<div className={classNames('step-button-group')}>
{(() => {
switch (nowStep) {
case 1:
return (
<>
<Button
background="white-100"
border={true}
color="primary"
onClick={exitCreatePlanPage}
size="sm">
나가기
</Button>
<Button
background="primary"
border={false}
color="white-100"
onClick={() => {
handleClickGoToNextStep(isFirstStepDataAllExist);
}}>
다음 단계
</Button>
</>
);
case 2:
return (
<>
<Button
background="white-100"
border={true}
color="primary"
onClick={goToPreviousStep}>
이전 단계
</Button>
<Button
background="primary"
border={false}
color="white-100"
onClick={() => {
handleClickGoToNextStep(isSecondStepDataAllExist);
}}>
다음 단계
</Button>
</>
);
case 3:
return (
<>
<Button
background="white-100"
border={true}
color="primary"
onClick={goToPreviousStep}>
이전 단계
</Button>
<Button
background="primary"
border={false}
color="white-100"
onClick={() => {
goToLastStep();
}}>
다음 단계
</Button>
</>
);
case 4:
return (
<>
<Button
background="white-100"
border={true}
color="primary"
onClick={goToPreviousStep}>
이전 단계
</Button>
<Button
background="primary"
border={false}
color="white-100"
onClick={() => {
handleClickCreatePlan(isEveryStepDataAllExist);
}}>
작성 완료
</Button>
</>
);
default:
return <div>Invalid nowStep value</div>;
}
})()}
</div>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.step-button-group{
display: flex;
position: absolute;
bottom: 6rem;
width: calc(100% - 3rem);
background-color: transparent;
justify-content: end;
gap: 24px;
}
28 changes: 7 additions & 21 deletions src/app/(header)/create/index.scss
Original file line number Diff line number Diff line change
@@ -1,25 +1,11 @@
.create-page {
padding: 1.75rem 2.5rem;
// height: 100%;
.new-create-page{
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
// overflow: auto;
align-items: center;

&__remind {
&:before {
content: '';
display: block;
height: 0.3px;
background-color: var(--origin-gray-100);
border: 1px solid var(--origin-gray-100);
margin: 2rem 0 2rem 0;
}
&__title{
margin-top: 0rem;
}

&__button__container {
margin-top: 2rem;
display: flex;
justify-content: center;
gap: 13rem;
}
}
}
Loading