From eb83f0b152ddf3e71828c46205be18eb0939aa4b Mon Sep 17 00:00:00 2001 From: Viet Nguyen <3805254+vnugent@users.noreply.github.com> Date: Sat, 23 Dec 2023 14:10:45 -0700 Subject: [PATCH] fix: new add climbs page in dashboard (#1037) * new add climbs page in area edit dashboard --- src/app/area/[[...slug]]/page.tsx | 7 +- .../[[...slug]]/sections/ClimbListSection.tsx | 24 +- .../[[...slug]]/sections/SubAreasSection.tsx | 4 +- src/app/editArea/[slug]/SidebarNav.tsx | 42 ++-- .../[slug]/components/EditAreaContainers.tsx | 21 ++ .../[slug]/components/SingleEntryForm.tsx | 11 +- .../components/climb/ClimbListForm.tsx | 68 +++-- src/app/editArea/[slug]/general/page.tsx | 58 +++-- src/app/editArea/[slug]/layout.tsx | 2 +- src/app/editArea/[slug]/loading.tsx | 6 +- .../manageClimbs/components/AddClimbsForm.tsx | 62 +++++ .../components/ClimbListMiniToolbar.tsx | 35 +++ .../components/DisciplinesSelection.tsx | 236 ++++++++++++++++++ .../components/DynamicClimbInputList.tsx | 120 +++++++++ src/app/editArea/[slug]/manageClimbs/page.tsx | 33 +++ src/components/edit/EditAreaForm.tsx | 2 +- src/js/grades/Grade.ts | 4 +- src/js/hooks/useUpdateAreasCmd.tsx | 2 +- src/js/hooks/useUpdateClimbsCmd.tsx | 10 +- 19 files changed, 656 insertions(+), 91 deletions(-) create mode 100644 src/app/editArea/[slug]/components/EditAreaContainers.tsx create mode 100644 src/app/editArea/[slug]/manageClimbs/components/AddClimbsForm.tsx create mode 100644 src/app/editArea/[slug]/manageClimbs/components/ClimbListMiniToolbar.tsx create mode 100644 src/app/editArea/[slug]/manageClimbs/components/DisciplinesSelection.tsx create mode 100644 src/app/editArea/[slug]/manageClimbs/components/DynamicClimbInputList.tsx create mode 100644 src/app/editArea/[slug]/manageClimbs/page.tsx diff --git a/src/app/area/[[...slug]]/page.tsx b/src/app/area/[[...slug]]/page.tsx index 3a99f38f1..cd7a5c987 100644 --- a/src/app/area/[[...slug]]/page.tsx +++ b/src/app/area/[[...slug]]/page.tsx @@ -123,8 +123,11 @@ export default async function Page ({ params }: PageWithCatchAllUuidProps): Prom - - + {/* An area can only have either subareas or climbs, but not both. */} +
+ + +
) } diff --git a/src/app/area/[[...slug]]/sections/ClimbListSection.tsx b/src/app/area/[[...slug]]/sections/ClimbListSection.tsx index b3a1cc15b..94b09572b 100644 --- a/src/app/area/[[...slug]]/sections/ClimbListSection.tsx +++ b/src/app/area/[[...slug]]/sections/ClimbListSection.tsx @@ -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 ( -
+

{climbs.length} Climbs

-
- Coming soon: - - New Climbs - -
+ {/* Already in the edit dashboard. Don't show the button */} + {!editMode && + }
-
+
- +
) } diff --git a/src/app/area/[[...slug]]/sections/SubAreasSection.tsx b/src/app/area/[[...slug]]/sections/SubAreasSection.tsx index c862fd370..e6d795bb0 100644 --- a/src/app/area/[[...slug]]/sections/SubAreasSection.tsx +++ b/src/app/area/[[...slug]]/sections/SubAreasSection.tsx @@ -11,7 +11,7 @@ export const SubAreasSection: React.FC<{ area: AreaType } > = ({ area }) => { const { uuid, children, metadata: { leaf } } = area if (leaf) return null return ( -
+

{children.length} Areas

@@ -21,7 +21,7 @@ export const SubAreasSection: React.FC<{ area: AreaType } > = ({ area }) => {
-
+
diff --git a/src/app/editArea/[slug]/SidebarNav.tsx b/src/app/editArea/[slug]/SidebarNav.tsx index 9622d5ba1..cc606e8ce 100644 --- a/src/app/editArea/[slug]/SidebarNav.tsx +++ b/src/app/editArea/[slug]/SidebarNav.tsx @@ -1,8 +1,7 @@ 'use client' -import Link from 'next/link' import clx from 'classnames' import { usePathname } from 'next/navigation' -import { Article, Plus } from '@phosphor-icons/react/dist/ssr' +import { Article, Plus, LineSegments } from '@phosphor-icons/react/dist/ssr' /** * Sidebar navigation for area edit @@ -12,32 +11,47 @@ export const SidebarNav: React.FC<{ slug: string, canAddAreas: boolean, canAddCl /** * Disable menu item's hover/click when own page is showing */ - const classForActivePage = (myPath: string): string => activePath.endsWith(myPath) ? 'font-semibold pointer-events-none' : '' + const classForActivePage = (myPath: string): string => activePath.endsWith(myPath) ? 'font-bold pointer-events-none' : 'font-base' return (