import { useMemo } from 'react'; import { Label } from '@/components/ui/label'; import { Badge } from '@/components/ui/badge'; import { Users, X, Link2 } from 'lucide-react'; import { useCrews } from '@/hooks/useCrews'; import { useCurrentUser } from '@/hooks/useCurrentUser'; import { SKATE_CREW_KIND } from '@/lib/types'; import { cn } from '@/lib/utils'; interface CrewLinkFieldProps { /** Selected crew coordinate `35006:pubkey:d`, or undefined. */ value?: string; onChange: (coord: string | undefined) => void; accentText?: string; accentBg?: string; } /** * Lets a Lab-profile owner link ONE of their own crews. Cross-links a collective * Lab profile (studio) to its crew so each surfaces the other. */ export function CrewLinkField({ value, onChange, accentText = 'text-teal-400', accentBg = 'bg-teal-500' }: CrewLinkFieldProps) { const { user } = useCurrentUser(); const { data: allCrews } = useCrews(200); // Only offer the crews this user founded — you can only vouch a link from a crew you control. const myCrews = useMemo( () => (allCrews ?? []).filter((c) => c.pubkey === user?.pubkey), [allCrews, user?.pubkey] ); const coordFor = (pubkey: string, identifier: string) => `${SKATE_CREW_KIND}:${pubkey}:${identifier}`; return (

Run a crew too? Link it so people can jump between your studio and your crew. Optional. Link this crew back to the profile from the crew editor and it'll show a green{' '} Verified badge on both.

{myCrews.length === 0 ? (

You don't have any crews yet. Create one on the Crews page to link it here.

) : (
{myCrews.map((crew) => { const coord = coordFor(crew.pubkey, crew.identifier); const selected = value === coord; return ( ); })}
)} {value && !myCrews.some((c) => coordFor(c.pubkey, c.identifier) === value) && ( Linked crew ({value.split(':')[2]}) )}
); }