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

Function PlusExtension

packages/shared/src/components/plus/PlusExtension.tsx:15–74  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13import { usePaymentContext } from '../../contexts/payment/context';
14
15const PlusExtension = (): ReactElement => {
16 const { getMarketingCta } = useBoot();
17 const marketingCta = getMarketingCta(MarketingCtaVariant.Plus);
18 const { flags } = marketingCta || {};
19 const { logEvent } = useLogContext();
20 const { productOptions } = usePaymentContext();
21
22 const handleClick = () => {
23 if (!marketingCta?.campaignId) {
24 throw new Error('PlusExtension requires a marketing CTA campaign id');
25 }
26
27 logEvent({
28 event_name: LogEvent.UpgradeSubscription,
29 target_type: TargetType.MarketingCtaPlus,
30 target_id: marketingCta.campaignId,
31 extra: JSON.stringify({
32 origin: Origin.InAppPromotion,
33 }),
34 });
35 };
36
37 const experiment = useFeature(plusTakeoverContent);
38 const [selectedOption, setSelectedOption] = useState<string | null>(null);
39
40 return (
41 <div className="flex flex-1 flex-row pl-6">
42 <div className="flex flex-1 flex-col pr-10 pt-6">
43 <PlusInfo
44 productOptions={productOptions || []}
45 title={experiment?.title ?? flags?.title}
46 description={experiment?.description ?? flags?.description}
47 selectedOption={selectedOption}
48 onChange={({ priceId }) => {
49 setSelectedOption(priceId);
50 }}
51 showPlusList={false}
52 showDailyDevLogo
53 showGiftButton={false}
54 showTrustReviews={false}
55 />
56 <Button
57 variant={ButtonVariant.Primary}
58 tag="a"
59 href={`${plusUrl}/payment?pid=${selectedOption}`}
60 disabled={!selectedOption}
61 className="mt-8"
62 onClick={handleClick}
63 >
64 {experiment?.cta ?? flags?.ctaText}
65 </Button>
66 </div>
67 <PlusListModalSection
68 items={experiment?.features}
69 shouldShowRefund={experiment?.shouldShowRefund}
70 shouldShowReviews={experiment?.shouldShowReviews}
71 />
72 </div>

Callers

nothing calls this directly

Calls 5

useBootFunction · 0.90
useLogContextFunction · 0.90
usePaymentContextFunction · 0.90
useFeatureFunction · 0.90
getMarketingCtaFunction · 0.85

Tested by

no test coverage detected