Skip to content

Commit 55801f0

Browse files
dgfh0450jpark0506
andauthored
[UNI-108] feat : 페이지간 라우터 연결 및 뒤로가기 공통 컴포넌트 생성 (#43)
* [UNI-108] feat : 학교 검색 페이지 -> 지도 메인 페이지 라우터 연결 * [UNI-108] feat : 지도 메인 페이지 -> 경로 검색 결과 페이지 라우터 연결 * [UNI-108] feat : 지도 메인 페이지 -> 제보 (불편한 길, 새로운 길) 모달 생성 및 라우터 연결 * [UNI-108] feat : 새로운 길 제보 페이지 상단 안내 문구 추가 (추후 변경 로직 추가 필요) * [UNI-108] feat : 공통 뒤로가기 버튼 컴포넌트 생성 * [UNI-108] feat : 뒤로가기 버튼 제보하기 페이지 & 경로 결과 페이지 적용 --------- Co-authored-by: Junhyeok Park(박준혁) <[email protected]>
1 parent 6c4a3df commit 55801f0

File tree

8 files changed

+87
-14
lines changed

8 files changed

+87
-14
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { useNavigate } from "react-router";
2+
import ChevronLeft from "../../../public/icons/chevron-left.svg?react";
3+
4+
interface BackButtonProps {
5+
className?: string;
6+
onClick?: () => void
7+
}
8+
9+
export default function BackButton({ className = "", onClick }: BackButtonProps) {
10+
const navigate = useNavigate();
11+
12+
const handleBack = () => {
13+
navigate(-1);
14+
}
15+
16+
return (
17+
<button className={`w-[52px] h-[52px] flex items-center justify-center border border-gray-400 rounded-full bg-gray-100 active:bg-gray-200 ${className}`} onClick={onClick ?? handleBack}>
18+
<ChevronLeft width={35} height={35} />
19+
</button>
20+
)
21+
}
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { Link } from "react-router";
21
import ReportIcon from "../../assets/report.svg?react";
2+
import { ButtonHTMLAttributes } from "react";
33

4-
export default function ReportButton() {
4+
export default function ReportButton({ ...rest }: ButtonHTMLAttributes<HTMLButtonElement>) {
55
return (
6-
<Link
7-
to="/"
6+
<button
7+
{...rest}
88
className="rounded-full w-fit h-[50px] px-6 py-3 flex flex-row items-center bg-gray-900 text-gray-100"
99
>
1010
제보하기
1111
<ReportIcon className="ml-3" stroke="#FFFFFF" />
12-
</Link>
12+
</button>
1313
);
1414
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { Link } from "react-router";
2+
import ChevronRight from "../../../public/icons/chevron-right.svg?react";
3+
4+
interface ReportModalProps {
5+
close: () => void;
6+
}
7+
8+
export default function ReportModal({ close }: ReportModalProps) {
9+
return (
10+
<div
11+
className="fixed inset-0 flex flex-col items-center justify-end bg-[rgba(0,0,0,0.2)] z-20 py-6 px-4 space-y-[10px]"
12+
onClick={close}
13+
>
14+
<Link
15+
to={"/report/route"}
16+
className="w-full h-[58px] flex items-center justify-between px-5 bg-gray-100 rounded-400 text-kor-body2 font-semibold text-primary-500"
17+
>
18+
<p>새로운 길 제보</p>
19+
<ChevronRight fill="none" />
20+
</Link>
21+
22+
<Link
23+
to={"/report/hazard"}
24+
className="w-full h-[58px] flex items-center justify-between px-5 bg-gray-100 rounded-400 text-kor-body2 font-semibold text-primary-500"
25+
>
26+
<p>불편한 길 제보</p>
27+
<ChevronRight fill="none" />
28+
</Link>
29+
</div>
30+
);
31+
}

uniro_frontend/src/pages/map.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,15 @@ import { RoutePoint } from "../constant/enum/routeEnum";
1919
import { Markers } from "../constant/enum/markerEnum";
2020
import createAdvancedMarker from "../utils/markers/createAdvanedMarker";
2121
import toggleMarkers from "../utils/markers/toggleMarkers";
22+
23+
import { Link } from "react-router";
24+
import useModal from "../hooks/useModal";
25+
import ReportModal from "../components/map/reportModal";
26+
2227
import useUniversityInfo from "../hooks/useUniversityInfo";
2328
import useRedirectUndefined from "../hooks/useRedirectUndefined";
2429

30+
2531
export type SelectedMarkerTypes = {
2632
type: MarkerTypes;
2733
element: AdvancedMarker;
@@ -45,6 +51,8 @@ export default function MapPage() {
4551
const { origin, setOrigin, destination, setDestination } = useRoutePoint();
4652
const { mode, building: selectedBuilding } = useSearchBuilding();
4753

54+
const [_, isOpen, open, close] = useModal();
55+
4856
const { university } = useUniversityInfo();
4957
useRedirectUndefined<string | undefined>([university]);
5058

@@ -298,21 +306,22 @@ export default function MapPage() {
298306
</BottomSheet>
299307
{origin && destination && origin.id !== destination.id ? (
300308
/** 출발지랑 도착지가 존재하는 경우 길찾기 버튼 보이기 */
301-
<div className="absolute bottom-6 space-y-2 w-full px-4">
309+
<Link to="/result" className="absolute bottom-6 space-y-2 w-full px-4">
302310
<Button variant="primary">길찾기</Button>
303-
</div>
311+
</Link>
304312
) : (
305313
/** 출발지랑 도착지가 존재하지 않거나, 같은 경우 기존 Button UI 보이기 */
306314
<>
307315
<div className="absolute right-4 bottom-6 space-y-2">
308-
<ReportButton />
316+
<ReportButton onClick={open} />
309317
</div>
310318
<div className="absolute right-4 bottom-[90px] space-y-2">
311319
<CautionToggleButton isActive={isCautionAcitve} onClick={toggleCautionButton} />
312320
<DangerToggleButton isActive={isDangerAcitve} onClick={toggleDangerButton} />
313321
</div>
314322
</>
315323
)}
324+
{isOpen && <ReportModal close={close} />}
316325
</div>
317326
);
318327
}

uniro_frontend/src/pages/navigationResult.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ import NavigationMap from "../component/NavgationMap";
1212
import NavigationDescription from "../components/navigation/navigationDescription";
1313
import BottomSheetHandle from "../components/navigation/bottomSheet/bottomSheetHandle";
1414

15-
import useLoading from "../hooks/useLoading";
1615
import Loading from "../components/loading/loading";
16+
import BackButton from "../components/map/backButton";
17+
18+
import useLoading from "../hooks/useLoading";
1719
import useUniversityInfo from "../hooks/useUniversityInfo";
1820
import useRedirectUndefined from "../hooks/useRedirectUndefined";
1921

@@ -107,9 +109,7 @@ const NavigationResultPage = () => {
107109
positionDelta={60}
108110
isTop={true}
109111
>
110-
<button onClick={hideDetailView}>
111-
<GoBack />
112-
</button>
112+
<BackButton onClick={hideDetailView} />
113113
</AnimatedContainer>
114114

115115
<AnimatedContainer

uniro_frontend/src/pages/reportHazard.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ import { ReportHazardMessage } from "../constant/enum/messageEnum";
1818
import { motion } from "framer-motion";
1919
import useReportHazard from "../hooks/useReportHazard";
2020
import AnimatedContainer from "../container/animatedContainer";
21+
22+
import BackButton from "../components/map/backButton";
23+
2124
import useUniversityInfo from "../hooks/useUniversityInfo";
2225
import useRedirectUndefined from "../hooks/useRedirectUndefined";
2326

@@ -196,6 +199,7 @@ export default function ReportHazardPage() {
196199
{message}
197200
</motion.p>
198201
</div>
202+
<BackButton className="absolute top-[73px] left-4 z-5" />
199203
<div ref={mapRef} className="w-full h-full" />
200204
<AnimatedContainer
201205
isVisible={reportMarker ? true : false}

uniro_frontend/src/pages/reportRoute.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Button from "../components/customButton";
1414
import { CautionToggleButton, DangerToggleButton } from "../components/map/floatingButtons";
1515
import { mockHazardEdges } from "../data/mock/hanyangHazardEdge";
1616
import toggleMarkers from "../utils/markers/toggleMarkers";
17+
import BackButton from "../components/map/backButton";
1718
import useUniversityInfo from "../hooks/useUniversityInfo";
1819
import useRedirectUndefined from "../hooks/useRedirectUndefined";
1920

@@ -256,6 +257,12 @@ export default function ReportRoutePage() {
256257

257258
return (
258259
<div className="relative w-full h-dvh">
260+
<div className="w-full h-[57px] flex items-center justify-center absolute top-0 bg-black opacity-50 z-10 py-3 px-4">
261+
<p className="text-gray-100 text-kor-body2 font-medium text-center">
262+
선 위 또는 기존 지점을 선택하세요
263+
</p>
264+
</div>
265+
<BackButton className="absolute top-[73px] left-4 z-5" />
259266
<div ref={mapRef} className="w-full h-full" />
260267
{isActive && (
261268
<div className="absolute w-full bottom-6 px-4">

uniro_frontend/src/pages/universitySearch.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function UniversitySearchPage() {
1313
return (
1414
<div className="relative flex flex-col h-screen w-full max-w-[450px] mx-auto py-5">
1515
<div className="w-full px-[14px] pb-[17px] border-b-[1px] border-gray-400">
16-
<Input onLengthChange={() => {}} placeholder="우리 학교를 검색해보세요" handleVoiceInput={() => {}} />
16+
<Input onLengthChange={() => { }} placeholder="우리 학교를 검색해보세요" handleVoiceInput={() => { }} />
1717
</div>
1818
<div className="overflow-y-scroll flex-1">
1919
<ul
@@ -24,6 +24,7 @@ export default function UniversitySearchPage() {
2424
>
2525
{UniversityList.map(({ name, img }) => (
2626
<UniversityButton
27+
key={name}
2728
selected={selectedUniv === name}
2829
onClick={() => {
2930
setSelectedUniv(name);
@@ -36,7 +37,7 @@ export default function UniversitySearchPage() {
3637
</div>
3738
<div className="px-[14px]">
3839
{selectedUniv !== "" && (
39-
<Link to="/" onClick={() => setUniversity(selectedUniv)}>
40+
<Link to="/map" onClick={() => setUniversity(selectedUniv)}>
4041
<Button variant="primary">다음</Button>
4142
</Link>
4243
)}

0 commit comments

Comments
 (0)