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

Function PlusMobile

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected