1 import type { ReactNode } from 'react';
3 import { c } from 'ttag';
5 import Icon from '@proton/components/components/icon/Icon';
6 import { type MethodsHook } from '@proton/components/payments/react-extensions';
7 import { PAYMENT_METHOD_TYPES, type PlanIDs } from '@proton/payments';
8 import { type Currency } from '@proton/payments';
9 import { isLifetimePlanSelected } from '@proton/shared/lib/helpers/planIDs';
10 import type { UserModel } from '@proton/shared/lib/interfaces';
12 import CurrencySelector from './CurrencySelector';
14 export interface Props {
15 currencies: readonly Currency[];
17 onChangeCurrency: (newCurrency: Currency) => void;
20 hasGuarantee?: boolean;
21 description?: ReactNode;
22 renewNotice: ReactNode;
23 paymentMethods: MethodsHook;
41 const isSepaDirectDebit = paymentMethods.selectedMethod?.type === PAYMENT_METHOD_TYPES.CHARGEBEE_SEPA_DIRECT_DEBIT;
42 const isLifetimeWithCredits = user.Credit > 0 && isLifetimePlanSelected(planIDs);
44 const disableCurrencySelector = isSepaDirectDebit || isLifetimeWithCredits || loading;
48 <div className="flex flex-nowrap mb-5">
49 <h2 className="h3 text-bold mt-1 mb-0 text-cut flex-1">{c('Title').t`Summary`}</h2>
50 <span className="shrink-0" data-testid="checkoutCurrencyDropdown">
52 currencies={currencies}
54 onSelect={onChangeCurrency}
56 disabled={disableCurrencySelector}
61 <div className={loading ? 'opacity-50 *:pointer-events-none' : ''}>{children}</div>
62 <div className="text-sm lh-standard">
64 <div className="flex flex-nowrap color-weak">
65 <span className="shrink-0 mr-2">
66 <Icon name="info-circle" size={4} />
68 <span className="flex-1" data-testid="checkout:renew-notice">
73 <div className="flex flex-nowrap color-weak my-2">
74 <span className="shrink-0 mr-2">
75 <Icon name="shield" />
77 <span className="flex-1">{c('Info')
78 .t`Payments are protected with TLS encryption and Swiss privacy laws.`}</span>
81 <div className="flex flex-nowrap color-weak">
82 <span className="shrink-0 mr-2">
85 <span className="flex-1">{c('Info').t`30-day money-back guarantee.`}</span>
94 export default Checkout;