From 973e06514b938ada432a9a24d8a20517e339144b Mon Sep 17 00:00:00 2001 From: Clinton Lunn Date: Sat, 7 Dec 2024 12:30:23 -0700 Subject: [PATCH] refactor: link to /maps? from climb or area page, if on climb, will link to parent --- src/app/(default)/area/[[...slug]]/page.tsx | 2 +- src/app/(default)/climb/[[...slug]]/page.tsx | 5 ++++- src/app/(default)/components/AreaAndClimbPageActions.tsx | 8 ++++++-- src/js/graphql/gql/climbById.ts | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/app/(default)/area/[[...slug]]/page.tsx b/src/app/(default)/area/[[...slug]]/page.tsx index 3c6875a50..ff8a602cc 100644 --- a/src/app/(default)/area/[[...slug]]/page.tsx +++ b/src/app/(default)/area/[[...slug]]/page.tsx @@ -56,7 +56,7 @@ export default async function Page ({ params }: PageWithCatchAllUuidProps): Prom ? : } - pageActions={} + pageActions={} breadcrumbs={ diff --git a/src/app/(default)/climb/[[...slug]]/page.tsx b/src/app/(default)/climb/[[...slug]]/page.tsx index 0242c18e6..16911ea9a 100644 --- a/src/app/(default)/climb/[[...slug]]/page.tsx +++ b/src/app/(default)/climb/[[...slug]]/page.tsx @@ -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) { @@ -66,7 +69,7 @@ export default async function Page ({ params }: PageWithCatchAllUuidProps): Prom ? : } - pageActions={} + pageActions={} breadcrumbs={ diff --git a/src/app/(default)/components/AreaAndClimbPageActions.tsx b/src/app/(default)/components/AreaAndClimbPageActions.tsx index e66acb89a..ca2f904d4 100644 --- a/src/app/(default)/components/AreaAndClimbPageActions.tsx +++ b/src/app/(default)/components/AreaAndClimbPageActions.tsx @@ -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 (
    @@ -33,7 +37,7 @@ export const AreaAndClimbPageActions: React.FC<{ uuid: string, name: string, tar - + Map diff --git a/src/js/graphql/gql/climbById.ts b/src/js/graphql/gql/climbById.ts index 9f85506be..99212ef7b 100644 --- a/src/js/graphql/gql/climbById.ts +++ b/src/js/graphql/gql/climbById.ts @@ -55,6 +55,7 @@ export const QUERY_CLIMB_BY_ID = gql` climbId } parent { + uuid, areaName gradeContext metadata {