generated from taylorbryant/gatsby-starter-tailwind
-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wip: combine separate pages into one
- Loading branch information
viet nguyen
committed
Nov 24, 2023
1 parent
8a91296
commit 6dbb1f7
Showing
22 changed files
with
164 additions
and
107 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
File renamed without changes.
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
File renamed without changes.
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
File renamed without changes.
44 changes: 44 additions & 0 deletions
44
src/app/editArea/[slug]/general/components/AreaTypeForm.tsx
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,44 @@ | ||
'use client' | ||
import { useSession } from 'next-auth/react' | ||
import { useRouter } from 'next/navigation' | ||
|
||
import { SingleEntryForm } from 'app/editArea/[slug]/components/SingleEntryForm' | ||
import useUpdateAreasCmd from '@/js/hooks/useUpdateAreasCmd' | ||
import { AreaType } from '@/js/types' | ||
import { AreaDesignationRadioGroup, areaDesignationToDb, areaDesignationToForm, AreaTypeFormProp } from '@/components/edit/form/AreaDesignationRadioGroup' | ||
|
||
/** | ||
* Set area type: general area | crag | boulder | ||
*/ | ||
export const AreaTypeForm: React.FC<{ area: AreaType }> = ({ area }) => { | ||
const { uuid, climbs, children } = area | ||
const session = useSession({ required: true }) | ||
const router = useRouter() | ||
const { updateOneAreaCmd } = useUpdateAreasCmd({ | ||
areaId: uuid, | ||
accessToken: session?.data?.accessToken as string | ||
} | ||
) | ||
|
||
const areaType = areaDesignationToForm(area.metadata) | ||
|
||
// we're allowed to change area designation when the area has neither climbs nor areas. | ||
const canChangeAreaType = | ||
climbs.length === 0 && | ||
children.length === 0 | ||
return ( | ||
<SingleEntryForm<{ areaType: AreaTypeFormProp }> | ||
initialValues={{ areaType }} | ||
keepValuesAfterReset={false} | ||
title='Area Type' | ||
helperText='You can not change the type if this area contains subareas or climbs.' | ||
submitHandler={async ({ areaType }) => { | ||
const { isBoulder, isLeaf } = areaDesignationToDb(areaType) | ||
await updateOneAreaCmd({ uuid, isBoulder, isLeaf }) | ||
router.refresh() // Ask Next to refresh props from the server | ||
}} | ||
> | ||
<AreaDesignationRadioGroup disabled={!canChangeAreaType} /> | ||
</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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.