/* global React, Icon, Badge, Button, Eyebrow, api */
const { useState: useStateCL, useEffect: useEffectCL } = React;
function CampaignsList({ onSubmit, onOpenBrief }){
const [campaigns, setCampaigns] = useStateCL([]);
const [myClips, setMyClips] = useStateCL([]);
const [loading, setLoading] = useStateCL(true);
useEffectCL(() => {
let mounted = true;
(async () => {
const [c, m] = await Promise.all([api.listLiveCampaigns(), api.listMyClips()]);
if (!mounted) return;
setCampaigns(c.error ? [] : c.data);
setMyClips(m.error ? [] : m.data);
setLoading(false);
})();
return () => { mounted = false; };
}, []);
if (loading) return
Loading…
;
return (
CAMPAIGNS
What you can post for
{campaigns.length === 0 && (
No live campaigns right now. Check back soon — Discord gets pinged when new ones launch.
)}
{campaigns.map(c => {
const myForC = myClips.filter(x => x.campaign_id === c.id);
const myViews = myForC.reduce((s,x) => s + (x.views||0), 0);
const myEarned = myForC.filter(x => x.status==="approved").reduce((s,x) => s + Number(x.earned||0), 0);
return (
{c.brief_md &&
{c.brief_md}
}
);
})}
);
}
function MiniStat({label,value,positive,className}){
return (
);
}
window.CampaignsList = CampaignsList;