"use client" import React from "react" import Link from "next/link" import { ActionLinkTypeLink, ProjectExtraLinkType, ProjectInterface, } from "@/lib/types" import { LABELS } from "@/app/labels" import { Icons } from "../icons" interface ProjectExtraLinksProps { project: ProjectInterface } interface ExtraLinkItemsProps { id: ProjectExtraLinkType links: ActionLinkTypeLink[] } export default function ProjectExtraLinks({ project }: ProjectExtraLinksProps) { const { extraLinks = {} } = project const hasExtraLinks = Object.keys(extraLinks).length > 0 const ExtraLinkLabelMapping: Record< ProjectExtraLinkType, { label: string icon?: any } > = { buildWith: { label: LABELS.COMMON.BUILD_WITH_THIS_TOOL, icon: , }, play: { label: LABELS.COMMON.TRY_IT_OUT, icon: , }, research: { label: LABELS.COMMON.DEEP_DIVE_RESEARCH, icon: , }, learn: { label: LABELS.COMMON.LEARN_MORE, }, } if (!hasExtraLinks) return null const ExtraLinkItems = ({ id, links = [] }: ExtraLinkItemsProps) => { const { label } = ExtraLinkLabelMapping[id] if (!links.length) return null // no links hide the section return (

{label}

{links.map((link: ActionLinkTypeLink, index) => { if (!link) return null const { label, url } = link ?? {} return ( {label} ) })}
) } return (
{Object.entries(ExtraLinkLabelMapping).map(([key]) => { const links = extraLinks[key as ProjectExtraLinkType] ?? [] return ( ) })}
) }