({
shouldShowPlusHeader,
}: CommonPlusPageProps)
| 23 | ); |
| 24 | |
| 25 | export 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} |
nothing calls this directly
no test coverage detected