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

Function PlusMobile

packages/shared/src/components/plus/PlusMobile.tsx:25–89  ·  view source on GitHub ↗
({
  shouldShowPlusHeader,
}: CommonPlusPageProps)

Source from the content-addressed store, hash-verified

23);
24
25export const PlusMobile = ({
26 shouldShowPlusHeader,
27}: CommonPlusPageProps): ReactElement => {
28 const router = useRouter();
29 const { giftToUser } = useGiftUserContext();
30 const { productOptions, isOrganization } = usePaymentContext();
31 const [selectedOption, setSelectedOption] = useState<string | null>(null);
32
33 const selectionChange: OpenCheckoutFn = useCallback(({ priceId }) => {
34 setSelectedOption(priceId);
35 }, []);
36
37 const onContinue = useCallback(() => {
38 const query: Record<string, string> = {};
39 if (selectedOption) {
40 query.pid = selectedOption;
41 }
42 if (giftToUser?.id) {
43 query.gift = giftToUser.id;
44 }
45 const params = objectToQueryParams(query);
46
47 router.push(`${plusUrl}/payment?${params}`);
48 }, [router, giftToUser, selectedOption]);
49
50 return (
51 <div
52 className="flex flex-col p-6"
53 ref={(element) => {
54 if (!element) {
55 return;
56 }
57
58 if (productOptions?.[0]?.priceId && !selectedOption) {
59 setSelectedOption(productOptions[0].priceId);
60 }
61 }}
62 >
63 {!giftToUser && <PlusSummerSaleBanner className="mb-6" />}
64 {!giftToUser && (
65 <PlusProductToggle
66 options={[
67 { priceType: PurchaseType.Plus, label: 'Personal' },
68 {
69 priceType: PurchaseType.Organization,
70 label: 'Team',
71 },
72 ]}
73 onSelect={() => setSelectedOption(null)}
74 className="self-start"
75 />
76 )}
77 <PlusInfo
78 productOptions={productOptions ?? []}
79 selectedOption={selectedOption}
80 onChange={selectionChange}
81 onContinue={onContinue}
82 shouldShowPlusHeader={shouldShowPlusHeader}

Callers

nothing calls this directly

Calls 5

useGiftUserContextFunction · 0.90
usePaymentContextFunction · 0.90
objectToQueryParamsFunction · 0.90
pushMethod · 0.80
useRouterFunction · 0.50

Tested by

no test coverage detected