Skip to content

Commit 3545aa3

Browse files
committed
feat: 처음으로 목표를 생성하는 경우 처리
1 parent b221f6e commit 3545aa3

File tree

2 files changed

+34
-14
lines changed

2 files changed

+34
-14
lines changed

src/app/(main)/home/goal-setting/page.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,15 @@ const GoalSetting = () => {
108108
setGoalData(resetState);
109109
};
110110

111+
// useEffect(() => {
112+
// console.log('goalData', goalData);
113+
// }, [goalData]);
114+
111115
return (
112116
<div className={'min-h-screen'}>
113-
{isSettingNewGoalModalOpen ? (
117+
{isSettingNewGoalModalOpen && userGoals ? (
114118
<SettingNewGoalModal
119+
isFirstGoalSetting={userGoals.length === 0} //새로 생성된 목표가 없을 경우
115120
fetchDataAndUpdateState={fetchDataAndUpdateState}
116121
setIsResetButtonClick={setIsResetButtonClick}
117122
resetData={resetData}

src/components/home/goal-setting/SettingNewGoalModal.tsx

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import { useRouter } from 'next/navigation';
12
import { type SVGProps } from 'react';
23
import * as React from 'react';
34

45
interface Props {
6+
isFirstGoalSetting: boolean;
57
setIsSettingNewModal: React.Dispatch<React.SetStateAction<boolean>>;
68
isSettingNewGoalModal: boolean;
79
resetData: () => void;
@@ -10,8 +12,15 @@ interface Props {
1012
}
1113

1214
const SettingNewGoalModal = (props: Props) => {
13-
const { setIsSettingNewModal, isSettingNewGoalModal, resetData, setIsResetButtonClick, fetchDataAndUpdateState } =
14-
props;
15+
const {
16+
isFirstGoalSetting = false,
17+
setIsSettingNewModal,
18+
isSettingNewGoalModal,
19+
resetData,
20+
setIsResetButtonClick,
21+
fetchDataAndUpdateState,
22+
} = props;
23+
const router = useRouter();
1524
return (
1625
<>
1726
<div
@@ -28,10 +37,14 @@ const SettingNewGoalModal = (props: Props) => {
2837
</div>
2938
<div className={'flex flex-col gap-y-4 bg-white rounded-[32px] p-5'}>
3039
<div className={'flex flex-col gap-y-1'}>
31-
<div className={'text-h2 font-semibold text-black'}>이전 목표를 불러올까요?</div>
40+
<div className={'text-h2 font-semibold text-black'}>
41+
{isFirstGoalSetting ? '이전에 세우신 목표가 없어요!' : '이전 목표를 불러올까요?'}
42+
</div>
3243
<div>
33-
<div className={'flex items-center text-h6'}>정보를 불러오면 이전에 설정한 목표를</div>
34-
<div className={'text-h6'}>토대로 작성할 수 있어요.</div>
44+
<div className={'flex items-center text-h6'}>
45+
{isFirstGoalSetting ? '새로운 목표를 세워보시겠어요?' : '정보를 불러오면 이전에 설정한 목표를'}
46+
</div>
47+
{!isFirstGoalSetting && <div className={'text-h6'}>토대로 작성할 수 있어요.</div>}
3548
</div>
3649
</div>
3750
<div className={'flex justify-end gap-x-2'}>
@@ -44,14 +57,16 @@ const SettingNewGoalModal = (props: Props) => {
4457
className={'bg-gray1 rounded-full text-gray4 py-[7px] px-4'}>
4558
새 목표
4659
</button>
47-
<button
48-
onClick={() => {
49-
fetchDataAndUpdateState();
50-
setIsSettingNewModal(!isSettingNewGoalModal);
51-
}}
52-
className={'bg-black rounded-full text-white py-[7px] px-3'}>
53-
불러오기
54-
</button>
60+
{!isFirstGoalSetting && (
61+
<button
62+
onClick={() => {
63+
fetchDataAndUpdateState();
64+
setIsSettingNewModal(!isSettingNewGoalModal);
65+
}}
66+
className={'bg-black rounded-full text-white py-[7px] px-3'}>
67+
불러오기
68+
</button>
69+
)}
5570
</div>
5671
</div>
5772
</div>

0 commit comments

Comments
 (0)