MCPcopy Create free account
hub / github.com/dailydotdev/apps / BoostsList

Function BoostsList

packages/shared/src/features/boost/BoostManager.tsx:554–671  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

552};
553
554const BoostsList = (): ReactElement => {
555 const { openModal } = useLazyModal();
556 const { onStopBoost } = useStopBoost();
557 const { data, isLoading, infiniteScrollingProps } = useCampaigns();
558 const campaigns = useMemo(
559 () =>
560 data?.pages.flatMap((page) => page.edges.map(({ node }) => node)) ?? [],
561 [data],
562 );
563 const live = campaigns.filter(({ state }) => state === CampaignState.Active);
564 const ended = campaigns.filter(({ state }) => state !== CampaignState.Active);
565 const [pickedTab, setTab] = useState<BoostsTab>();
566 const { query } = useRouter();
567 const linkedId = typeof query.boost === 'string' ? query.boost : undefined;
568 const linked = campaigns.find(({ id }) => id === linkedId);
569 const linkedTab =
570 linked &&
571 (linked.state === CampaignState.Active ? BoostsTab.Live : BoostsTab.Ended);
572 const tab =
573 pickedTab ?? linkedTab ?? (live.length ? BoostsTab.Live : BoostsTab.Ended);
574 const blinkingId = useBlinkLinkedRow(linked?.id);
575 const tabs = [
576 { name: BoostsTab.Live, list: live },
577 { name: BoostsTab.Ended, list: ended },
578 ];
579 const active = tab === BoostsTab.Live ? live : ended;
580 // Counts only add up once every page is in
581 const isComplete = !infiniteScrollingProps.canFetchMore;
582
583 const onBoostAgain = (campaign: Campaign) => {
584 if (campaign.type === CampaignType.Post && campaign.post) {
585 openModal({
586 type: LazyModal.BoostPost,
587 props: {
588 post: campaign.post,
589 origin: Origin.AdsDashboard,
590 lastBoost: lastBoostOf(campaign),
591 },
592 });
593 return;
594 }
595
596 if (campaign.type === CampaignType.Squad && campaign.source) {
597 openModal({
598 type: LazyModal.BoostSquad,
599 props: { squad: campaign.source, origin: Origin.AdsDashboard },
600 });
601 }
602 };
603
604 const emptyState = (
605 <CharmEmptyState
606 image={cloudinaryCharmNoPosts}
607 imageAlt="No boosts yet"
608 title="No running ads yet"
609 description="Learn how boosting works and launch your first campaign to get discovered by more developers."
610 action={{ label: 'Learn more about boosting', href: boostDocsLink }}
611 placement={CharmEmptyStatePlacement.Page}

Callers

nothing calls this directly

Calls 6

useLazyModalFunction · 0.90
useStopBoostFunction · 0.90
useCampaignsFunction · 0.90
useBlinkLinkedRowFunction · 0.85
setTabFunction · 0.85
useRouterFunction · 0.50

Tested by

no test coverage detected