/* global React, NA_DATA, NASite, naSupabase */
const { useState, useEffect } = React;
/* ============================================================
CAMPS PAGE
============================================================
Lists published camps from Supabase (`public_camps` view).
Each card has an "Apply" button that opens an application form;
submitting writes to `enquiries` with source='camp_application'.
============================================================ */
function CampsPage({ setPage }) {
const [camps, setCamps] = useState([]);
const [loadState, setLoadState] = useState('loading'); // 'loading' | 'ok' | 'empty' | 'error'
const [errMsg, setErrMsg] = useState('');
const [applyTo, setApplyTo] = useState(null); // a camp object, or null
// Fetch published camps on mount.
useEffect(() => {
let cancelled = false;
(async () => {
try {
const rows = await naSupabase.fetchCamps();
if (cancelled) return;
setCamps(rows);
setLoadState(rows.length === 0 ? 'empty' : 'ok');
} catch (e) {
if (cancelled) return;
console.warn('Supabase fetchCamps failed:', e);
setErrMsg(e.message || 'Could not reach Supabase');
setLoadState('error');
}
})();
return () => { cancelled = true; };
}, []);
return (
Programme / Camps
Camps.
Multi-day skills camps — open to club members and outside players. Run during school holidays at our partner venues across Nottingham. Coaches publish each camp here as soon as dates are confirmed.
{loadState === 'loading' && (
Loading camps…
)}
{loadState === 'error' && (
Could not load camps.
{errMsg}
)}
{loadState === 'empty' && (
No camps published right now.
We run camps in the school holidays — Christmas, February half-term, Easter, and across summer. When dates are confirmed they appear here. Drop us a line and we'll let you know.