App.Dashboard = function Dashboard({ user }) {
const [data, setData] = React.useState(null);
const [loading, setLoading] = React.useState(true);
const [quote, setQuote] = React.useState(null);
const quotesRef = React.useRef([]);
React.useEffect(() => {
App.API.get('dashboard?fingerprint=' + App.fingerprint)
.then(d => {
setData(d);
setLoading(false);
})
.catch(() => setLoading(false));
fetch('data/quotes.json')
.then(r => r.json())
.then(quotes => {
quotesRef.current = quotes;
if (quotes.length > 0) {
setQuote(quotes[Math.floor(Math.random() * quotes.length)]);
}
})
.catch(() => {});
}, []);
function newQuote() {
const quotes = quotesRef.current;
if (quotes.length <= 1) return;
let next;
do {
next = quotes[Math.floor(Math.random() * quotes.length)];
} while (next === quote);
setQuote(next);
}
if (loading) return
Failed to load dashboard.
"{quote.text}" — {quote.author}
Your racing command center
)} {/* Quick Actions */}You're all caught up!
) : (No poll results yet.
) : (#{combo.rank}: {combo.name} at {combo.trackName} {combo.voteCount > 0 && ( ({combo.avgRating.toFixed(1)} avg) )}
)) ) : (No votes yet
)}You haven't created any combos yet.
) : ( <>