From 6d673fef52b2404f67be4af9bad04dba885b10bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriele=20Vigan=C3=B2?= Date: Tue, 17 Nov 2026 15:41:47 +0100 Subject: [PATCH 1/3] feat(associations): render reviewed registry links and portal entry --- src/app/associations/page.tsx | 7 ++++++ .../associations/associations-list.tsx | 23 ++++++++++++++----- src/queries/associations.ts | 20 +++++++++++++++- 3 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/app/associations/page.tsx b/src/app/associations/page.tsx index 8a8d2426..c334b326 100644 --- a/src/app/associations/page.tsx +++ b/src/app/associations/page.tsx @@ -24,6 +24,13 @@ export default async function AssociationsPage() {
+

+ Rappresenti un’associazione?{" "} + + Registrala o richiedi accesso alla sua scheda + + . +

diff --git a/src/components/associations/associations-list.tsx b/src/components/associations/associations-list.tsx index d22670e6..bef05977 100644 --- a/src/components/associations/associations-list.tsx +++ b/src/components/associations/associations-list.tsx @@ -13,9 +13,9 @@ import { import AccordionAssociation from "@/components/accordion-association" import type { GradientIconType } from "@/components/gradient-icon" import { EMPTY_STATE } from "@/components/layout/page" -import type { ApiOutput } from "@/types" +import type { getAllAssociations } from "@/queries/associations" -type Association = ApiOutput["web"]["associations"]["getAllAssociations"][number] +type Association = Awaited>[number] type AssociationLinks = Association["links"] const LINK_CONFIG: { key: keyof AssociationLinks; label: string; icon: GradientIconType; mailto?: boolean }[] = [ @@ -43,10 +43,21 @@ export function AssociationsList({ associations }: { associations: Association[] // No placeholder logo: an association without one gets its initials (see AccordionAssociation) logo: association.logo, content: association.descriptionIt, - links: LINK_CONFIG.filter(({ key }) => association.links[key]).map(({ key, label, icon, mailto }) => { - const value = association.links[key] as string - return { key: label, href: mailto ? `mailto:${value}` : value, icon } - }), + links: association.extraLinks + ? [ + ...(association.links.email + ? [{ key: "Email", href: `mailto:${association.links.email}`, icon: FiMail }] + : []), + ...association.extraLinks.map((link, index) => ({ + key: `${link.label} · ${index + 1}`, + href: link.url, + icon: LINK_CONFIG.find((config) => config.key === link.platform)?.icon ?? FiGlobe, + })), + ] + : LINK_CONFIG.filter(({ key }) => association.links[key]).map(({ key, label, icon, mailto }) => { + const value = association.links[key] as string + return { key: label, href: mailto ? `mailto:${value}` : value, icon } + }), })) return diff --git a/src/queries/associations.ts b/src/queries/associations.ts index 21dc8ef7..943f1ff6 100644 --- a/src/queries/associations.ts +++ b/src/queries/associations.ts @@ -1,10 +1,28 @@ "use server" +import { z } from "zod" import { trpc } from "@/lib/backend" +const extraLinksSchema = z.object({ + extraLinks: z + .array( + z.object({ + platform: z.string(), + label: z.string(), + url: z.url().refine((url) => /^https?:\/\//i.test(url)), + }) + ) + .optional(), +}) + export async function getAllAssociations() { try { - return await trpc.web.associations.getAllAssociations.query() + const associations = await trpc.web.associations.getAllAssociations.query() + // The published SDK predates repeated platform links. Validate the additive field, with old-server fallback. + return associations.map((association) => ({ + ...association, + extraLinks: extraLinksSchema.parse(association).extraLinks, + })) } catch (error) { console.error("Failed to fetch associations", error) return [] From 79895728ddc17b425607f25f4e978444b6a1ee7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriele=20Vigan=C3=B2?= Date: Tue, 17 Nov 2026 15:50:22 +0100 Subject: [PATCH 2/3] feat(associations): label repeated links and support reviewed external logos --- docs/associations.md | 9 ++++++ .../accordion-association/index.tsx | 30 +++++++++++++------ src/components/accordion-association/types.ts | 1 + .../associations/associations-list.tsx | 3 +- 4 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 docs/associations.md diff --git a/docs/associations.md b/docs/associations.md new file mode 100644 index 00000000..936da6ce --- /dev/null +++ b/docs/associations.md @@ -0,0 +1,9 @@ +# Published association registry + +The association listing accepts the optional `extraLinks` field from the reviewed backend registry. It validates the additive payload and keeps the existing `links` fallback for older backend deployments. Multiple entries for the same platform have their own visible labels, including unsupported platforms with a generic web icon. Public email remains a mail link. + +The public page links representatives to `https://admin.polinetwork.org/dashboard/associations`. Registration, representative approvals, private evidence and draft content belong to the backend/admin portal; this website receives only the approved public version. + +Reviewed external logo URLs are rendered without Next's server-side image optimization, avoiding arbitrary remote fetches through the image optimizer. Bundled static images retain optimization. + +This PR can deploy before the coordinated backend/admin release. Run `pnpm check`, `pnpm build`, and `pnpm typecheck`. The backend tests cover publication gating, preservation of existing associations and numeric IDs. In staging, confirm existing associations, repeated platform links and labels, and logo display after content approval. diff --git a/src/components/accordion-association/index.tsx b/src/components/accordion-association/index.tsx index ff257a04..15b638d6 100644 --- a/src/components/accordion-association/index.tsx +++ b/src/components/accordion-association/index.tsx @@ -31,7 +31,16 @@ function AssociationLogo({ name, logo }: Pick ) } - return + return ( + + ) } export default function AccordionAssociation({ accordionItems, defaultValue }: AccordionAssociationProps) { @@ -58,15 +67,18 @@ export default function AccordionAssociation({ accordionItems, defaultValue }: A href={link.href} target="_blank" rel="noopener noreferrer" - aria-label={link.key} - title={link.key} - className="group/icon relative flex size-10 items-center justify-center rounded-full outline-none transition-colors hover:bg-white/60 focus-visible:ring-2 focus-visible:ring-blue-secondary" + aria-label={link.label ?? link.key} + title={link.label ?? link.key} + className={`group/icon relative flex h-10 items-center justify-center gap-2 rounded-full outline-none transition-colors hover:bg-white/60 focus-visible:ring-2 focus-visible:ring-blue-secondary ${link.label ? "px-3" : "w-10"}`} > - - + + + + + {link.label && {link.label}} ))} diff --git a/src/components/accordion-association/types.ts b/src/components/accordion-association/types.ts index 216727e5..475bf09a 100644 --- a/src/components/accordion-association/types.ts +++ b/src/components/accordion-association/types.ts @@ -9,6 +9,7 @@ export type AccordionAssociationItem = { content: React.ReactNode links: { key: string + label?: string href: string icon: GradientIconType }[] diff --git a/src/components/associations/associations-list.tsx b/src/components/associations/associations-list.tsx index bef05977..ede05a32 100644 --- a/src/components/associations/associations-list.tsx +++ b/src/components/associations/associations-list.tsx @@ -49,7 +49,8 @@ export function AssociationsList({ associations }: { associations: Association[] ? [{ key: "Email", href: `mailto:${association.links.email}`, icon: FiMail }] : []), ...association.extraLinks.map((link, index) => ({ - key: `${link.label} · ${index + 1}`, + key: `${link.platform}-${index}`, + label: link.label, href: link.url, icon: LINK_CONFIG.find((config) => config.key === link.platform)?.icon ?? FiGlobe, })), From 5a9c168e401cfbf97aca2a9f02206037fcb89d14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriele=20Vigan=C3=B2?= Date: Tue, 17 Nov 2026 15:17:10 +0000 Subject: [PATCH 3/3] fix(associations): harden extraLinks parsing, label only repeated links, configurable admin URL - fall back to legacy links on invalid extraLinks instead of emptying the list - show visible labels only for repeated platforms and twitch/other - include platform name in link accessible names - optimize only configured logo hosts and ignore non-http(s) logos - read the admin portal URL from ADMIN_URL - add unit tests for link parsing and labels Co-Authored-By: Claude Sonnet 5.5 --- docs/associations.md | 4 +- src/app/associations/page.tsx | 6 +- .../accordion-association/index.tsx | 12 +-- src/components/accordion-association/types.ts | 1 + .../associations/associations-list.tsx | 8 +- src/env.js | 3 + src/lib/association-links.ts | 74 +++++++++++++++++++ src/queries/associations.ts | 16 +--- tests/association-links.test.mjs | 51 +++++++++++++ 9 files changed, 150 insertions(+), 25 deletions(-) create mode 100644 src/lib/association-links.ts create mode 100644 tests/association-links.test.mjs diff --git a/docs/associations.md b/docs/associations.md index 936da6ce..80c49bbe 100644 --- a/docs/associations.md +++ b/docs/associations.md @@ -1,8 +1,8 @@ # Published association registry -The association listing accepts the optional `extraLinks` field from the reviewed backend registry. It validates the additive payload and keeps the existing `links` fallback for older backend deployments. Multiple entries for the same platform have their own visible labels, including unsupported platforms with a generic web icon. Public email remains a mail link. +The association listing accepts the optional `extraLinks` field from the reviewed backend registry. It validates the additive payload and keeps the existing `links` fallback for older backend deployments. Visible labels are shown only for repeated platforms and for Twitch/other links (single links keep the icon-only look); an invalid `extraLinks` payload falls back to the legacy `links` for that association instead of emptying the list. Multiple entries for the same platform have their own visible labels, including unsupported platforms with a generic web icon. Public email remains a mail link. -The public page links representatives to `https://admin.polinetwork.org/dashboard/associations`. Registration, representative approvals, private evidence and draft content belong to the backend/admin portal; this website receives only the approved public version. +The public page links representatives to `/dashboard/associations` on `ADMIN_URL` (default `https://admin.polinetwork.org`). Registration, representative approvals, private evidence and draft content belong to the backend/admin portal; this website receives only the approved public version. Reviewed external logo URLs are rendered without Next's server-side image optimization, avoiding arbitrary remote fetches through the image optimizer. Bundled static images retain optimization. diff --git a/src/app/associations/page.tsx b/src/app/associations/page.tsx index c334b326..dbc710ce 100644 --- a/src/app/associations/page.tsx +++ b/src/app/associations/page.tsx @@ -2,6 +2,7 @@ import type { Metadata } from "next" import { AssociationsList } from "@/components/associations/associations-list" import { CONTAINER, PAGE_HERO, PAGE_MAIN } from "@/components/layout/page" import { Hero } from "@/components/ui/hero" +import { env } from "@/env" import { getAllAssociations } from "@/queries/associations" export const metadata: Metadata = { @@ -26,7 +27,10 @@ export default async function AssociationsPage() {

Rappresenti un’associazione?{" "} - + Registrala o richiedi accesso alla sua scheda . diff --git a/src/components/accordion-association/index.tsx b/src/components/accordion-association/index.tsx index 15b638d6..ad978726 100644 --- a/src/components/accordion-association/index.tsx +++ b/src/components/accordion-association/index.tsx @@ -1,4 +1,5 @@ import Image from "next/image" +import { isHttpUrl, isOptimizableImageHost } from "@/lib/association-links" import { GradientIcon } from "../gradient-icon" import { Accordion } from "./accordion" import { AccordionContent } from "./accordion-content" @@ -21,7 +22,8 @@ function initials(name: string) { function AssociationLogo({ name, logo }: Pick) { // The name sits right next to the logo, so both are decorative for screen readers - if (!logo) { + // Reviewed logos must be http(s); anything else falls back to the initials + if (!logo || (typeof logo === "string" && !isHttpUrl(logo))) { return ( Segui l'associazione