@@ -28,10 +28,12 @@ function RoutePage() {
28
28
const [ destinationDistance , setDestinationDistance ] = useState ( null ) ;
29
29
const [ destinationIndex , setDestinationIndex ] = useState ( 0 ) ;
30
30
const [ nextUnlockableId , setNextUnlockableId ] = useState ( null ) ;
31
+ const [ routeComplete , setRouteComplete ] = useState ( false ) ;
31
32
const [ source , setSource ] = useState ( null ) ;
32
33
const { userLatitude, userLongitude } = useContext ( LatLongContext ) ;
33
34
const { geolocationAvailable } = useContext ( PermissionContext ) ;
34
35
const audioRef = useRef ( ) ;
36
+ const { fileUrl } = useContext ( ApiEndpointContext ) ;
35
37
const isIOS =
36
38
navigator . userAgent . match ( / ( i P o d | i P h o n e | i P a d ) / ) &&
37
39
navigator . userAgent . match ( / A p p l e W e b K i t / ) ;
@@ -137,6 +139,9 @@ function RoutePage() {
137
139
const destinationChanged = ( ) => {
138
140
if ( pointsOfInterest ) {
139
141
const destinationPoint = getRelevantDestinationPoint ( pointsOfInterest ) ;
142
+ if ( destinationPoint . length === 0 ) {
143
+ return setRouteComplete ( true ) ;
144
+ }
140
145
const index = pointsOfInterest . findIndex (
141
146
( poi ) => destinationPoint [ 0 ] . id === poi . id
142
147
) ;
@@ -145,17 +150,17 @@ function RoutePage() {
145
150
setDestinationLatitude ( destinationPoint [ 0 ] . latitude ) ;
146
151
setDestinationLongitude ( destinationPoint [ 0 ] . longitude ) ;
147
152
}
153
+ return false ;
148
154
} ;
149
155
useEffect ( ( ) => {
150
156
destinationChanged ( ) ;
151
157
} , [ pointsOfInterest ] ) ;
152
158
153
159
if ( selectedRoute === null ) return null ;
154
160
155
- const { fileUrl } = useContext ( ApiEndpointContext ) ;
156
161
157
162
return (
158
- < div className = "flex flex-col place-items-start pb-28 " >
163
+ < div className = "flex flex-col place-items-start pb-36 " >
159
164
< BackButton > Afslut</ BackButton >
160
165
< h1 className = "text-xl font-bold my-3" > { selectedRoute . name } </ h1 >
161
166
< div className = "relative w-full rounded-lg flex flex-col-reverse gap-1" >
@@ -171,49 +176,50 @@ function RoutePage() {
171
176
/>
172
177
) ) }
173
178
</ div >
174
- { /* TODO: Make room for audio player below when playing */ }
175
179
< div className = "fixed flex flex-col left-3 bottom-3 right-3 bg-zinc-200 dark:bg-zinc-700 gap-3 rounded-lg p-3 pb-15 divide-x dark:divide-zinc-200/5" >
176
- < div className = "flex flex-row justify-between" >
177
- < div >
178
- < div className = "text-sm text-bold" >
179
- Afstand til del
180
- < span className = "ml-1 px-2 font-bold rounded-full bg-emerald-700 text-zinc-100 text-sm" >
181
- { destinationIndex + 1 }
182
- </ span >
183
- </ div >
184
- < div className = "" >
185
- { destinationDistance && `${ destinationDistance } meter` }
180
+ { routeComplete && < h3 > You completed the route. Congratulations!</ h3 > }
181
+ { ! routeComplete && (
182
+ < div className = "flex flex-row justify-between" >
183
+ < div >
184
+ < div className = "text-sm text-bold" >
185
+ Afstand til del
186
+ < span className = "ml-1 px-2 font-bold rounded-full bg-emerald-700 text-zinc-100 text-sm" >
187
+ { destinationIndex + 1 }
188
+ </ span >
189
+ </ div >
190
+ < div className = "" >
191
+ { destinationDistance && `${ destinationDistance } meter` }
192
+ </ div >
186
193
</ div >
187
- </ div >
188
- < div className = "pl-3" >
189
- { /* TODO: Make this check for compass */ }
190
- { ( ! orientation || ! angle ) && (
191
- < button
192
- className = "bg-zinc-700 dark:bg-zinc-200 dark:text-zinc-800 rounded text-sm py-1 px-3"
193
- type = "button"
194
- onClick = { ( ) => startWaypointer ( ) }
195
- >
196
- Vis mig vej
197
- </ button >
198
- ) }
199
- { /* TODO: Make this check for compass */ }
200
- { orientation && angle && (
201
- < div >
202
- < div className = "flex justify-between" >
203
- < span className = "text-sm text-bold mr-5" > Retning</ span >
204
- < span className = "w-1/2" >
205
- < LocationArrow
206
- className = "inline w-5"
207
- style = { {
208
- transform : `rotate(${ - rotation } deg)` ,
209
- } }
210
- />
211
- </ span >
194
+ < div className = "pl-3" >
195
+ { ( ! orientation || ! angle ) && (
196
+ < button
197
+ className = "bg-zinc-700 dark:bg-zinc-200 dark:text-zinc-800 rounded text-sm py-1 px-3"
198
+ type = "button"
199
+ onClick = { ( ) => startWaypointer ( ) }
200
+ >
201
+ Vis mig vej
202
+ </ button >
203
+ ) }
204
+ { orientation && angle && (
205
+ < div >
206
+ < div className = "flex justify-between" >
207
+ < span className = "text-sm text-bold mr-5" > Retning</ span >
208
+ < span className = "w-1/2" >
209
+ < LocationArrow
210
+ className = "inline w-5"
211
+ style = { {
212
+ transform : `rotate(${ - rotation } deg)` ,
213
+ } }
214
+ />
215
+ </ span >
216
+ </ div >
212
217
</ div >
213
- </ div >
214
- ) }
218
+ ) }
219
+ </ div >
215
220
</ div >
216
- </ div >
221
+ ) }
222
+
217
223
< div >
218
224
< audio
219
225
className = "w-full"
0 commit comments