import { useMemo } from 'react'; import { Label } from '@/components/ui/label'; import { Link2, X, GraduationCap } from 'lucide-react'; import { useLabProfiles } from '@/hooks/useLabProfiles'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { cn } from '@/lib/utils'; const TYPE_LABEL: Record = { coach: 'Coach', filmer: 'Filmer', editor: 'Editor', photographer: 'Photographer', builder: 'Builder', }; interface LabLinkFieldProps { /** Selected Lab profile coordinates (`kind:pubkey:d`). */ value: string[]; onChange: (coords: string[]) => void; maxLinks?: number; } /** * Lets a crew owner link their own Lab profiles (studio/coach/builder listings) * so a crew and its service listings cross-reference each other. */ export function LabLinkField({ value, onChange, maxLinks = 8 }: LabLinkFieldProps) { const { user } = useCurrentUser(); const { data: allProfiles } = useLabProfiles(200); // Only your own Lab profiles — a crew can only vouch a link to listings it controls. const myProfiles = useMemo( () => (allProfiles ?? []).filter((p) => p.pubkey === user?.pubkey), [allProfiles, user?.pubkey] ); const coordFor = (kind: number, pubkey: string, identifier: string) => `${kind}:${pubkey}:${identifier}`; const toggle = (coord: string) => { if (value.includes(coord)) { onChange(value.filter((c) => c !== coord)); } else if (value.length < maxLinks) { onChange([...value, coord]); } }; return (

Run a studio, coaching or build service too? Link your Lab listings so people can hire your crew. Optional.

{myProfiles.length === 0 ? (

You don't have any Lab profiles yet. Create one in The Lab to link it here.

) : (
{myProfiles.map((p) => { const coord = coordFor(p.event.kind, p.pubkey, p.identifier); const selected = value.includes(coord); return ( ); })}
)}
); }