Skip to content

Commit d42237f

Browse files
authored
QA: 나머지 qa 반영 (#188)
* feat: 드롭다운 여닫을 때 애니메이션 추가 * refactor: 칩의 size prop 제거 * feat: 드롭다운 애니메이션 추가 * refactor: card-container 모바일 화면 간격 조정 * refactor: 좋아요 mutation 실행 후 쿼리키 무효화되도록 수정 * refactor: qa 반영 * feat: 로딩화면 2초동안 보여지도록 수정 * refactor: intro step에서, 제목을 입력하지 않으면 버튼이 disabled 되도록 수정 * refactor: 로딩상태일 때 스피너 추가 * refactor: 열림 애니메이션 타이밍 일치되도록 수정
1 parent f63e6b0 commit d42237f

17 files changed

Lines changed: 157 additions & 81 deletions

File tree

app/(main)/explore/_components/card-container/card-container.css.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { style } from "@vanilla-extract/css";
22

33
export const cardContainer = style({
44
display: "grid",
5-
gap: "1.2rem",
6-
rowGap: "3.2rem",
5+
gap: "0.8rem",
6+
rowGap: "2.4rem",
77
width: "100%",
88
padding: "1.6rem",
99
paddingTop: "2.3rem",
@@ -17,6 +17,8 @@ export const cardContainer = style({
1717
},
1818
"(min-width: 1024px)": {
1919
gridTemplateColumns: "repeat(4, 1fr)",
20+
gap: "1.2rem",
21+
rowGap: "3.2rem",
2022
},
2123
},
2224
});

app/(main)/my-capsule/_components/card-container/card-container.css.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ import { style } from "@vanilla-extract/css";
22

33
export const cardContainer = style({
44
display: "grid",
5-
gap: "1.2rem",
6-
rowGap: "3.2rem",
5+
6+
gap: "0.8rem",
7+
rowGap: "2.4rem",
78
width: "100%",
89
padding: "1.6rem",
910
paddingTop: "2.3rem",
@@ -18,6 +19,8 @@ export const cardContainer = style({
1819
},
1920
"(min-width: 1024px)": {
2021
gridTemplateColumns: "repeat(4, 1fr)",
22+
gap: "1.2rem",
23+
rowGap: "3.2rem",
2124
},
2225
},
2326
});

app/(sub)/capsule-detail/_components/modal/index.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ export default function Modal({
4242

4343
if (!isOpen) return null;
4444

45-
const handleOverlayClick = (event: React.MouseEvent<HTMLDivElement>) => {
46-
if (event.target === event.currentTarget) {
47-
onClose();
48-
}
49-
};
5045

5146
const contentStyles = fullScreenOnMobile
5247
? `${styles.content} ${contentClassName || ""}`
@@ -55,7 +50,6 @@ export default function Modal({
5550
return createPortal(
5651
<div
5752
className={`${styles.overlay} ${overlayClassName || ""}`}
58-
onClick={handleOverlayClick}
5953
onKeyDown={(event) => {
6054
if (
6155
(event.key === "Enter" || event.key === " ") &&

app/(sub)/capsule-detail/_components/write-modal/index.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import RevealMotion from "@/shared/ui/motion/reveal-motion";
77
import ShakeYMotion from "@/shared/ui/motion/shakeY-motion";
88
import PopupConfirmLetter from "@/shared/ui/popup/popup-confirm-letter";
99
import PopupWarningLetter from "@/shared/ui/popup/popup-warning-letter";
10-
import SprinkleContainer from "@/shared/ui/sprinkle-container";
11-
10+
import { PulseLoader } from "react-spinners";
1211
import { useWriteLetter } from "@/shared/api/mutations/letter";
1312
import type { CapsuleDetailRes } from "@/shared/types/api/capsule";
1413
import type { WriteLetterReq } from "@/shared/types/api/letter";
@@ -49,7 +48,7 @@ const WriteModal = ({
4948
capsuleId: capsuleData.result.id.toString(),
5049
content: "",
5150
from: "",
52-
objectKeys: "",
51+
objectKey: "",
5352
},
5453
});
5554

@@ -65,7 +64,7 @@ const WriteModal = ({
6564

6665
const { uploadedImageUrl, handleImageUpload, removeImage, isUploading } =
6766
useImageUpload({
68-
onObjectKeyChange: (value) => setValue("objectKeys", value),
67+
onObjectKeyChange: (value) => setValue("objectKey", value),
6968
});
7069

7170
// 모달이 열릴 때마다 폼 초기화
@@ -75,7 +74,7 @@ const WriteModal = ({
7574
capsuleId: capsuleData.result.id.toString(),
7675
content: "",
7776
from: "",
78-
objectKeys: "",
77+
objectKey: "",
7978
});
8079
if (uploadedImageUrl) {
8180
removeImage();
@@ -124,9 +123,9 @@ const WriteModal = ({
124123
<button
125124
type="submit"
126125
className={styles.title}
127-
disabled={isPending || isUploading}
126+
disabled={(isPending || isUploading)}
128127
>
129-
{isPending ? "제출 중..." : isUploading ? "업로드 중..." : "편지담기"}
128+
{(isPending || isUploading) ? <PulseLoader color="#FFFFFF" size={5}/> : '편지담기'}
130129
</button>
131130
</div>
132131

app/(sub)/capsule-detail/_components/write-modal/write-modal.css.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ export const content = style({
6969
});
7070

7171
export const title = style({
72+
display: "flex",
73+
alignItems: "center",
74+
justifyContent: "center",
7275
...themeVars.text.B1,
7376
color: themeVars.color.purple[10],
7477
margin: 0,

app/(sub)/create-capsule/_components/steps/intro-step/index.tsx

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface Props {
1414
}
1515

1616
const IntroStep = ({ handleNextStep }: Props) => {
17-
const { control, getValues } = useFormContext();
17+
const { control} = useFormContext();
1818

1919
const { field: titleField } = useController({
2020
name: "title",
@@ -27,11 +27,6 @@ const IntroStep = ({ handleNextStep }: Props) => {
2727
});
2828

2929
const handleClickNext = () => {
30-
const title = getValues("title");
31-
if (!title?.trim()) {
32-
alert("타임캡슐 이름을 입력해주세요.");
33-
return;
34-
}
3530
handleNextStep("date");
3631
};
3732

@@ -80,7 +75,7 @@ const IntroStep = ({ handleNextStep }: Props) => {
8075
</RevealMotion>
8176
<RevealMotion delay={1.2}>
8277
<div className={styles.buttonContainer}>
83-
<Button variant="primary" text="다음" onClick={handleClickNext} />
78+
<Button variant="primary" text="다음" onClick={handleClickNext} disabled={!titleField.value?.trim()} />
8479
</div>
8580
</RevealMotion>
8681
</main>

app/(sub)/create-capsule/page.tsx

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"use client";
22
import { useCreateCapsule } from "@/shared/api/mutations/capsule";
3-
import { Suspense, useState } from "react";
4-
3+
import { Suspense, useState, useEffect } from "react";
54
import CreateCapsuleLoading from "@/app/(sub)/create-capsule/_components/create-capsule-loading";
65
import { useFunnel } from "@/shared/hooks/use-funnel";
76
import type { CreateCapsuleReq } from "@/shared/types/api/capsule";
@@ -33,8 +32,9 @@ interface CapsuleInfo {
3332
const CreateCapsule = () => {
3433
const { Funnel, Step, setStep, step } = useFunnel();
3534
const [capsuleInfo, setCapsuleInfo] = useState<CapsuleInfo | null>(null);
35+
const [showLoading, setShowLoading] = useState(false);
3636
const { open } = useOverlay();
37-
37+
3838
const { mutate: createCapsuleMutate, isPending } = useCreateCapsule();
3939

4040
const defaultOpenDate = getDate(14);
@@ -71,12 +71,25 @@ const CreateCapsule = () => {
7171
id: res.result.id,
7272
inviteCode: res.result.inviteCode,
7373
});
74-
setStep("complete");
7574
},
7675
});
7776
};
7877

79-
if (isPending) {
78+
// 로딩 화면 2초 동안 지속
79+
useEffect(() => {
80+
if (isPending) {
81+
setShowLoading(true);
82+
} else if (showLoading && !isPending) {
83+
const timer = setTimeout(() => {
84+
setShowLoading(false);
85+
setStep("complete");
86+
}, 2000);
87+
88+
return () => clearTimeout(timer);
89+
}
90+
}, [isPending, showLoading]);
91+
92+
if (showLoading) {
8093
return <CreateCapsuleLoading />;
8194
}
8295

app/(sub)/search/_components/card-container/card-container.css.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { style } from "@vanilla-extract/css";
22

33
export const cardContainer = style({
44
display: "grid",
5-
gap: "1.2rem",
6-
rowGap: "3.2rem",
5+
gap: "0.8rem",
6+
rowGap: "2.4rem",
77
width: "100%",
88
padding: "1.6rem",
99
paddingTop: "2.3rem",
@@ -16,6 +16,8 @@ export const cardContainer = style({
1616
gridTemplateColumns: "repeat(3, 1fr)",
1717
},
1818
"(min-width: 1024px)": {
19+
gap: "1.2rem",
20+
rowGap: "3.2rem",
1921
gridTemplateColumns: "repeat(4, 1fr)",
2022
},
2123
},

shared/api/mutations/capsule.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,16 @@ import { useQueryClient } from "@tanstack/react-query";
99
import { apiClient } from "../api-client";
1010

1111
export const useCreateCapsule = () => {
12+
const queryClient = useQueryClient();
1213
return useMutation({
1314
mutationFn: async (data: CreateCapsuleReq): Promise<CreateCapsuleRes> => {
1415
return await apiClient.post<CreateCapsuleRes>(ENDPOINTS.CREATE_CAPSULE, {
1516
json: data,
1617
});
1718
},
19+
onSuccess: () => {
20+
queryClient.invalidateQueries({ queryKey: capsuleQueryKeys.all() });
21+
},
1822
});
1923
};
2024

@@ -27,32 +31,21 @@ export const useLikeToggle = () => {
2731
} else {
2832
await apiClient.put(ENDPOINTS.LIKE_TOGGLE(id));
2933
}
30-
return id;
3134
},
32-
onSuccess: (id: string) => {
33-
queryClient.invalidateQueries({
34-
queryKey: capsuleQueryKeys.detail(id),
35-
});
35+
onSuccess: () => {
36+
queryClient.invalidateQueries({ queryKey: capsuleQueryKeys.all() });
3637
},
3738
});
3839
};
3940

4041
export const useLeaveCapsule = () => {
4142
const queryClient = useQueryClient();
4243
return useMutation({
43-
mutationFn: async (id: string) => {
44-
await apiClient.delete(ENDPOINTS.LEAVE_CAPSULE(id));
45-
return id;
44+
mutationFn: (id: string) => {
45+
return apiClient.delete(ENDPOINTS.LEAVE_CAPSULE(id));
4646
},
47-
onSuccess: async (id: string) => {
48-
await Promise.all([
49-
queryClient.invalidateQueries({
50-
queryKey: capsuleQueryKeys.detail(id),
51-
}),
52-
queryClient.invalidateQueries({ queryKey: capsuleQueryKeys.lists() }),
53-
queryClient.invalidateQueries({ queryKey: capsuleQueryKeys.my() }),
54-
queryClient.invalidateQueries({ queryKey: capsuleQueryKeys.all() }),
55-
]);
47+
onSuccess: () => {
48+
queryClient.invalidateQueries({ queryKey: capsuleQueryKeys.all() });
5649
},
5750
});
5851
};

shared/types/api/letter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,6 @@ export interface LetterListRes {
3232
export interface WriteLetterReq {
3333
capsuleId: string;
3434
content: string;
35-
objectKeys: string;
35+
objectKey: string;
3636
from: string;
3737
}

0 commit comments

Comments
 (0)