Skip to content

Commit

Permalink
refactor: account for mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
clintonlunn committed May 19, 2024
1 parent 43b9fc0 commit 66987e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,17 @@ import { DashboardInput } from '@/components/ui/form/Input'
import useUpdateAreasCmd from '@/js/hooks/useUpdateAreasCmd'
import { parseLatLng } from '@/components/crag/cragSummary'
import { CoordinatePickerMap } from '@/components/maps/CoordinatePickerMap'
import { useResponsive } from '@/js/hooks'

export const AreaLatLngForm: React.FC<{ initLat: number, initLng: number, uuid: string, isLeaf: boolean, areaName: string }> = ({ uuid, initLat, initLng, isLeaf, areaName }) => {
const session = useSession({ required: true })
const { updateOneAreaCmd } = useUpdateAreasCmd({
areaId: uuid,
accessToken: session?.data?.accessToken as string
}
)
})
const latlngStr = `${initLat.toString()},${initLng.toString()}`
const [pickerSelected, setPickerSelected] = useState(false)
const { isMobile } = useResponsive()

return (
<SingleEntryForm<{ latlngStr: string }>
Expand All @@ -40,7 +41,6 @@ export const AreaLatLngForm: React.FC<{ initLat: number, initLng: number, uuid:
<DashboardInput
name='latlngStr'
label='Coordinates in latitude, longitude format.'
className='w-80'
registerOptions={AREA_LATLNG_FORM_VALIDATION_RULES}
readOnly={!isLeaf}
/>
Expand All @@ -50,15 +50,17 @@ export const AreaLatLngForm: React.FC<{ initLat: number, initLng: number, uuid:
Picker
</button>
</DialogTrigger>
<DialogContent title={`Pick location for ${areaName}`}>
<div className='w-full h-80'>
<CoordinatePickerMap
initialCenter={[initLng, initLat]}
initialZoom={14}
onCoordinateConfirmed={(coord) => {
setPickerSelected(false)
}}
/>
<DialogContent title={`Pick location for ${areaName}`} fullScreen={!!isMobile}>
<div className='w-full h-100vh'>
<div className='h-[90vh] w-full'>
<CoordinatePickerMap
initialCenter={[initLng, initLat]}
initialZoom={14}
onCoordinateConfirmed={(coord) => {
setPickerSelected(false)
}}
/>
</div>
</div>
</DialogContent>
</MobileDialog>
Expand Down
3 changes: 2 additions & 1 deletion src/components/maps/CoordinatePickerMap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ interface CoordinatePickerMapProps {
}

/**
* Coordinate Picker Map
* Map for picking coordinates to update the AreaLatLngForm component.
* Allows user to place a marker on the map and confirm the selection.
*/
export const CoordinatePickerMap: React.FC<CoordinatePickerMapProps> = ({
showFullscreenControl = true, initialCenter, initialZoom, initialViewState, onCameraMovement, onCoordinateConfirmed, children
Expand Down

0 comments on commit 66987e8

Please sign in to comment.