Skip to content

Commit 4bf5c9c

Browse files
authored
[UNI-190] feat : 건물 리스트 API 적용 및 Default 도착지 제거 (#103)
1 parent b80ad9c commit 4bf5c9c

File tree

3 files changed

+25
-30
lines changed

3 files changed

+25
-30
lines changed

uniro_frontend/src/api/route.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,5 @@ export const postReportRoute = (
5454
coordinates: Coord[];
5555
},
5656
): Promise<boolean> => {
57-
return postFetch<void, Coord[] | NodeId | null>(`/${univId}/route`, body);
57+
return postFetch<void, Coord[] | NodeId | null>(`/1/route`, body);
5858
};

uniro_frontend/src/hooks/useRoutePoint.ts

+4-25
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,10 @@
11
import { create } from "zustand";
22
import { Building } from "../data/types/node";
33

4-
const originMockInfo = {
5-
buildingName: "5호관",
6-
buildingImageUrl: "",
7-
phoneNumber: "",
8-
address: "인하로 100",
9-
nodeId: 1,
10-
lng: 127.042012,
11-
lat: 37.557643,
12-
};
13-
14-
const destMockInfo = {
15-
buildingName: "하이테크",
16-
buildingImageUrl: "",
17-
phoneNumber: "",
18-
address: "인하로 100",
19-
nodeId: 2,
20-
lng: 127.042012,
21-
lat: 37.557643,
22-
};
23-
244
interface RouteStore {
25-
origin: Building;
5+
origin: Building | undefined;
266
setOrigin: (origin: Building | undefined) => void;
27-
destination: Building;
28-
setDemoBuildingInfo: (building: Building) => void;
7+
destination: Building | undefined;
298
setDestination: (destination: Building | undefined) => void;
309
setOriginCoord: (lng: number, lat: number) => void;
3110
setDestinationCoord: (lng: number, lat: number) => void;
@@ -34,9 +13,9 @@ interface RouteStore {
3413

3514
/** 출발지, 도착지 관리 전역 상태 */
3615
const useRoutePoint = create<RouteStore>((set) => ({
37-
origin: originMockInfo,
16+
origin: undefined,
3817
setOrigin: (newOrigin: Building | undefined) => set(() => ({ origin: newOrigin })),
39-
destination: destMockInfo,
18+
destination: undefined,
4019
setDemoBuildingInfo: (building: Building) => set(() => ({ origin: building, destination: building })),
4120
setOriginCoord: (lng: number, lat: number) => set(({ origin }) => ({ origin: { ...origin, lng, lat } })),
4221
setDestinationCoord: (lng: number, lat: number) =>

uniro_frontend/src/pages/buildingSearch.tsx

+20-4
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,37 @@ import BuildingCard from "../components/building/buildingCard";
44
import useSearchBuilding from "../hooks/useSearchBuilding";
55
import useUniversityInfo from "../hooks/useUniversityInfo";
66
import useRedirectUndefined from "../hooks/useRedirectUndefined";
7+
import { useQuery } from "@tanstack/react-query";
8+
import { getAllBuildings } from "../api/nodes";
9+
import { University } from "../data/types/university";
710

811
export default function BuildingSearchPage() {
12+
const { university } = useUniversityInfo();
913
const { setBuilding } = useSearchBuilding();
1014

11-
const { university } = useUniversityInfo();
12-
useRedirectUndefined<string | undefined>([university]);
15+
if (!university) return;
16+
17+
const { data: buildings } = useQuery({
18+
queryKey: [university.id, "buildings"],
19+
queryFn: () =>
20+
getAllBuildings(university.id, {
21+
leftUpLat: 38,
22+
leftUpLng: 127,
23+
rightDownLat: 37,
24+
rightDownLng: 128,
25+
}),
26+
},)
27+
28+
useRedirectUndefined<University | undefined>([university]);
1329

1430
return (
1531
<div className="relative flex flex-col h-dvh w-full max-w-[450px] mx-auto justify-center">
1632
<div className="px-[14px] py-4 border-b-[1px] border-gray-400">
17-
<Input onLengthChange={() => {}} handleVoiceInput={() => {}} placeholder="" />
33+
<Input onLengthChange={() => { }} handleVoiceInput={() => { }} placeholder="" />
1834
</div>
1935
<div className="flex-1 overflow-y-scroll">
2036
<ul className="px-4 pt-1 space-y-1">
21-
{hanyangBuildings.map((building) => (
37+
{(buildings ?? []).map((building) => (
2238
<BuildingCard
2339
onClick={() => setBuilding(building)}
2440
key={`building-${building.buildingName}`}

0 commit comments

Comments
 (0)