5.6 KiB
5.6 KiB
Handoff Report: Menu Exploration & Investigation
1. Observation
-
Types Definitions:
packages/types/index.tslines 195–208:export interface MenuItem { id: number label: string url: string order: number translations?: any[] } export interface Menu { id: number name: string items: MenuItem[] payload?: any }apps/spa/src/store/menuStore.tslines 4–21:export interface MenuLink { label: Record<string, string>; url?: string; links?: MenuLink[]; } export interface MenuColumn { title: Record<string, string>; links: MenuLink[]; } export interface MegaMenuPayload { id?: string; nodeId?: string; label: Record<string, string>; url?: string; columns?: MenuColumn[]; }apps/website/src/components/navigation/menuTypes.tslines 1–18:export interface MenuLink { label: Record<string, string> | string url?: string links?: MenuLink[] } export interface MenuColumn { title: Record<string, string> | string links: MenuLink[] } export interface MegaMenuPayload { id?: string nodeId?: string label: Record<string, string> | string url?: string columns?: MenuColumn[] }
-
Elysia Backend Routes:
apps/backend/src/routes/menus.tsline 5 defines route prefix/menus.PUT /:name(lines 60–147) receivesitemsandpayload, upserts the menu model, and executestx.menuItemoperations in a Prisma transaction (prisma.$transaction).- Validation schema (lines 132–147) defines
payload: t.Optional(t.Any()). - Database schema:
apps/backend/prisma/schema.prismalines 638–670 specifies:model Menu { id Int @id @default(autoincrement()) name String @unique payload Json? isActive Boolean @default(true) items MenuItem[] ... }
-
Storefront & Admin UI Rendering:
apps/spa/src/components/DesktopMegaMenu.tsxlines 86–130 renders three hardcoded mockup images frompicsum.photosfor:- Left side root menu mockup:
picsum.photos/seed/root-... - Column thumbnail:
picsum.photos/seed/col-... - Right side hover link preview:
picsum.photos/seed/link-...
- Left side root menu mockup:
apps/website/src/components/navigation/DesktopMegaMenu.tsxlines 73–94 maps columns and links but currently lacks any image placements (root, column, or hover).apps/admin/src/pages/MenuManagerPage.tsxlines 311–327 mapscurrentMenu.payloadrecursive tree configuration viaTreeNodeEditorbut has no inputs for image URLs.
2. Logic Chain
- Prisma Schema Constraints: Currently, the
MenuandMenuItemdatabase models do not have columns forrootImage,columnImage, orhoverImage(apps/backend/prisma/schema.prisma). Because these are missing in the schema, the backend cannot yet store flat values directly related to menus/menu-items. - Payload Structure: The
PUT /:nameroute accepts an unvalidated JSON tree inpayloadand stores it directly as aJsondatabase column. Thus, the client applications can structure the payload freely. - TypeScript Contracts: The client applications (
apps/spaandapps/website) define different structures for recursiveMegaMenuPayload, but both map to the database JSON field. - Current SPA Rendering Logic: The SPA megamenu dropdown implements the three visual image compartments but relies entirely on static mockup links from picsum.photos.
- Next.js storefront (
apps/website): Does not render any images inside its desktop megamenu layout. - Admin Interface (
apps/admin): TheMenuManagerPage's recursiveTreeNodeEditorcomponent permits editing names and URLs, but has no provisions for specifying the image links.
3. Caveats
- We assumed that all menus are stored using the Elysia menu routes and no direct raw SQL queries bypass them.
- We did not check the exact media uploader functionality since we only focused on how URLs are represented in menu definitions.
- The
isActiveflag toggle behavior on the website storefront was not fully traced since it does not affect structural data definitions.
4. Conclusion
- Backend / Database Changes Needed:
- Prisma schema needs updates:
rootImageonMenu, andcolumnImage/hoverImageonMenuItem. - Type validation schemas inside Elysia and typescript interfaces must be expanded to include these optional image fields.
- Prisma schema needs updates:
- Frontend Changes Needed:
apps/admin/src/pages/MenuManagerPage.tsx: ExpandTreeNodeEditorto support text/upload inputs for the 3 image types depending on the node type (root, column, link).apps/spa/src/components/DesktopMegaMenu.tsx: Replace hardcoded Picsum placeholders with dynamic data retrieved from the payload.apps/website/src/components/navigation/DesktopMegaMenu.tsx: Implement the 3-image layout usingnext/imageto match the SPA design.
5. Verification Method
- Check project compilation using:
npm run build --workspaces --if-present - Inspect file paths to verify the location of changes:
- Prisma schema:
apps/backend/prisma/schema.prisma - Types:
packages/types/index.ts,apps/spa/src/store/menuStore.ts,apps/website/src/components/navigation/menuTypes.ts - Routes:
apps/backend/src/routes/menus.ts - Components:
apps/admin/src/pages/MenuManagerPage.tsx,apps/spa/src/components/DesktopMegaMenu.tsx,apps/website/src/components/navigation/DesktopMegaMenu.tsx
- Prisma schema: