/* global React, Icon */ const { useState, useEffect } = React; function Analytics({ goto }) { const [days, setDays] = useState(7); const [data, setData] = useState(null); const [error, setError] = useState(null); const [ga4, setGa4] = useState(null); useEffect(() => { fetch(`/api/analytics/overview?days=${days}`, { credentials: 'include' }) .then((r) => r.ok ? r.json() : Promise.reject(r.statusText)) .then(setData) .catch((e) => setError(String(e))); fetch(`/api/analytics/ga4?days=${days}`, { credentials: 'include' }) .then((r) => r.ok ? r.json() : { connected: false, reason: r.statusText }) .then(setGa4) .catch(() => setGa4({ connected: false, reason: 'fetch failed' })); }, [days]); if (error) { return