Skip to content

Commit

Permalink
refactor: link to /maps? from climb or area page, if on climb, will l…
Browse files Browse the repository at this point in the history
…ink to parent
  • Loading branch information
clintonlunn committed Dec 7, 2024
1 parent c49b6c4 commit 973e065
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/app/(default)/area/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default async function Page ({ params }: PageWithCatchAllUuidProps): Prom
? <UploadPhotoCTA />
: <PhotoMontage photoList={photoList} />
}
pageActions={<AreaAndClimbPageActions name={areaName} uuid={uuid} targetType={TagTargetType.area} />}
pageActions={<AreaAndClimbPageActions name={areaName} uuid={uuid} targetType={TagTargetType.area} parentUuid={uuid} />}
breadcrumbs={
<StickyHeaderContainer>
<AreaCrumbs pathTokens={pathTokens} ancestors={ancestors} />
Expand Down
5 changes: 4 additions & 1 deletion src/app/(default)/climb/[[...slug]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ export default async function Page ({ params }: PageWithCatchAllUuidProps): Prom
id, name, type, ancestors, pathTokens, parent
} = climb

console.log('parent', parent.uuid);


const correctSlug = getFriendlySlug(name)

if (correctSlug !== userProvidedSlug) {
Expand All @@ -66,7 +69,7 @@ export default async function Page ({ params }: PageWithCatchAllUuidProps): Prom
? <UploadPhotoCTA />
: <PhotoMontage photoList={photoList} />
}
pageActions={<AreaAndClimbPageActions name={name} uuid={id} targetType={TagTargetType.climb} />}
pageActions={<AreaAndClimbPageActions name={name} uuid={id} targetType={TagTargetType.climb} parentUuid={parent.uuid} />}
breadcrumbs={
<StickyHeaderContainer>
<AreaCrumbs pathTokens={pathTokens} ancestors={ancestors} />
Expand Down
8 changes: 6 additions & 2 deletions src/app/(default)/components/AreaAndClimbPageActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,26 @@ import { TagTargetType } from '@/js/types'

/**
* Main action bar for area & climb page
* In an area page, pass in the same uuid for both `uuid` and `parentUuid` but `parentUuid` is not used.
*/
export const AreaAndClimbPageActions: React.FC<{ uuid: string, name: string, targetType: TagTargetType }> = ({ uuid, name, targetType }) => {
export const AreaAndClimbPageActions: React.FC<{ uuid: string, name: string, targetType: TagTargetType, parentUuid: string }> = ({ uuid, name, targetType, parentUuid }) => {
let url: string
let sharePath: string
let enableEdit = true
let editLabel = 'Edit'
let navigateUuid = ''
switch (targetType) {
case TagTargetType.area:
url = `/editArea/${uuid}`
sharePath = `/area/${uuid}`
navigateUuid = uuid
break
case TagTargetType.climb:
url = `/editClimb/${uuid}`
sharePath = `/climb/${uuid}`
enableEdit = false
editLabel = 'Edit (TBD)'
navigateUuid = parentUuid ?? ''
}
return (
<ul className='flex items-center justify-between gap-2'>
Expand All @@ -33,7 +37,7 @@ export const AreaAndClimbPageActions: React.FC<{ uuid: string, name: string, tar

<UploadPhotoButton />

<Link href='#map' className='btn no-animation'>
<Link href={`/maps?areaId=${navigateUuid}`} className='btn no-animation'>
<MapTrifold size={20} className='hidden md:inline' /> Map
</Link>
<SharePageURLButton path={sharePath} name={name} />
Expand Down
1 change: 1 addition & 0 deletions src/js/graphql/gql/climbById.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export const QUERY_CLIMB_BY_ID = gql`
climbId
}
parent {
uuid,
areaName
gradeContext
metadata {
Expand Down

0 comments on commit 973e065

Please sign in to comment.