generated from taylorbryant/gatsby-starter-tailwind
-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: add latlng and isDirty state to submit btn
- Loading branch information
viet nguyen
committed
Nov 9, 2023
1 parent
5f1683e
commit ed207c5
Showing
12 changed files
with
141 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use client' | ||
import { useSession } from 'next-auth/react' | ||
|
||
import { SingleEntryForm } from 'app/area/[...slug]/SingleEntryForm' | ||
import { AREA_LATLNG_FORM_VALIDATION_RULES } from '@/components/edit/EditAreaForm' | ||
import { DashboardInput } from '@/components/ui/form/Input' | ||
import useUpdateAreasCmd from '@/js/hooks/useUpdateAreasCmd' | ||
import { parseLatLng } from '@/components/crag/cragSummary' | ||
|
||
export const AreaLatLngForm: React.FC<{ initLat: number, initLng: number, uuid: string }> = ({ uuid, initLat, initLng }) => { | ||
const session = useSession({ required: true }) | ||
const { updateOneAreaCmd } = useUpdateAreasCmd({ | ||
areaId: uuid, | ||
accessToken: session?.data?.accessToken as string | ||
} | ||
) | ||
const latlngStr = `${initLat.toString()},${initLng.toString()}` | ||
return ( | ||
<SingleEntryForm<{ latlngStr: string }> | ||
initialValues={{ latlngStr }} | ||
submitHandler={({ latlngStr }) => { | ||
const latlng = parseLatLng(latlngStr) | ||
if (latlng != null) { | ||
void updateOneAreaCmd({ lat: latlng[0], lng: latlng[1] }) | ||
} else { | ||
console.error('# form validation should catch this error') | ||
} | ||
}} | ||
> | ||
<DashboardInput | ||
name='latlng' | ||
label='Coordinates' | ||
description='Specify the approximate latitude and longitude. The location may be where the trail meets the wall or in the middle of a long wall.' | ||
helper='Please use <latitude>, <longitude>' | ||
className='w-80' | ||
registerOptions={AREA_LATLNG_FORM_VALIDATION_RULES} | ||
/> | ||
</SingleEntryForm> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters