import { Link } from 'react-router-dom';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { ImageWithFallback } from '@/components/ImageWithFallback';
import { Users, GraduationCap, ChevronRight, Link2, BadgeCheck } from 'lucide-react';
import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
import { useCrew } from '@/hooks/useCrews';
import { useLabProfile } from '@/hooks/useLabProfiles';
import { parseAddrCoord } from '@/lib/types';
/**
* Small "✓ Verified" pill shown when a link is confirmed from BOTH sides
* (the crew links the Lab profile AND the Lab profile links the crew). A
* one-sided claim shows nothing — we never imply trust that isn't mutual.
*/
function MutualBadge() {
return (
Verified
Both sides confirm this link — the crew and the Lab profile each point at
the other.
);
}
const LAB_TYPE_LABEL: Record = {
35001: 'Coach',
35002: 'Filmer',
35003: 'Editor',
35004: 'Photographer',
35005: 'Builder',
35007: 'Artist',
35008: 'Graffiti',
35009: 'Tattoo',
35010: 'Trainer',
35011: 'Musician',
};
/**
* A single linked-crew row, resolved from a `35006:pubkey:d` coordinate.
* `selfCoord` is the coordinate of the Lab profile showing this card — used to
* check whether the crew links BACK (mutual = verified).
*/
function CrewRow({ coord, selfCoord }: { coord: string; selfCoord?: string }) {
const parsed = parseAddrCoord(coord);
const { data: crew } = useCrew(parsed?.identifier ?? '', parsed?.pubkey);
if (!parsed) return null;
const mutual = !!selfCoord && !!crew?.labRefs?.includes(selfCoord);
return (
}
/>
{crew?.name ?? 'Skate Crew'}
{mutual && }
Crew{crew?.location ? ` · ${crew.location}` : ''}
);
}
/**
* A single linked-Lab-profile row, resolved from a `kind:pubkey:d` coordinate.
* `selfCoord` is the coordinate of the crew showing this card — used to check
* whether the Lab profile links BACK (mutual = verified).
*/
function LabRow({ coord, selfCoord }: { coord: string; selfCoord?: string }) {
const parsed = parseAddrCoord(coord);
const { data: profile } = useLabProfile(parsed?.identifier ?? '', parsed?.pubkey);
if (!parsed) return null;
const typeLabel = LAB_TYPE_LABEL[parsed.kind] ?? 'Lab';
const mutual = !!selfCoord && profile?.crewRef === selfCoord;
return (
}
/>
{profile?.title ?? `${typeLabel} profile`}
{mutual && }
In The Lab · {typeLabel}
);
}
/**
* Card shown on a Lab profile: the crew it belongs to.
* `selfCoord` is this Lab profile's own coordinate (`kind:pubkey:d`) so the row
* can show a "Verified" badge when the crew links back.
*/
export function LinkedCrewCard({ crewRef, selfCoord }: { crewRef?: string; selfCoord?: string }) {
if (!crewRef) return null;
return (
Part of a Crew
);
}
/**
* Card shown on a crew: the Lab service profiles it links to.
* `selfCoord` is the crew's own coordinate (`35006:pubkey:d`) so each row can
* show a "Verified" badge when that Lab profile links back to this crew.
*/
export function LinkedLabCard({ labRefs, selfCoord }: { labRefs: string[]; selfCoord?: string }) {
if (!labRefs || labRefs.length === 0) return null;
return (
Hire This Crew