1
1
import { React , useEffect , useState , useContext } from "react" ;
2
2
import { Link , useParams } from "react-router-dom" ;
3
- import { faPlayCircle } from "@fortawesome/free-solid-svg-icons" ;
4
- import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
5
- import useFetch from "../../util/useFetch" ;
3
+ import PermissionContext from "../../context/permission-context" ;
6
4
import RouteContext from "../../context/RouteContext" ;
5
+ import useFetch from "../../util/useFetch" ;
7
6
import MapWrapper from "../map/MapWrapper" ;
8
7
import TagList from "../tags/TagList" ;
8
+ import { FontAwesomeIcon } from "@fortawesome/react-fontawesome" ;
9
+ import { faPlayCircle } from "@fortawesome/free-solid-svg-icons" ;
9
10
10
11
function RoutePage ( ) {
11
12
const { id } = useParams ( ) ;
13
+ const { openStreetMapConsent, setOpenStreetMapConsent } = useContext ( PermissionContext ) ;
12
14
const { selectedRoute, setSelectedRoute, setListOfUnlocked } = useContext ( RouteContext ) ;
13
15
const [ dataFetched , setDataFetched ] = useState ( false ) ;
16
+ const [ focusOnText , setFocusOnText ] = useState ( false ) ;
14
17
function isRouteAlreadySet ( ) {
15
18
return selectedRoute === null && dataFetched ;
16
19
}
@@ -35,7 +38,14 @@ function RoutePage() {
35
38
36
39
if ( selectedRoute === null ) return null ;
37
40
41
+ function resetPermission ( ) {
42
+ setFocusOnText ( false ) ;
43
+ setOpenStreetMapConsent ( null ) ;
44
+ }
45
+
38
46
const { title, tags, points, totalDuration, distance, description } = selectedRoute ;
47
+ const consentText =
48
+ "Du har ikke givet samtykke, derfor kan vi ikke vise et kort her. Vil du ændre det, kan du trykke her." ;
39
49
40
50
return (
41
51
< >
@@ -46,7 +56,19 @@ function RoutePage() {
46
56
< h1 className = "text-4xl font-extrabold z-50 relative word-break" > { title } </ h1 >
47
57
</ div >
48
58
< div className = "flex flex-col items-end" >
49
- < div className = "w-3/5 mb-10 text-end" > Tryk på kortet for at undersøge ruten</ div >
59
+ { openStreetMapConsent && < div className = "w-3/5 mb-10 text-end" > Tryk på kortet for at undersøge ruten</ div > }
60
+
61
+ { ! openStreetMapConsent && ! focusOnText && (
62
+ < button type = "button" onClick = { ( ) => setFocusOnText ( true ) } className = "opacity-35 mb-10 text-center" >
63
+ { consentText }
64
+ </ button >
65
+ ) }
66
+ { ! openStreetMapConsent && focusOnText && (
67
+ < button type = "button" onClick = { ( ) => resetPermission ( ) } className = "mb-10 text-center" >
68
+ { consentText }
69
+ </ button >
70
+ ) }
71
+
50
72
< div className = "bg-emerald-400 w-full dark:bg-emerald-800 mb-3 rounded-md p-3 flex z-50 relative" >
51
73
< div >
52
74
< div className = "font-bold" > Distance</ div >
0 commit comments