App.ComboLibrary = function ComboLibrary() { const [combos, setCombos] = React.useState([]); const [myCombos, setMyCombos] = React.useState([]); const [loading, setLoading] = React.useState(true); const [page, setPage] = React.useState(1); const [totalPages, setTotalPages] = React.useState(1); const [deleteModal, setDeleteModal] = React.useState(null); // { comboId, comboName, step: 'confirm' | 'in_use', polls: [] } const loadCombos = (p) => { setLoading(true); App.API.get('combos?page=' + p + '&limit=20&fingerprint=' + App.fingerprint).then(data => { setCombos(data.combos); setMyCombos(data.myCombos || []); setTotalPages(data.pages || 1); setLoading(false); }); }; React.useEffect(() => { loadCombos(page); }, [page]); const handleDeleteRequest = (comboId, comboName) => { setDeleteModal({ comboId: comboId, comboName: comboName, step: 'confirm', polls: [] }); }; const handleDeleteConfirm = () => { if (!deleteModal) return; App.API.post('combos/' + deleteModal.comboId, { _action: 'delete', fingerprint: App.fingerprint, }) .then((data) => { if (data.error === 'in_use') { setDeleteModal(prev => ({ ...prev, step: 'in_use', polls: data.polls || [] })); } else { setDeleteModal(null); loadCombos(page); } }) .catch(err => { setDeleteModal(null); alert(err.message); }); }; if (loading) return ; return (

Race Combos

Create Race Combo

Browse and manage race combinations

{myCombos.length > 0 && (

My Combos

{myCombos.map(combo => ( ))}
)}

Community Combos

{combos.length === 0 ? (

No community combos yet. Be the first to create one!

Create Race Combo
) : ( <>
{combos.map(combo => ( ))}
{totalPages > 1 && (
Page {page} of {totalPages}
)} )}
{deleteModal && (
setDeleteModal(null)}>
e.stopPropagation()}> {deleteModal.step === 'confirm' ? ( <>

Delete Combo

Are you sure you want to delete "{deleteModal.comboName}"?

) : ( <>

Cannot Delete

"{deleteModal.comboName}" is used in the following polls. Remove it from these polls first:

)}
)}
); };