From 7d8de2e9df517c9c96d9ba0f646e25c043f376a0 Mon Sep 17 00:00:00 2001 From: Clinton Lunn Date: Sat, 7 Dec 2024 14:19:13 -0700 Subject: [PATCH] refactor: adding a default vercel url, link to /maps from area and climb page (#1236) * fix: adding a default vercel url to fix the share button * refactor: add NEXT_PUBLIC_VERCEL_URL to env file * refactor: don't show share button on area or climb page * refactor: link to /maps? from climb or area page, if on climb, will link to parent --- .env | 2 ++ src/app/(default)/area/[[...slug]]/page.tsx | 2 +- src/app/(default)/climb/[[...slug]]/page.tsx | 2 +- src/app/(default)/components/AreaAndClimbPageActions.tsx | 8 ++++++-- src/app/(default)/components/SharePageURLButton.tsx | 2 +- src/components/maps/TileHandlers/CragContent.tsx | 5 +++-- src/js/graphql/gql/climbById.ts | 1 + 7 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.env b/.env index 415ac1936..e5797c3a0 100644 --- a/.env +++ b/.env @@ -21,6 +21,8 @@ NEXT_PUBLIC_CDN_URL=https://stg-media.openbeta.io NEXT_PUBLIC_API_SERVER=https://stg-api.openbeta.io +NEXT_PUBLIC_VERCEL_URL=$VERCEL_URL + # Disable telemetry NEXT_TELEMETRY_DISABLED=1 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..6345dfd23 100644 --- a/src/app/(default)/climb/[[...slug]]/page.tsx +++ b/src/app/(default)/climb/[[...slug]]/page.tsx @@ -66,7 +66,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/app/(default)/components/SharePageURLButton.tsx b/src/app/(default)/components/SharePageURLButton.tsx index 43500a25b..ccbd4fc17 100644 --- a/src/app/(default)/components/SharePageURLButton.tsx +++ b/src/app/(default)/components/SharePageURLButton.tsx @@ -10,7 +10,7 @@ import { ControlledTooltip } from '@/components/ui/Tooltip' */ export const SharePageURLButton: React.FC<{ path: string, name: string }> = ({ path, name }) => { const slug = getFriendlySlug(name) - const baseUrl = process.env.NEXT_PUBLIC_BASE_URL != null ? process.env.NEXT_PUBLIC_BASE_URL : 'http://localhost:3000' + const baseUrl = process.env.NEXT_PUBLIC_VERCEL_URL !== '' && process.env.NEXT_PUBLIC_VERCEL_URL != null ? `https://${process.env.NEXT_PUBLIC_VERCEL_URL}` : 'http://localhost:3000' const optionalSlug = slug !== '' ? `/${slug}` : '' const url = `${baseUrl}${path}${optionalSlug}` diff --git a/src/components/maps/TileHandlers/CragContent.tsx b/src/components/maps/TileHandlers/CragContent.tsx index 4363d6323..0de8c3503 100644 --- a/src/components/maps/TileHandlers/CragContent.tsx +++ b/src/components/maps/TileHandlers/CragContent.tsx @@ -11,6 +11,7 @@ export const CragDrawerContent: React.FC = ({ id, areaNam const friendlyUrl = getAreaPageFriendlyUrl(id, areaName) const editUrl = `/editArea/${id}/general` const pathname = `${usePathname()}${window.location.search}` + const isMapPage = pathname.startsWith('/maps?') return ( <> @@ -18,8 +19,8 @@ export const CragDrawerContent: React.FC = ({ id, areaNam media={} heading={{areaName}} subheading={} - cta={Edit area} - share={} + cta={Edit area} + share={isMapPage && } >
    {description == null || description.trim() === '' 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 {