import React from 'react'; import { StyleSheet, TouchableOpacity, FlatList, ActivityIndicator } from 'react-native'; import { View, Text, useTheme } from '@bettoredge/styles'; import { Ionicons } from '@expo/vector-icons'; import type { CalcuttaTemplateProps } from '@bettoredge/types'; import { useCalcuttaTemplates } from '../hooks/useCalcuttaTemplates'; export interface CalcuttaTemplateSelectorProps { selectedTemplateId?: string; onSelect: (template: CalcuttaTemplateProps | undefined) => void; } export const CalcuttaTemplateSelector: React.FC = ({ selectedTemplateId, onSelect, }) => { const { theme } = useTheme(); const { loading, templates } = useCalcuttaTemplates(); if (loading) { return ( ); } if (templates.length === 0) { return null; } return ( Use a Template (optional) {selectedTemplateId && ( onSelect(undefined)} > Clear template )} item.calcutta_template_id} renderItem={({ item }) => { const isSelected = item.calcutta_template_id === selectedTemplateId; return ( onSelect(isSelected ? undefined : item)} > {item.template_name} {item.sport && ( {item.sport} )} {item.items?.length ?? '?'} items ยท {item.rounds?.length ?? '?'} rounds ); }} /> ); }; const styles = StyleSheet.create({ container: { marginVertical: 8, }, centered: { alignItems: 'center', justifyContent: 'center', paddingVertical: 16, }, clearButton: { flexDirection: 'row', alignItems: 'center', alignSelf: 'flex-start', paddingHorizontal: 8, paddingVertical: 4, borderRadius: 12, borderWidth: 1, marginBottom: 8, }, card: { width: 140, padding: 12, borderRadius: 8, borderWidth: 1.5, marginRight: 10, }, });