Skip to content

Commit 3df3ef8

Browse files
authored
Merge pull request #23 from CarToi/feat/#21/recommendation-page
[feat] #21 추천 페이지 기능 추가/ 제출 완료 페이지/ 서비스 만족도 조사 모달 기능 추가
2 parents 91e31c1 + 56fcfd5 commit 3df3ef8

File tree

15 files changed

+151
-235
lines changed

15 files changed

+151
-235
lines changed

src/app/map/PopupTestPage/PopupTestPage.jsx

Lines changed: 0 additions & 99 deletions
This file was deleted.

src/app/map/page.tsx

Lines changed: 0 additions & 14 deletions
This file was deleted.

src/app/recommend/_components/MapView/SatisfactionModalContent/index.tsx

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/app/recommend/_components/RecommendationPanel/SpaceCard.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ export default function SpaceCard({
1010
position,
1111
category,
1212
image,
13-
// url,
13+
url,
1414
}: RecommendationResponse) {
1515
const city = getCity(position);
1616
return (
17-
<div className="flex h-full w-full gap-2 sm:flex-col sm:gap-3">
17+
<button
18+
onClick={() => {
19+
window.open(url, "_blank");
20+
}}
21+
className="flex h-full w-full cursor-pointer gap-2 hover:bg-[#D1D4DC] sm:flex-col sm:gap-3"
22+
>
1823
<Image
1924
className="size-40 rounded-[6px] object-cover sm:h-[180px] sm:w-full"
2025
src={image || Temp}
@@ -46,6 +51,6 @@ export default function SpaceCard({
4651
)}
4752
</div>
4853
</div>
49-
</div>
54+
</button>
5055
);
5156
}

src/app/recommend/_components/RecommendationPanel/index.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { RecommendationResponse } from "@/lib/type";
22
import SpaceCard from "./SpaceCard";
3+
import ErrorScreen from "@/components/ErrorScreen";
34

45
export default function RecommendationPanel({
56
spaceData,
7+
isError,
68
}: {
79
spaceData: RecommendationResponse[];
10+
isError: boolean;
811
}) {
912
return (
1013
<div className="pointer-events-auto mt-auto flex h-[50vh] rounded-tl-[20px] rounded-tr-[20px] bg-white px-4 py-5 sm:mt-0 sm:h-screen sm:w-[50vw] sm:max-w-[750px] sm:min-w-[500px] sm:rounded-tl-none sm:rounded-br-[20px] sm:p-10">
11-
<div className="scrollbar-hide flex flex-col gap-4 overflow-x-auto sm:gap-10 sm:overflow-hidden">
14+
<div className="scrollbar-hide flex w-full flex-col gap-4 overflow-x-auto sm:gap-10 sm:overflow-hidden">
1215
<div className="flex flex-col gap-2 sm:gap-4">
1316
<h2 className="sm:text-title-large text-title-small text-[#1F2229]">
1417
새길이 오늘 기분에 딱 맞는
@@ -20,11 +23,16 @@ export default function RecommendationPanel({
2023
</p>
2124
</div>
2225
<div className="h-0.5 border border-[#EEEFF2]"></div>
23-
<div className="scrollbar-overlay grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-5 sm:overflow-x-auto">
24-
{spaceData.map((space, index) => (
25-
<SpaceCard key={index} {...space} />
26-
))}
27-
</div>
26+
27+
{isError ? (
28+
<ErrorScreen />
29+
) : (
30+
<div className="scrollbar-overlay grid grid-cols-1 gap-3 sm:grid-cols-2 sm:gap-5 sm:overflow-x-auto">
31+
{spaceData.map((space, index) => (
32+
<SpaceCard key={index} {...space} />
33+
))}
34+
</div>
35+
)}
2836
</div>
2937
</div>
3038
);

src/app/recommend/_components/RetrySurveyButton.tsx

Lines changed: 0 additions & 21 deletions
This file was deleted.

src/app/recommend/_components/SatisfactionModalButton.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/app/recommend/_components/MapView/SatisfactionModalContent/SatisfactionForm.tsx renamed to src/app/recommend/_components/SatisfactionModalContent/SatisfactionForm.tsx

File renamed without changes.

src/app/recommend/_components/MapView/SatisfactionModalContent/hooks/useSatisfactionSubmit.ts renamed to src/app/recommend/_components/SatisfactionModalContent/hooks/useSatisfactionSubmit.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { useState } from "react";
2+
import { useRouter } from "next/navigation";
23
import { UpdateRequest } from "@/lib/type";
34
import { updateSatisfactionScore } from "@/lib/apis/survey";
45

56
export function useSatisfactionSubmit(onClose: () => void) {
67
const [isLoading, setIsLoading] = useState(false);
7-
const [error, setError] = useState<null | string>(null);
8+
const [isError, setIsError] = useState(false);
9+
10+
const router = useRouter();
811

912
const handleSubmit = async (satisfactions: number[]) => {
1013
setIsLoading(true);
11-
setError(null);
14+
setIsError(false);
1215

1316
const clientId = localStorage.getItem("userId") || "";
1417

@@ -20,13 +23,14 @@ export function useSatisfactionSubmit(onClose: () => void) {
2023
try {
2124
await updateSatisfactionScore(payload);
2225
onClose();
26+
router.push("/submit-success");
2327
} catch (err) {
2428
console.error(err);
25-
setError("만족도 정보를 전송하는 데 실패했어요.");
29+
setIsError(true);
2630
} finally {
2731
setIsLoading(false);
2832
}
2933
};
3034

31-
return { handleSubmit, isLoading, error };
35+
return { handleSubmit, isLoading, isError };
3236
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { useState } from "react";
2+
import { useSatisfactionSubmit } from "./hooks/useSatisfactionSubmit";
3+
import SatisfactionForm from "./SatisfactionForm";
4+
import Button from "@/components/Button";
5+
import ErrorScreen from "@/components/ErrorScreen";
6+
7+
export default function SatisfactionModalContent({
8+
onClose,
9+
}: {
10+
onClose: () => void;
11+
}) {
12+
const [satisfactionScores, setSatisfactionScores] = useState([0, 0, 0]);
13+
14+
const { handleSubmit, isLoading, isError } = useSatisfactionSubmit(onClose);
15+
16+
return (
17+
<div className="flex h-full flex-col gap-8 sm:gap-16">
18+
<div className="flex shrink-0 flex-col gap-1 sm:gap-2.5">
19+
<h1 className="text-title-small sm:text-heading-small text-[#1F2229]">
20+
추천받는 과정은 어떠셨나요?
21+
</h1>
22+
<p className="text-body-small sm:text-body-medium text-[#79839A]">
23+
작은 의견 하나가 더 나은 새길을 만드는 데 큰 힘이 돼요 :)
24+
</p>
25+
</div>
26+
{isError ? (
27+
<ErrorScreen />
28+
) : (
29+
<>
30+
<div className="flex flex-1 flex-col gap-10 overflow-y-auto sm:gap-12">
31+
<SatisfactionForm
32+
scores={satisfactionScores}
33+
setScores={setSatisfactionScores}
34+
/>
35+
</div>
36+
<div className="flex shrink-0 justify-center gap-3">
37+
<Button
38+
color="gray"
39+
onClick={onClose}
40+
className="text-body-large h-[62px] w-full max-w-[150px] rounded-xl sm:w-[150px]"
41+
>
42+
다음에 하기
43+
</Button>
44+
<Button
45+
color="blue"
46+
onClick={() => handleSubmit(satisfactionScores)}
47+
className="text-body-large h-[62px] w-full max-w-[150px] rounded-xl sm:w-[150px]"
48+
disabled={isLoading || satisfactionScores.includes(0)}
49+
>
50+
보내기
51+
</Button>
52+
</div>
53+
</>
54+
)}
55+
</div>
56+
);
57+
}

0 commit comments

Comments
 (0)