@@ -13,10 +13,9 @@ import { useTranslation } from 'react-i18next'
1313import { useMemory } from '@store/useMemory'
1414import { useLayoutStore } from '@store/useLayoutStore'
1515import { setDeepStore } from '@store/useStorage'
16- import { NestSubmission } from '@components/dialogs/NestSubmission'
1716import { getTimeUntil } from '@utils/getTimeUntil'
1817import { useAnalytics } from '@hooks/useAnalytics'
19- import { Popup } from 'react-leaflet '
18+ import { Navigation } from '@components/popups/Navigation '
2019
2120/** @param {number } timeSince */
2221const getColor = ( timeSince ) => {
@@ -52,7 +51,7 @@ export function NestPopup({
5251 lon,
5352} ) {
5453 const { t } = useTranslation ( )
55- const { perms } = useMemory ( ( s ) => s . auth )
54+ const submissionPerm = useMemory ( ( s ) => s . auth . perms . nestSubmissions )
5655
5756 const [ parkName , setParkName ] = React . useState ( true )
5857 const [ anchorEl , setAnchorEl ] = React . useState ( null )
@@ -80,121 +79,129 @@ export function NestPopup({
8079 ]
8180
8281 return (
83- < Popup position = { [ lat , lon ] } >
84- < Grid
85- container
86- justifyContent = "center"
87- alignItems = "center"
88- style = { { width : 200 } }
89- spacing = { 1 }
90- >
91- < Grid xs = { pokemon_id ? 9 : 12 } textAlign = "center" >
82+ < Grid
83+ container
84+ justifyContent = "center"
85+ alignItems = "center"
86+ style = { { width : 200 } }
87+ spacing = { 1 }
88+ >
89+ < Grid xs = { pokemon_id ? 9 : 12 } textAlign = "center" >
90+ < Typography
91+ variant = { name . length > 20 ? 'subtitle2' : 'h6' }
92+ align = "center"
93+ noWrap = { parkName }
94+ onClick = { ( ) => setParkName ( ! parkName ) }
95+ >
96+ { name }
97+ </ Typography >
98+ { submitted_by && (
9299 < Typography
93- variant = { name . length > 20 ? 'subtitle2' : 'h6' }
94- align = "center"
100+ variant = "caption"
101+ fontSize = { 10 }
95102 noWrap = { parkName }
96103 onClick = { ( ) => setParkName ( ! parkName ) }
97104 >
98- { name }
105+ { t ( 'submitted_by' ) } : { submitted_by }
99106 </ Typography >
100- { submitted_by && (
101- < Typography
102- variant = "caption"
103- fontSize = { 10 }
104- noWrap = { parkName }
105- onClick = { ( ) => setParkName ( ! parkName ) }
106- >
107- { t ( 'submitted_by' ) } : { submitted_by }
108- </ Typography >
109- ) }
110- </ Grid >
111- { ! ! pokemon_id && (
112- < Grid xs = { 3 } >
113- < IconButton aria-haspopup = "true" onClick = { handleClick } size = "large" >
114- < MoreVert />
115- </ IconButton >
116- </ Grid >
117107 ) }
118- < Menu
119- anchorEl = { anchorEl }
120- keepMounted
121- open = { ! ! anchorEl }
122- onClose = { handleClose }
123- PaperProps = { {
124- style : {
125- maxHeight : 216 ,
126- minWidth : '20ch' ,
127- } ,
128- } }
108+ </ Grid >
109+ { ! ! pokemon_id && (
110+ < Grid xs = { 3 } >
111+ < IconButton aria-haspopup = "true" onClick = { handleClick } size = "large" >
112+ < MoreVert />
113+ </ IconButton >
114+ </ Grid >
115+ ) }
116+ < Menu
117+ anchorEl = { anchorEl }
118+ keepMounted
119+ open = { ! ! anchorEl }
120+ onClose = { handleClose }
121+ PaperProps = { {
122+ style : {
123+ maxHeight : 216 ,
124+ minWidth : '20ch' ,
125+ } ,
126+ } }
127+ >
128+ { options . map ( ( option ) => (
129+ < MenuItem key = { option . key || option . name } onClick = { option . action } >
130+ { typeof option . name === 'string' ? t ( option . name ) : option . name }
131+ </ MenuItem >
132+ ) ) }
133+ </ Menu >
134+ { ! ! pokemon_id && (
135+ < Grid xs = { 6 } textAlign = "center" >
136+ < img
137+ src = { iconUrl }
138+ alt = { iconUrl }
139+ style = { {
140+ maxHeight : 75 ,
141+ maxWidth : 75 ,
142+ } }
143+ />
144+ < br />
145+ < Typography variant = "caption" > { t ( `poke_${ pokemon_id } ` ) } </ Typography >
146+ </ Grid >
147+ ) }
148+ < Grid xs = { pokemon_id ? 6 : 12 } textAlign = "center" >
149+ < Typography variant = "subtitle2" > { t ( 'last_updated' ) } </ Typography >
150+ < Typography
151+ variant = { lastUpdated . str . includes ( 'D' ) ? 'h6' : 'subtitle2' }
152+ color = { getColor ( lastUpdated . diff ) }
129153 >
130- { options . map ( ( option ) => (
131- < MenuItem key = { option . key || option . name } onClick = { option . action } >
132- { typeof option . name === 'string' ? t ( option . name ) : option . name }
133- </ MenuItem >
134- ) ) }
135- </ Menu >
136- { ! ! pokemon_id && (
137- < Grid xs = { 6 } textAlign = "center" >
138- < img
139- src = { iconUrl }
140- alt = { iconUrl }
141- style = { {
142- maxHeight : 75 ,
143- maxWidth : 75 ,
144- } }
145- />
154+ { lastUpdated . str . replace ( 'days' , t ( 'days' ) ) . replace ( 'day' , t ( 'day' ) ) }
155+ </ Typography >
156+ < Typography variant = "subtitle2" >
157+ ~{ pokemon_avg ?. toFixed ( 2 ) || 0 } { t ( 'spawns_per_hour' ) }
158+ </ Typography >
159+ </ Grid >
160+ < Grid xs = { 12 } >
161+ < Divider style = { { margin : 4 } } />
162+ </ Grid >
163+ < Grid xs = { 12 } textAlign = "center" >
164+ { recent ? (
165+ < Typography variant = "caption" >
166+ { t ( 'nest_estimated' ) }
146167 < br />
147- < Typography variant = "caption" > { t ( `poke_${ pokemon_id } ` ) } </ Typography >
148- </ Grid >
149- ) }
150- < Grid xs = { pokemon_id ? 6 : 12 } textAlign = "center" >
151- < Typography variant = "subtitle2" > { t ( 'last_updated' ) } </ Typography >
152- < Typography
153- variant = { lastUpdated . str . includes ( 'D' ) ? 'h6' : 'subtitle2' }
154- color = { getColor ( lastUpdated . diff ) }
155- >
156- { lastUpdated . str
157- . replace ( 'days' , t ( 'days' ) )
158- . replace ( 'day' , t ( 'day' ) ) }
168+ { t ( 'verify_nests' ) }
159169 </ Typography >
160- < Typography variant = "subtitle2" >
161- ~{ pokemon_avg ?. toFixed ( 2 ) || 0 } { t ( 'spawns_per_hour' ) }
170+ ) : (
171+ < Typography variant = "caption" >
172+ { t ( 'nest_out_of_date' ) }
173+ < br />
174+ { t ( 'nest_check_current' ) }
162175 </ Typography >
163- </ Grid >
164- < Grid xs = { 12 } >
165- < Divider style = { { margin : 4 } } />
166- </ Grid >
167- < Grid xs = { 12 } textAlign = "center" >
168- { recent ? (
169- < Typography variant = "caption" >
170- { t ( 'nest_estimated' ) }
171- < br />
172- { t ( 'verify_nests' ) }
173- </ Typography >
174- ) : (
175- < Typography variant = "caption" >
176- { t ( 'nest_out_of_date' ) }
177- < br />
178- { t ( 'nest_check_current' ) }
179- </ Typography >
180- ) }
181- </ Grid >
182- { perms . nestSubmissions && (
183- < Grid xs = { 12 } textAlign = "center" >
184- < Button
185- color = "secondary"
186- variant = "outlined"
187- size = "small"
188- onClick = { ( ) =>
189- useLayoutStore . setState ( { nestSubmissions : `${ id } ` } )
190- }
191- >
192- { t ( 'submit_nest_name' ) }
193- </ Button >
194- </ Grid >
195176 ) }
196177 </ Grid >
197- < NestSubmission id = { id } name = { name } />
198- </ Popup >
178+ { submissionPerm && (
179+ < Grid xs = { 9 } textAlign = "center" >
180+ < Button
181+ color = "secondary"
182+ variant = "outlined"
183+ size = "small"
184+ onClick = { ( ) =>
185+ useLayoutStore . setState ( {
186+ nestSubmissions : {
187+ id : `${ id } ` ,
188+ name : `${ name } ` ,
189+ } ,
190+ } )
191+ }
192+ >
193+ < Typography variant = "caption" > { t ( 'submit_nest_name' ) } </ Typography >
194+ </ Button >
195+ </ Grid >
196+ ) }
197+ < Grid
198+ xs = { submissionPerm ? 3 : 12 }
199+ container
200+ alignItems = "center"
201+ justifyContent = "center"
202+ >
203+ < Navigation lat = { lat } lon = { lon } />
204+ </ Grid >
205+ </ Grid >
199206 )
200207}
0 commit comments