2025-06-14 03:38:09 +10:00
|
|
|
// Copyright 2025 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
2025-06-27 13:48:50 -07:00
|
|
|
import React from 'react';
|
2025-06-14 03:38:09 +10:00
|
|
|
|
|
|
|
import type { MutableRefObject } from 'react';
|
|
|
|
|
|
|
|
import type { LocalizerType } from '../types/Util';
|
2025-06-27 13:48:50 -07:00
|
|
|
import { Page, PreferencesContent } from './Preferences';
|
|
|
|
import { Button, ButtonVariant } from './Button';
|
|
|
|
import { PreferencesDonateFlow } from './PreferencesDonateFlow';
|
|
|
|
import type { CardDetail, DonationWorkflow } from '../types/Donations';
|
2025-06-14 03:38:09 +10:00
|
|
|
|
|
|
|
type PropsExternalType = {
|
|
|
|
contentsRef: MutableRefObject<HTMLDivElement | null>;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type PropsDataType = {
|
|
|
|
i18n: LocalizerType;
|
2025-06-27 13:48:50 -07:00
|
|
|
isStaging: boolean;
|
|
|
|
page: Page;
|
|
|
|
workflow: DonationWorkflow | undefined;
|
2025-06-14 03:38:09 +10:00
|
|
|
};
|
|
|
|
|
2025-06-27 13:48:50 -07:00
|
|
|
type PropsActionType = {
|
|
|
|
clearWorkflow: () => void;
|
|
|
|
setPage: (page: Page) => void;
|
|
|
|
submitDonation: (options: {
|
|
|
|
currencyType: string;
|
|
|
|
paymentAmount: number;
|
|
|
|
paymentDetail: CardDetail;
|
|
|
|
}) => void;
|
|
|
|
};
|
|
|
|
|
|
|
|
export type PropsType = PropsDataType & PropsActionType & PropsExternalType;
|
2025-06-14 03:38:09 +10:00
|
|
|
|
|
|
|
export function PreferencesDonations({
|
|
|
|
contentsRef,
|
|
|
|
i18n,
|
2025-06-27 13:48:50 -07:00
|
|
|
isStaging,
|
|
|
|
page,
|
|
|
|
workflow,
|
|
|
|
clearWorkflow,
|
|
|
|
setPage,
|
|
|
|
submitDonation,
|
2025-06-14 03:38:09 +10:00
|
|
|
}: PropsType): JSX.Element {
|
2025-06-27 13:48:50 -07:00
|
|
|
if (page === Page.DonationsDonateFlow) {
|
|
|
|
return (
|
|
|
|
<PreferencesDonateFlow
|
|
|
|
contentsRef={contentsRef}
|
|
|
|
i18n={i18n}
|
|
|
|
workflow={workflow}
|
|
|
|
clearWorkflow={clearWorkflow}
|
|
|
|
onBack={() => setPage(Page.Donations)}
|
|
|
|
submitDonation={submitDonation}
|
|
|
|
/>
|
|
|
|
);
|
|
|
|
}
|
2025-06-14 03:38:09 +10:00
|
|
|
|
2025-06-27 13:48:50 -07:00
|
|
|
const content = (
|
|
|
|
<div className="PreferencesDonations">
|
|
|
|
{isStaging && (
|
|
|
|
<Button
|
|
|
|
onClick={() => setPage(Page.DonationsDonateFlow)}
|
|
|
|
variant={ButtonVariant.Primary}
|
|
|
|
>
|
|
|
|
Donate
|
|
|
|
</Button>
|
|
|
|
)}
|
|
|
|
</div>
|
2025-06-14 03:38:09 +10:00
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
2025-06-27 13:48:50 -07:00
|
|
|
<PreferencesContent
|
|
|
|
contents={content}
|
|
|
|
contentsRef={contentsRef}
|
|
|
|
title={i18n('icu:Preferences__DonateTitle')}
|
|
|
|
/>
|
2025-06-14 03:38:09 +10:00
|
|
|
);
|
|
|
|
}
|