From 251a56039bb6b3a230d537bbc3ab9110b178f4ba Mon Sep 17 00:00:00 2001
From: Jessy Pappachan <32092402+jessy-p@users.noreply.github.com>
Date: Fri, 3 May 2024 13:02:03 +0530
Subject: [PATCH 1/4] Update View Report link of Charges data highlight tile.
(#8766)
Co-authored-by: Jessy
$stripe_billing_migrator
+ wcs_get_subscriptions_for_order( $order )
+ wcs_is_manual_renewal_required()
+ wcs_order_contains_subscription( $order_id )
+ + { __( + 'At least one risk filter needs to be enabled for advanced protection.', + 'woocommerce-payments' + ) } +
+ > ); const SaveFraudProtectionSettingsButton: React.FC = ( { children } ) => { @@ -154,42 +162,66 @@ const FraudProtectionAdvancedSettingsPage: React.FC = () => { .every( Boolean ); }; + const checkAnyRuleFilterEnabled = ( + settings: ProtectionSettingsUI + ): boolean => { + return Object.values( settings ).some( ( setting ) => setting.enabled ); + }; + const handleSaveSettings = () => { - if ( validateSettings( protectionSettingsUI ) ) { - if ( ProtectionLevel.ADVANCED !== currentProtectionLevel ) { - updateProtectionLevel( ProtectionLevel.ADVANCED ); - dispatch( 'core/notices' ).createSuccessNotice( + if ( ! validateSettings( protectionSettingsUI ) ) { + window.scrollTo( { + top: 0, + } ); + return; + } + + if ( ! checkAnyRuleFilterEnabled( protectionSettingsUI ) ) { + if ( ProtectionLevel.BASIC === currentProtectionLevel ) { + dispatch( 'core/notices' ).createErrorNotice( __( - 'Current protection level is set to "advanced".', + 'At least one risk filter needs to be enabled for advanced protection.', 'woocommerce-payments' ) ); + return; } - const settings = writeRuleset( protectionSettingsUI ); + updateProtectionLevel( ProtectionLevel.BASIC ); + dispatch( 'core/notices' ).createErrorNotice( + __( + 'Current protection level is set to "basic". At least one risk filter needs to be enabled for advanced protection.', + 'woocommerce-payments' + ) + ); + } else if ( ProtectionLevel.ADVANCED !== currentProtectionLevel ) { + updateProtectionLevel( ProtectionLevel.ADVANCED ); + dispatch( 'core/notices' ).createSuccessNotice( + __( + 'Current protection level is set to "advanced".', + 'woocommerce-payments' + ) + ); + } - // Persist the AVS verification setting until the account cache is updated locally. - if ( - wcpaySettings?.accountStatus?.fraudProtection - ?.declineOnAVSFailure - ) { - wcpaySettings.accountStatus.fraudProtection.declineOnAVSFailure = settings.some( - ( setting ) => setting.key === 'avs_verification' - ); - } + const settings = writeRuleset( protectionSettingsUI ); - updateAdvancedFraudProtectionSettings( settings ); + // Persist the AVS verification setting until the account cache is updated locally. + if ( + wcpaySettings?.accountStatus?.fraudProtection?.declineOnAVSFailure + ) { + wcpaySettings.accountStatus.fraudProtection.declineOnAVSFailure = settings.some( + ( setting ) => setting.key === 'avs_verification' + ); + } - saveSettings(); + updateAdvancedFraudProtectionSettings( settings ); - recordEvent( 'wcpay_fraud_protection_advanced_settings_saved', { - settings: JSON.stringify( settings ), - } ); - } else { - window.scrollTo( { - top: 0, - } ); - } + saveSettings(); + + recordEvent( 'wcpay_fraud_protection_advanced_settings_saved', { + settings: JSON.stringify( settings ), + } ); }; // Hack to make "Payments > Settings" the active selected menu item. diff --git a/client/settings/fraud-protection/advanced-settings/test/__snapshots__/index.test.tsx.snap b/client/settings/fraud-protection/advanced-settings/test/__snapshots__/index.test.tsx.snap index abd09b5d4c7..dffbf33c6b1 100644 --- a/client/settings/fraud-protection/advanced-settings/test/__snapshots__/index.test.tsx.snap +++ b/client/settings/fraud-protection/advanced-settings/test/__snapshots__/index.test.tsx.snap @@ -66,6 +66,11 @@ Object { > Advanced fraud protection ++ At least one risk filter needs to be enabled for advanced protection. +
+ At least one risk filter needs to be enabled for advanced protection. +
+ At least one risk filter needs to be enabled for advanced protection. +
+ At least one risk filter needs to be enabled for advanced protection. +
+ At least one risk filter needs to be enabled for advanced protection. +
+ At least one risk filter needs to be enabled for advanced protection. +
+ At least one risk filter needs to be enabled for advanced protection. +
+ At least one risk filter needs to be enabled for advanced protection. +