signal-desktop/ts/components/PreferencesDonations.tsx

81 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-06-14 03:38:09 +10:00
// Copyright 2025 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import React from 'react';
2025-06-14 03:38:09 +10:00
import type { MutableRefObject } from 'react';
import type { LocalizerType } from '../types/Util';
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;
isStaging: boolean;
page: Page;
workflow: DonationWorkflow | undefined;
2025-06-14 03:38:09 +10: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,
isStaging,
page,
workflow,
clearWorkflow,
setPage,
submitDonation,
2025-06-14 03:38:09 +10:00
}: PropsType): JSX.Element {
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
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 (
<PreferencesContent
contents={content}
contentsRef={contentsRef}
title={i18n('icu:Preferences__DonateTitle')}
/>
2025-06-14 03:38:09 +10:00
);
}