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.
Add climb list to manage climbs page
- Loading branch information
viet nguyen
committed
Dec 23, 2023
1 parent
ba9af1d
commit 6c6debc
Showing
13 changed files
with
163 additions
and
68 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,30 @@ | ||
import Link from 'next/link' | ||
import { Plus } from '@phosphor-icons/react/dist/ssr' | ||
import { ClimbList } from '@/app/editArea/[slug]/general/components/climb/ClimbListForm' | ||
import { AreaType } from '@/js/types' | ||
/** | ||
* Sub-areas section | ||
* Climb list section | ||
*/ | ||
export const ClimbListSection: React.FC<{ area: AreaType }> = ({ area }) => { | ||
export const ClimbListSection: React.FC<{ area: AreaType, editMode?: boolean }> = ({ area, editMode = false }) => { | ||
const { uuid, gradeContext, climbs, metadata } = area | ||
if (!metadata.leaf) return null | ||
return ( | ||
<section className='w-full mt-16'> | ||
<section className='w-full'> | ||
<div className='flex items-center justify-between'> | ||
<div className='flex items-center gap-3'> | ||
<h3 className='flex items-center gap-4'>{climbs.length} Climbs</h3> | ||
</div> | ||
<div className='flex items-center gap-2'> | ||
<span className='text-sm italic'>Coming soon:</span> | ||
<Link href={`/editArea/${uuid}/general#addArea`} className='btn-disabled btn btn-sm'> | ||
<Plus size={18} weight='bold' /> New Climbs | ||
</Link> | ||
</div> | ||
{/* Already in the edit dashboard. Don't show the button */} | ||
{!editMode && | ||
<div className='flex items-center gap-2'> | ||
<a href={`/editArea/${uuid}/manageClimbs`} className='btn btn-sm btn-accent btn-outline'> | ||
<Plus size={18} weight='bold' /> New Climbs | ||
</a> | ||
</div>} | ||
</div> | ||
|
||
<hr className='my-6 border-2 border-base-content' /> | ||
<hr className='mt-2 mb-6 border-2 border-base-content' /> | ||
|
||
<ClimbList gradeContext={gradeContext} areaMetadata={metadata} climbs={climbs} /> | ||
<ClimbList gradeContext={gradeContext} areaMetadata={metadata} climbs={climbs} editMode={editMode} /> | ||
</section> | ||
) | ||
} |
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 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
35 changes: 35 additions & 0 deletions
35
src/app/editArea/[slug]/manageClimbs/components/ClimbListMiniToolbar.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,35 @@ | ||
'use client' | ||
import { useSession } from 'next-auth/react' | ||
import { useRouter } from 'next/navigation' | ||
import { Trash } from '@phosphor-icons/react/dist/ssr' | ||
import useUpdateClimbsCmd from '@/js/hooks/useUpdateClimbsCmd' | ||
import Confirmation from '@/components/ui/micro/AlertDialogue' | ||
|
||
export const ClimbListMiniToolbar: React.FC<{ parentAreaId: string, climbId: string, climbName: string }> = ({ parentAreaId, climbId, climbName }) => { | ||
const session = useSession({ required: true }) | ||
const router = useRouter() | ||
const { deleteClimbsCmd } = useUpdateClimbsCmd({ parentId: parentAreaId, accessToken: session.data?.accessToken ?? '' }) | ||
const onConfirm = (): void => { | ||
deleteClimbsCmd([climbId]).then((count) => { | ||
router.refresh() | ||
}).catch((error) => { | ||
console.error(error) | ||
}) | ||
} | ||
return ( | ||
<div className='flex justify-end mb-2 py-1'> | ||
<Confirmation | ||
title='Please confirm' | ||
confirmText='Delete' | ||
button={ | ||
<button className='btn btn-xs btn-glass'> | ||
<Trash size={16} /> Delete | ||
</button> | ||
} | ||
onConfirm={onConfirm} | ||
> | ||
You're about to delete climb "<i>{climbName}"</i>. <strong>This cannot be undone.</strong> | ||
</Confirmation> | ||
</div> | ||
) | ||
} |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Metadata } from 'next' | ||
import { DashboardPageProps, getPageDataForEdit } from '../general/page' | ||
import { PageContainer, SectionContainer } from '../components/EditAreaContainers' | ||
import { AddClimbsForm } from './components/AddClimbsForm' | ||
import { ClimbListSection } from '@/app/area/[[...slug]]/sections/ClimbListSection' | ||
|
||
// Opt out of caching for all data requests in the route segment | ||
export const dynamic = 'force-dynamic' | ||
export const fetchCache = 'force-no-store' // opt out of Nextjs version of 'fetch' | ||
|
||
// Page metadata | ||
export async function generateMetadata ({ params }: DashboardPageProps): Promise<Metadata> { | ||
const { area: { areaName } } = await getPageDataForEdit(params.slug, 'cache-first') | ||
return { | ||
title: `Maging climbs in area ${areaName}` | ||
} | ||
} | ||
|
||
export default async function AddClimbsPage ({ params: { slug } }: DashboardPageProps): Promise<any> { | ||
const { area } = await getPageDataForEdit(slug) | ||
const { areaName, uuid, gradeContext, metadata } = area | ||
const { leaf, isBoulder } = metadata | ||
return ( | ||
<PageContainer> | ||
<SectionContainer id='climbList'> | ||
<ClimbListSection area={area} editMode /> | ||
</SectionContainer> | ||
<SectionContainer id='addClimbs'> | ||
<AddClimbsForm parentAreaName={areaName} parentAreaUuid={uuid} gradeContext={gradeContext} canAddClimbs={isBoulder || leaf} /> | ||
</SectionContainer> | ||
</PageContainer> | ||
) | ||
} |
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