Update text in donations discard dialog

Co-authored-by: ayumi-signal <143036029+ayumi-signal@users.noreply.github.com>
This commit is contained in:
automated-signal
2025-08-29 11:52:29 -05:00
committed by GitHub
parent b218946064
commit a8ad80f205
5 changed files with 55 additions and 10 deletions

View File

@@ -8982,6 +8982,14 @@
"messageformat": "The minimum amount you can donate is {formattedCurrencyAmount}", "messageformat": "The minimum amount you can donate is {formattedCurrencyAmount}",
"description": "Tooltip for a disabled continue button when selecting a donation amount, when the user has entered a custom amount below the minimum allowed donation amount. Minimum amount text includes the currency symbol and is formatted in the locale's standard format. Examples: $3; ¥300; €3" "description": "Tooltip for a disabled continue button when selecting a donation amount, when the user has entered a custom amount below the minimum allowed donation amount. Minimum amount text includes the currency symbol and is formatted in the locale's standard format. Examples: $3; ¥300; €3"
}, },
"icu:DonateFlow__discard-dialog-body": {
"messageformat": "Leaving this page will remove your credit card information. Do you want to proceed?",
"description": "While making a donation and after entering payment details, if you try to navigate away then a dialog shows with this body text."
},
"icu:DonateFlow__discard-dialog-remove-info": {
"messageformat": "Remove info",
"description": "While making a donation and after entering payment details, if you try to navigate away then a dialog shows and its primary button has this text to confirm cancellation of the donation."
},
"icu:DonationReceipt__title": { "icu:DonationReceipt__title": {
"messageformat": "Donation receipt", "messageformat": "Donation receipt",
"description": "Title shown at the top of donation receipt documents" "description": "Title shown at the top of donation receipt documents"

View File

@@ -5,21 +5,40 @@ import React from 'react';
import { action } from '@storybook/addon-actions'; import { action } from '@storybook/addon-actions';
import type { Meta } from '@storybook/react'; import type { Meta } from '@storybook/react';
import type { PropsType } from './ConfirmDiscardDialog'; import type { ConfirmDialogProps } from './ConfirmDiscardDialog';
import { ConfirmDiscardDialog } from './ConfirmDiscardDialog'; import { ConfirmDiscardDialog } from './ConfirmDiscardDialog';
const { i18n } = window.SignalContext; const { i18n } = window.SignalContext;
const createProps = (): PropsType => ({ const createProps = ({
bodyText,
discardText,
}: {
bodyText?: string;
discardText?: string;
} = {}): ConfirmDialogProps => ({
i18n, i18n,
bodyText,
discardText,
onClose: action('onClose'), onClose: action('onClose'),
onDiscard: action('onDiscard'), onDiscard: action('onDiscard'),
}); });
export default { export default {
title: 'Components/ConfirmDiscardDialog', title: 'Components/ConfirmDiscardDialog',
} satisfies Meta<PropsType>; } satisfies Meta<ConfirmDialogProps>;
export function Default(): JSX.Element { export function Default(): JSX.Element {
return <ConfirmDiscardDialog {...createProps()} />; return <ConfirmDiscardDialog {...createProps()} />;
} }
export function DonateFlow(): JSX.Element {
return (
<ConfirmDiscardDialog
{...createProps({
bodyText: i18n('icu:DonateFlow__discard-dialog-body'),
discardText: i18n('icu:DonateFlow__discard-dialog-remove-info'),
})}
/>
);
}

View File

@@ -5,31 +5,35 @@ import React from 'react';
import { ConfirmationDialog } from './ConfirmationDialog'; import { ConfirmationDialog } from './ConfirmationDialog';
import type { LocalizerType } from '../types/Util'; import type { LocalizerType } from '../types/Util';
export type PropsType = { export type ConfirmDialogProps = {
i18n: LocalizerType; i18n: LocalizerType;
bodyText?: string;
discardText?: string;
onClose: () => unknown; onClose: () => unknown;
onDiscard: () => unknown; onDiscard: () => unknown;
}; };
export function ConfirmDiscardDialog({ export function ConfirmDiscardDialog({
i18n, i18n,
bodyText,
discardText,
onClose, onClose,
onDiscard, onDiscard,
}: PropsType): JSX.Element { }: ConfirmDialogProps): JSX.Element {
return ( return (
<ConfirmationDialog <ConfirmationDialog
dialogName="ConfirmDiscardDialog" dialogName="ConfirmDiscardDialog"
actions={[ actions={[
{ {
action: onDiscard, action: onDiscard,
text: i18n('icu:discard'), text: discardText ?? i18n('icu:discard'),
style: 'negative', style: 'negative',
}, },
]} ]}
i18n={i18n} i18n={i18n}
onClose={onClose} onClose={onClose}
> >
{i18n('icu:ConfirmDiscardDialog--discard')} {bodyText ?? i18n('icu:ConfirmDiscardDialog--discard')}
</ConfirmationDialog> </ConfirmationDialog>
); );
} }

View File

@@ -122,6 +122,8 @@ export function PreferencesDonateFlow({
const tryClose = useRef<() => void | undefined>(); const tryClose = useRef<() => void | undefined>();
const [confirmDiscardModal, confirmDiscardIf] = useConfirmDiscard({ const [confirmDiscardModal, confirmDiscardIf] = useConfirmDiscard({
i18n, i18n,
bodyText: i18n('icu:DonateFlow__discard-dialog-body'),
discardText: i18n('icu:DonateFlow__discard-dialog-remove-info'),
name: 'PreferencesDonateFlow', name: 'PreferencesDonateFlow',
tryClose, tryClose,
}); });

View File

@@ -10,24 +10,36 @@ import {
type ExplodePromiseResultType, type ExplodePromiseResultType,
} from '../util/explodePromise'; } from '../util/explodePromise';
import type { PropsType } from '../components/ConfirmDiscardDialog'; import type { ConfirmDialogProps } from '../components/ConfirmDiscardDialog';
import type { LocalizerType } from '../types/Util'; import type { LocalizerType } from '../types/Util';
export function useConfirmDiscard({ export function useConfirmDiscard({
i18n, i18n,
bodyText,
discardText,
name, name,
tryClose, tryClose,
}: { }: {
i18n: LocalizerType; i18n: LocalizerType;
bodyText?: string;
discardText?: string;
name: string; name: string;
tryClose?: React.MutableRefObject<(() => void) | undefined>; tryClose?: React.MutableRefObject<(() => void) | undefined>;
}): [ }): [
JSX.Element | null, JSX.Element | null,
(condition: boolean, discardChanges: () => void, cancel?: () => void) => void, (condition: boolean, discardChanges: () => void, cancel?: () => void) => void,
] { ] {
const [props, setProps] = useState<Omit<PropsType, 'i18n'> | null>(null); const [props, setProps] = useState<Omit<
ConfirmDialogProps,
'i18n' | 'bodyText' | 'discardText'
> | null>(null);
const confirmElement = props ? ( const confirmElement = props ? (
<ConfirmDiscardDialog i18n={i18n} {...props} /> <ConfirmDiscardDialog
i18n={i18n}
bodyText={bodyText}
discardText={discardText}
{...props}
/>
) : null; ) : null;
const confirmDiscardPromise = useRef< const confirmDiscardPromise = useRef<
ExplodePromiseResultType<BeforeNavigateResponse> | undefined ExplodePromiseResultType<BeforeNavigateResponse> | undefined