// components/templates/TemplateCard.tsx import React from 'react'; import { View, TouchableOpacity, Platform } from 'react-native'; import { Text } from '@/components/ui/text'; import { Card, CardContent } from '@/components/ui/card'; import { Button } from '@/components/ui/button'; import { Badge } from '@/components/ui/badge'; import { Trash2, Star, Play } from 'lucide-react-native'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from '@/components/ui/alert-dialog'; import { Sheet, SheetContent, SheetHeader, SheetTitle } from '@/components/ui/sheet'; import { Template } from '@/types/library'; interface TemplateCardProps { template: Template; onPress: () => void; onDelete: (id: string) => void; onFavorite: () => void; onStartWorkout: () => void; } export function TemplateCard({ template, onPress, onDelete, onFavorite, onStartWorkout }: TemplateCardProps) { const [showSheet, setShowSheet] = React.useState(false); const [showDeleteAlert, setShowDeleteAlert] = React.useState(false); const { id, title, type, category, exercises, description, tags = [], source, lastUsed, isFavorite } = template; const handleConfirmDelete = () => { onDelete(id); setShowDeleteAlert(false); }; const handleCardPress = () => { setShowSheet(true); onPress(); }; return ( <> {title} {source} {type} {category} {exercises.length > 0 && ( Exercises: {exercises.slice(0, 3).map((exercise, index) => ( • {exercise.title} ({exercise.targetSets}×{exercise.targetReps}) ))} {exercises.length > 3 && ( +{exercises.length - 3} more )} )} {description && ( {description} )} {tags.length > 0 && ( {tags.map(tag => ( {tag} ))} )} {lastUsed && ( Last used: {lastUsed.toLocaleDateString()} )} Delete Template Are you sure you want to delete {title}? This action cannot be undone. Cancel Delete {/* Sheet for detailed view */} setShowSheet(false)}> {title} {description && ( Description {description} )} Details Type: {type} Category: {category} Source: {source} Exercises {exercises.map((exercise, index) => ( {exercise.title} ({exercise.targetSets}×{exercise.targetReps}) ))} {tags.length > 0 && ( Tags {tags.map(tag => ( {tag} ))} )} ); }