@@ -4,21 +4,37 @@ import BuildingCard from "../components/building/buildingCard";
4
4
import useSearchBuilding from "../hooks/useSearchBuilding" ;
5
5
import useUniversityInfo from "../hooks/useUniversityInfo" ;
6
6
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" ;
7
10
8
11
export default function BuildingSearchPage ( ) {
12
+ const { university } = useUniversityInfo ( ) ;
9
13
const { setBuilding } = useSearchBuilding ( ) ;
10
14
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 ] ) ;
13
29
14
30
return (
15
31
< div className = "relative flex flex-col h-dvh w-full max-w-[450px] mx-auto justify-center" >
16
32
< div className = "px-[14px] py-4 border-b-[1px] border-gray-400" >
17
- < Input onLengthChange = { ( ) => { } } handleVoiceInput = { ( ) => { } } placeholder = "" />
33
+ < Input onLengthChange = { ( ) => { } } handleVoiceInput = { ( ) => { } } placeholder = "" />
18
34
</ div >
19
35
< div className = "flex-1 overflow-y-scroll" >
20
36
< ul className = "px-4 pt-1 space-y-1" >
21
- { hanyangBuildings . map ( ( building ) => (
37
+ { ( buildings ?? [ ] ) . map ( ( building ) => (
22
38
< BuildingCard
23
39
onClick = { ( ) => setBuilding ( building ) }
24
40
key = { `building-${ building . buildingName } ` }
0 commit comments