Skip to content

Commit be877ee

Browse files
authored
[Fix] 일기 작성 페이지에서 x 누르면 홈으로 이동 구현 (#64)
* feat: WriteDiaryPage UI 구현 * feat: Check 표시에 대한 이미지 추가 * feat: DiaryHeader 컴포넌트로 분리 * feat: DiaryEditor 와 ImageUploader 컴포넌트 분리 (추후 props driling 생길 시 코드 수정) * feat: DiaryFooter 컴포넌트 구현 * refactor: WriteDiaryPage에서 Diary관련 컴포넌트를 통해 UI 구현되도록 리팩토링 * fix: pt 수정 (pt 중복으로 인한 padding 크기 수정) * refactor: ImageUploader 재사용을 위한 폴더 구조 변경 * fix: 폴더 구조 변경으로 인한 파일 삭제 및 import 수정 * feat: TakePhoto 에서 사용하는 Header 컴포넌트 정의 * feat: TakePhoto에서 사용하는 Main 컴포넌트 정의 * feat: TakePhoto 에서 사용하는 Footer (Button) 정의 * feat: TakePhotoPage 추가 및 라우터 추가 * feat: WriteDiaryPage UI 구현 * fix: 파일 구조 변경 (컴포넌트 재사용) 및 DiaryHeader props 추가 * fix: 파일 이름 일관성을 위한 수정 (TakePhotoMain -> TakePhotoEditor) * PR 리뷰 내용 수정 * fix: check.svg 파일 삭제 * feat: 일기 작성 관련 mutation 구현 * feat: pnael API 로직 구현 * feat: takePhoto 사진 업로드 관련 API 및 훅 로직 구현 * TakePhoto API 연동 구현 * feat: 일기쓰기 img API 로직 구현 * feat: 일일 미션 퀴즈 UI 구현 * fix: 오타 수정 * feat: OX 퀴즈 문제 불러오기 API 구현 * feat: quiz 정답 api 구현 * fix: queryKey 수정 * feat: 일기 작성 이미지 업로드 API 구현 * feat: 일기 작성 API 구현 * feat: OX Quiz 정답 확인 후 로직 구현 * OX Quiz 정답 확인 후 로직 구현 * feat: page별 구분 및 사지선다 UI 구현 * refactor: 체크박스 svg 활용하여 수정 * fix: OX 테두리 버그 수정 * feat: 일기 작성 API 연동 * fix: 스타일 var -> -gray 등으로 수정 * fix: placeholder 색상 변경 * chore: takephoto 관련 파일 삭제 * feat: 일기 작성 후 홈 화면으로 이동하는 로직 추가 * fix: queryKey 수정 * fix: yarn build & constants 폴더 삭제 * fix: 일기 작성 x 클릭 시 홈으로 이동 구현 * feat: pull origin dev 충돌 해결 및 미션 랜덤으로 이동
1 parent d06e70a commit be877ee

21 files changed

Lines changed: 78 additions & 28 deletions

File tree

src/App.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import Layout from "@/components/layout/Layout";
1919
//네비게이션
2020
import Navbar from "@/components/layout/Navbar";
2121

22-
2322
import DailyMissionRoutes from "./routes/dailyMissionRoutes";
2423

2524
import "swiper/css";

src/apis/missions/QuizApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { QUERY_KEYS } from "@/constants/querykey";
21
import { AnswerQuizResponse } from "@/types/realQuiz/answerQuiz";
32
import { getQuizRequest, getQuizResponse } from "@/types/realQuiz/getQuiz";
43

@@ -9,7 +8,8 @@ export const getQuizApi = async (
98
): Promise<getQuizResponse> => {
109
try {
1110
const response = await axios.get("/api/v1/realQuiz", { params });
12-
console.log("QUERY_KEYS.QUIZ.REAL는 다음과 같다.", QUERY_KEYS.REAL);
11+
12+
1313
return response.data;
1414
} catch (error) {
1515
console.error("Error get MissionPanel:", error);

src/assets/icons/common/OX_O.svg

Lines changed: 2 additions & 0 deletions
Loading

src/assets/icons/common/OX_X.svg

Lines changed: 2 additions & 0 deletions
Loading

src/components/bottom-sheet/BottomSheet.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ const BottomSheet: React.FC<{ setIsModalOpen: (isOpen: boolean) => void }> = ({
1818
const [isChecked2] = useState(data?.isDairyCompleted);
1919
const [isChecked3] = useState(data?.isQuizCompleted);
2020
const [percent] = useState(data?.wishTree.progressPercent);
21+
const randomNum = (Math.floor(Math.random() * 3) + 1) % 2;
22+
const path =
23+
randomNum === 1
24+
? "/dailyMission/quiz/multipleChoice"
25+
: "/dailyMission/quiz/ox";
2126

2227
// ===== 스냅/드래그 파라미터 =====
2328

@@ -238,7 +243,7 @@ const BottomSheet: React.FC<{ setIsModalOpen: (isOpen: boolean) => void }> = ({
238243
{
239244
label: "퀴즈 풀기",
240245
on: isChecked3,
241-
action: () => navigate("/dailyMission/quiz"),
246+
action: () => navigate(path),
242247
},
243248
].map(({ label, on, action }, i) => (
244249
<div

src/components/dailyMission/common/DiaryHeader.tsx

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { useNavigate } from "react-router-dom";
2+
13
import XIcon from "@/assets/icons/common/Xmack.svg?url";
24

35
interface DiaryHeaderProps {
@@ -7,10 +9,20 @@ interface DiaryHeaderProps {
79
}
810

911
const DiaryHeader = ({ onSubmit, showSubmit, context }: DiaryHeaderProps) => {
12+
const navigate = useNavigate();
13+
const handleGohomee = () => {
14+
navigate("/");
15+
};
16+
1017
return (
1118
<header className="w-full h-14 flex items-center justify-between p-4 border-b border-gray-200">
1219
<button>
13-
<img src={XIcon} alt="Close" className="w-3.5 h-3.5" />
20+
<img
21+
src={XIcon}
22+
alt="Close"
23+
className="w-3.5 h-3.5"
24+
onClick={handleGohomee}
25+
/>
1426
</button>
1527
<h1 className="text-heading2">{context}</h1>
1628
{showSubmit ? (

src/components/dailyMission/common/ImageUploader.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import React, { useEffect, useState } from "react";
22

3+
34
import { Camera } from "@/assets/icons/common";
45

6+
57
interface ImageUploaderProps {
68
image: File | null;
79
handleImageChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
@@ -37,7 +39,9 @@ const ImageUploader = ({ image, handleImageChange }: ImageUploaderProps) => {
3739
/>
3840
) : (
3941
<div className="flex flex-col gap-2.5 items-center justify-center object-contain">
42+
4043
<Camera className="w-6 h-5" />
44+
4145
<div className="text-gray-600 text-center text-body-sb">
4246
화분을 예쁘게 가꾸고 <br />
4347
친구들에게 멋진 식물을 자랑해보아요

src/components/dailyMission/quiz/MultipleChoiceQuestionQuiz.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
12
import { Check, UnCheck } from "@/assets/icons/common";
23

4+
35
interface MultipleChoiceQuizProps {
46
quizQuestion: string;
57
quizOptions: { optionOrder: number; optionText: string }[] | null;

src/components/dailyMission/quiz/OXQuiz.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ const OX_Quiz: React.FC<OXQuizProps> = ({
3535

3636
if (isCorrect) {
3737
if (value === answerValue) {
38+
3839
return "bg-primary-varient border-primary text-primary";
3940
}
4041
} else {
@@ -43,12 +44,15 @@ const OX_Quiz: React.FC<OXQuizProps> = ({
4344
}
4445
if (value === answerValue) {
4546
return "bg-primary-varient border-primary text-primary";
47+
4648
}
4749
}
4850
}
4951
return selected === value
52+
5053
? "border-gray-600 bg-gray-400"
5154
: "border-gray-400 bg-white text-gray-400";
55+
5256
};
5357

5458
const handleClick = (value: number) => {
@@ -64,13 +68,17 @@ const OX_Quiz: React.FC<OXQuizProps> = ({
6468
className={`${baseBoxClass} ${getBoxClass(0)} `}
6569
onClick={() => handleClick(0)}
6670
>
71+
6772
<OX_O width={32} height={32} />
73+
6874
</div>
6975
<div
7076
className={`${baseBoxClass} ${getBoxClass(1)}`}
7177
onClick={() => handleClick(1)}
7278
>
79+
7380
<OX_X width={32} height={32} />
81+
7482
</div>
7583
</div>
7684
</div>

src/components/dailyMission/writeDiary/DiaryFooter.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
12
import { Check, UnCheck } from "@/assets/icons/common";
23

4+
35
interface DiaryFooterProps {
46
isPublic: boolean;
57
onVisibilityChange: (isPublic: boolean) => void;

0 commit comments

Comments
 (0)