diff --git a/web/src/components/gardens/GardenCard.tsx b/web/src/components/gardens/GardenCard.tsx index 56f6f06..ebab3c2 100644 --- a/web/src/components/gardens/GardenCard.tsx +++ b/web/src/components/gardens/GardenCard.tsx @@ -1,33 +1,30 @@ import { Link } from '@tanstack/react-router' -import { isOwnerRole, type Garden } from '@/lib/gardens' +import type { Garden } from '@/lib/gardens' import { formatDimensions } from '@/lib/units' - -const actionClass = - 'rounded-md px-2.5 py-1 text-sm font-medium text-muted outline-none transition-colors ' + - 'hover:bg-border/50 hover:text-fg focus-visible:ring-2 focus-visible:ring-accent/40' -const dangerClass = - 'rounded-md px-2.5 py-1 text-sm font-medium text-muted outline-none transition-colors ' + - 'hover:bg-red-500/10 hover:text-red-600 focus-visible:ring-2 focus-visible:ring-red-500/40 dark:hover:text-red-400' +import { cardActionClass, cardDangerClass } from '@/components/ui/cardActions' /** * One garden as a card: the body links into the editor. The footer differs by * role — the owner gets Share / Edit / Delete; a recipient sees a "shared · role" * badge and a Leave action (garden metadata edit + sharing are owner-only). + * Ownership is the authoritative ownerId==me check, not the my_role hint. */ export function GardenCard({ garden, + currentUserId, onShare, onEdit, onDelete, onLeave, }: { garden: Garden + currentUserId?: number onShare: () => void onEdit: () => void onDelete: () => void onLeave: () => void }) { - const owner = isOwnerRole(garden.myRole) + const owner = currentUserId != null && garden.ownerId === currentUserId return (