import { __ } from "@wordpress/i18n"; import { createInterpolateElement } from '@wordpress/element'; import classnames from 'classnames'; import { CheckCircleIcon, HandHeartIcon, XCircleIcon } from "./icons"; import styles from "./styles.module.scss"; /** * Utility function to capitalize the first letter of a string * * @since 4.8.0 * @param str - The string to capitalize * @returns The string with first letter capitalized */ const capitalizeFirstLetter = (str: string): string => { if (!str) return str; return str.charAt(0).toUpperCase() + str.slice(1).toLowerCase(); }; /** * @since 4.8.0 */ type SyncDetailsProps = { isAccurate: boolean; platform: string; gateway: string; } /** * @since 4.8.0 */ export default function SyncDetails({ isAccurate, platform, gateway }: SyncDetailsProps) { if(isAccurate) { return (

{__('Platform', 'give')}

{platform ? capitalizeFirstLetter(platform) : __('Completed', 'give')}

{__('Gateway', 'give')}

{gateway ? capitalizeFirstLetter(gateway) : __('Completed', 'give')}

) } return (

{__('OLD', 'give')}

{__('Platform', 'give')}

{capitalizeFirstLetter(platform)}

{__('Gateway', 'give')}

{capitalizeFirstLetter(gateway)}

{__('NEW', 'give')}

{__('Platform', 'give')}

{capitalizeFirstLetter(gateway)}

{__('Gateway', 'give')}

{capitalizeFirstLetter(gateway)}

); } /** * @since 4.8.0 */ type SyncPaymentDetailsProps = { payment: { gatewayTransactionId: string; id: number; amount: string; createdAt: string; status: string; type: string; } | null; isAccurate?: boolean; platform?: string; gateway?: string; } /** * @since 4.8.0 */ export function SyncPaymentDetails({ payment, platform, gateway, isAccurate }: SyncPaymentDetailsProps) { if(isAccurate) { return (

{__('Platform', 'give')}

{platform ? capitalizeFirstLetter(platform) : __('Completed', 'give')}

{__('Gateway', 'give')}

{gateway ? capitalizeFirstLetter(gateway) : __('Completed', 'give')}

) } const PaymentAmount = () => ( {payment?.amount} ); const description = createInterpolateElement( __('A donation of has been added.', 'give'), { PaymentAmount: } ); return (

{description}

{payment?.createdAt}

); }