Skip to content

Commit b2088c7

Browse files
authored
Merge pull request #43 from SWYP-mingling/feature/QA-midpoint-ui
fix : 중간모임 카테고리 & 환승경로 수정
2 parents 0e0550b + 134d056 commit b2088c7

4 files changed

Lines changed: 104 additions & 77 deletions

File tree

app/result/[id]/page.tsx

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function Page() {
3333
}
3434

3535
return midpointData.data.map((midpoint, index) => {
36-
const { endStation, endStationLine, userRoutes } = midpoint;
36+
const { endStation, endStationLine, userRoutes, hot } = midpoint;
3737

3838
const routesWithColor = userRoutes.map((route) => {
3939
return {
@@ -107,18 +107,52 @@ export default function Page() {
107107
transferPath: myRoute?.transferPath || [],
108108
transferPathLines,
109109
userRoutes: routesWithColor,
110+
hot,
110111
};
111112
});
112113
}, [midpointData, myNickname, id]);
113114

114115
// 카테고리 텍스트 생성 함수
115-
const getCategoryText = (category: string | undefined): string => {
116-
if (!category) return '밍글링 추천 1위';
116+
const getCategoryText = (
117+
category: string | undefined,
118+
hot: boolean | undefined,
119+
rank: number,
120+
): string => {
121+
const purposeText = '[모임 목적]';
122+
const lastChar = purposeText.charCodeAt(purposeText.length - 1);
123+
const hasJongseong = (lastChar - 0xac00) % 28 !== 0;
124+
const purposeTextWithPostfix = `${purposeText}${hasJongseong ? '이' : '가'} 많은 장소`;
125+
126+
127+
if (hot === true && rank === 1) {
128+
return `밍글링 추천 1위 · ${purposeTextWithPostfix}`;
129+
}
130+
131+
132+
else if (hot === true && rank === 2) {
133+
return `밍글링 추천 2위 · ${purposeTextWithPostfix}`;
134+
}
135+
136+
137+
else if (hot === true) {
138+
return purposeTextWithPostfix;
139+
}
140+
141+
142+
else if (rank === 1) {
143+
return '밍글링 추천 1위';
144+
}
145+
146+
else if (rank === 2) {
147+
return '밍글링 추천 2위';
148+
}
149+
150+
else if (!category) return '밍글링 추천 1위';
117151

118152
// 카테고리 종성에 따라 "이/가"를 다르게 렌더링
119-
const lastChar = category.charCodeAt(category.length - 1);
120-
const hasJongseong = (lastChar - 0xac00) % 28 !== 0;
121-
return `${category}${hasJongseong ? '이' : '가'} 많은 장소`;
153+
const categoryLastChar = category.charCodeAt(category.length - 1);
154+
const categoryHasJongseong = (categoryLastChar - 0xac00) % 28 !== 0;
155+
return `${category}${categoryHasJongseong ? '이' : '가'} 많은 장소`;
122156
};
123157

124158
const [selectedResultId, setSelectedResultId] = useState<number>(1);
@@ -151,7 +185,7 @@ export default function Page() {
151185
<>
152186
<section className="border-gray-1 flex w-full flex-col gap-5 bg-white md:w-77.5 md:gap-3">
153187
<div className="px-5 pt-5 md:p-0">
154-
<div className="flex items-center justify-between">
188+
<div className="flex items-center gap-3">
155189
<button
156190
onClick={handleModifyStart}
157191
className="flex items-center justify-center"
@@ -162,14 +196,7 @@ export default function Page() {
162196
<div className="text-gray-9 text-[22px] font-semibold tracking-[-1.94%]">
163197
최종 위치 결과 Top3
164198
</div>
165-
<button
166-
className="text-blue-5 bg-blue-1 hover:bg-blue-2 flex h-7 cursor-pointer items-center gap-1 rounded px-2.5 text-[11px] font-semibold transition-colors"
167-
type="button"
168-
onClick={(e) => openModal('SHARE', { meetingId: id }, e)}
169-
>
170-
<Image src="/icon/share.svg" alt="공유 아이콘" width={12} height={12} />
171-
결과 공유하기
172-
</button>
199+
173200
</div>
174201
</div>
175202

@@ -207,7 +234,7 @@ export default function Page() {
207234
locationResults.map((result) => {
208235
const category =
209236
meetingData?.data?.purposes?.[meetingData.data.purposes.length - 1];
210-
const categoryText = getCategoryText(category);
237+
const categoryText = getCategoryText(category, result.hot, result.id);
211238

212239
const handleRecommendClick = (e: React.MouseEvent) => {
213240
e.stopPropagation();
@@ -309,12 +336,13 @@ export default function Page() {
309336
)}
310337
</div>
311338
</div>
312-
339+
313340
<button
314-
onClick={handleModifyStart}
315-
className="bg-blue-5 hover:bg-blue-8 absolute right-5 bottom-0 left-5 h-12 rounded text-lg font-semibold text-white transition-transform active:scale-[0.98] md:right-0 md:left-0"
341+
onClick={(e) => openModal('SHARE', { meetingId: id }, e)}
342+
className="flex items-center justify-center gap-2.5 bg-blue-5 hover:bg-blue-8 absolute right-5 bottom-0 left-5 h-12 rounded text-lg font-semibold text-white transition-transform active:scale-[0.98] md:right-0 md:left-0"
316343
>
317-
내 출발지 수정하기
344+
<Image src="/icon/share-white.svg" alt="공유 아이콘" width={20} height={20} />
345+
결과 공유하기
318346
</button>
319347
</div>
320348
</section>

components/modal/transferModal.tsx

Lines changed: 52 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -116,43 +116,6 @@ export default function TransferModal({
116116
}
117117
};
118118

119-
// stations 배열에서 호선별 경로 추출 함수
120-
const extractRouteSteps = (route: UserRoute) => {
121-
const steps: Array<{ linenumber: string; station: string; isLast: boolean }> = [];
122-
123-
if (!route.stations || route.stations.length === 0) {
124-
return steps;
125-
}
126-
127-
let currentLine = route.stations[0]?.linenumber || '';
128-
129-
route.stations.forEach((station, index) => {
130-
if (station.linenumber !== currentLine || index === route.stations.length - 1) {
131-
if (currentLine) {
132-
steps.push({
133-
linenumber: currentLine,
134-
station: station.station,
135-
isLast: index === route.stations.length - 1,
136-
});
137-
}
138-
currentLine = station.linenumber;
139-
}
140-
});
141-
142-
if (route.stations.length > 0) {
143-
const lastStation = route.stations[route.stations.length - 1];
144-
if (steps.length === 0 || steps[steps.length - 1].station !== lastStation.station) {
145-
steps.push({
146-
linenumber: lastStation.linenumber,
147-
station: lastStation.station,
148-
isLast: true,
149-
});
150-
}
151-
}
152-
153-
return steps;
154-
};
155-
156119
return (
157120
<Dialog open={isOpen} onOpenChange={(open) => !open && onClose()}>
158121
<DialogContent
@@ -176,8 +139,6 @@ export default function TransferModal({
176139
</div>
177140
) : (
178141
userRoutes.map((route, index) => {
179-
const routeSteps = extractRouteSteps(route);
180-
181142
return (
182143
<div
183144
key={index}
@@ -200,34 +161,68 @@ export default function TransferModal({
200161
{/* 하단: 환승 경로 (세로 배치) */}
201162
<div className="relative flex gap-4 p-5">
202163
<div className="flex flex-col items-center gap-[10px]">
203-
{routeSteps.map((step, idx) => (
204-
<div key={idx} className="flex flex-col items-center gap-[10px]">
205-
<div
206-
className={`flex min-w-[60px] items-center justify-center gap-1 rounded-[5px] px-[7px] py-[2px] text-[13px] leading-[1.385] font-normal tracking-[0.252px] text-white ${getLineBadgeStyle(
207-
step.linenumber
208-
)}`}
209-
>
210-
<Image src="/icon/train.svg" alt="train" width={12} height={12} />
211-
<span>{step.linenumber}</span>
212-
</div>
164+
165+
<div className="flex flex-col items-center gap-[10px]">
166+
<div
167+
className={`flex min-w-[60px] items-center justify-center gap-1 rounded-[5px] px-[7px] py-[2px] text-[13px] leading-[1.385] font-normal tracking-[0.252px] text-white ${getLineBadgeStyle(
168+
route.startStationLine
169+
)}`}
170+
>
171+
<Image src="/icon/train.svg" alt="train" width={12} height={12} />
172+
<span>{route.startStationLine}</span>
173+
</div>
213174

175+
{route.transferPath && route.transferPath.length > 0 && (
214176
<div className="flex items-center justify-center">
215177
<Image src="/icon/down.svg" alt="arrow-down" width={12} height={12} />
216178
</div>
217-
</div>
218-
))}
179+
)}
180+
</div>
219181

220-
<div className="bg-gray-8 flex min-w-[60px] items-center justify-center rounded-[5px] px-[7px] py-[2px] text-[13px] leading-[1.385] font-normal tracking-[0.252px] text-white">
221-
하차
182+
183+
{route.transferPath &&
184+
route.transferPath.map((transfer, idx) => (
185+
<div key={idx} className="flex flex-col items-center gap-[10px]">
186+
<div
187+
className={`flex min-w-[60px] items-center justify-center gap-1 rounded-[5px] px-[7px] py-[2px] text-[13px] leading-[1.385] font-normal tracking-[0.252px] text-white ${getLineBadgeStyle(
188+
transfer.linenumber
189+
)}`}
190+
>
191+
<Image src="/icon/train.svg" alt="train" width={12} height={12} />
192+
<span>{transfer.linenumber}</span>
193+
</div>
194+
195+
{idx < route.transferPath.length - 1 && (
196+
<div className="flex items-center justify-center">
197+
<Image src="/icon/down.svg" alt="arrow-down" width={12} height={12} />
198+
</div>
199+
)}
200+
</div>
201+
))}
202+
203+
204+
<div className="flex flex-col items-center gap-[10px]">
205+
<div className="flex items-center justify-center">
206+
<Image src="/icon/down.svg" alt="arrow-down" width={12} height={12} />
207+
</div>
208+
<div className="bg-gray-8 flex min-w-[60px] items-center justify-center rounded-[5px] px-[7px] py-[2px] text-[13px] leading-[1.385] font-normal tracking-[0.252px] text-white">
209+
하차
210+
</div>
222211
</div>
223212
</div>
224213

225214
<div className="text-gray-8 flex flex-col gap-[30px] text-[13px] leading-[1.385] font-normal tracking-[0.252px]">
226-
{routeSteps.map((step, idx) => (
227-
<span key={idx}>{step.station}</span>
228-
))}
215+
216+
<span>{route.startStation}</span>
217+
218+
219+
{route.transferPath &&
220+
route.transferPath.map((transfer, idx) => (
221+
<span key={idx}>{transfer.station}</span>
222+
))}
229223

230-
<span>{endStation || routeSteps[routeSteps.length - 1]?.station}</span>
224+
{/* 종료역 */}
225+
<span>{endStation}</span>
231226
</div>
232227
</div>
233228
</div>

public/icon/share-white.svg

Lines changed: 3 additions & 0 deletions
Loading

types/api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ export type MeetingStatusResponse = ApiResponse<MeetingStatusData>;
7070
export interface MidpointData {
7171
endStation: string;
7272
endStationLine: string;
73+
hot: boolean;
7374
latitude: number;
7475
longitude: number;
7576
userRoutes: {

0 commit comments

Comments
 (0)