Skip to content

Commit

Permalink
Fix payment field validation issue
Browse files Browse the repository at this point in the history
The composable that handles the error summary and
form validation on the donation form was watching
a store getter that didn't exist.

This fixes that, and adds tests to make sure the
error summaries and form submits are handled on
all iterations of the donation form.

There was also a message about requiring an email
being displayed to anonymous donors, which is now
removed.
  • Loading branch information
Abban committed Oct 11, 2024
1 parent fe3aba3 commit 28ceff8
Show file tree
Hide file tree
Showing 12 changed files with 1,734 additions and 859 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function usePersonalDataSectionEventHandlers(
}
} );

store.watch( ( state, getters ) => getters[ 'payment/requiredFieldsAreValid' ], ( isValid: boolean ) => {
store.watch( ( state, getters ) => getters[ 'payment/paymentDataIsValid' ], ( isValid: boolean ) => {
if ( !paymentDataIsValid.value && isValid ) {
paymentDataIsValid.value = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
:initial-address-type="addressType"
:address-type-is-invalid="addressTypeIsInvalid"
/>
<div
class="address-type-anonymous-disclaimer"
v-show="!addressTypeIsNotAnon">{{ $t( 'donation_addresstype_option_anonymous_disclaimer' ) }}
</div>
</form>

<AddressForms
Expand Down Expand Up @@ -148,7 +144,6 @@ onMounted( trackDynamicForm );
const {
disabledAddressTypes,
addressType,
addressTypeIsNotAnon,
addressTypeIsInvalid,
addressTypeName,
setAddressType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,13 @@ export function usePersonalDataSectionEventHandlers(
type: store.state.address.addressType,
disallowed: [ AddressTypeModel.UNSET ],
} ),
store.dispatch( action( 'address', 'validateAddress' ), validateAddressUrl ),
store.dispatch( action( 'address', 'validateEmail' ), validateEmailUrl ),
];

if ( store.state.address.addressType !== AddressTypeModel.ANON ) {
validationCalls.push( store.dispatch( action( 'address', 'validateAddress' ), validateAddressUrl ) );
validationCalls.push( store.dispatch( action( 'address', 'validateEmail' ), validateEmailUrl ) );
}

if ( isDirectDebit.value ) {
validationCalls.push( store.dispatch( action( 'bankdata', 'markEmptyFieldsAsInvalid' ) ) );
}
Expand Down Expand Up @@ -93,7 +96,7 @@ export function usePersonalDataSectionEventHandlers(
}
} );

store.watch( ( state, getters ) => getters[ 'payment/requiredFieldsAreValid' ], ( isValid: boolean ) => {
store.watch( ( state, getters ) => getters[ 'payment/paymentDataIsValid' ], ( isValid: boolean ) => {
if ( !paymentDataIsValid.value && isValid ) {
paymentDataIsValid.value = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ const onBlur = ( selectedCountry: Country ) => {
autocompleteIsActive.value = false;
if ( !itemWasJustSelectedFromList ) {
emit( 'field-changed', selectedCountry );
emit( 'field-changed', selectedCountry ?? '' );
}
itemWasJustSelectedFromList = false;
}, 200 );
Expand Down
Loading

0 comments on commit 28ceff8

Please sign in to comment.