Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Convert validation context to data store #6402

Merged
merged 66 commits into from
Jul 1, 2022

Conversation

tarunvijwani
Copy link

@tarunvijwani tarunvijwani commented May 11, 2022

This PR is for moving the validation errors to a @wordpress/data store instead of using context

Changes made in the PR:

  • Added reducer, selectors, actions types, and actions for the validation store.
  • Added test cases for the validation store.
  • Found instances of useValidationContext and refactored them to use the data store.

Testing

Automated Tests

  • Changes in this PR are covered by Automated Tests.

    • Unit tests
    • E2E tests
  • Do not include in the Testing Notes

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Manual Testing

  • Add a Single Product Block to a page and choose a product with multiple attributes (Hoodie is a good one from the sample products set)
  • Go to the page and without selecting any attributes try to add it to your cart.
  • Verify you see errors on each input.
  • Select an option and ensure the error message disappears as soon as you do.
  • Add to cart and verify it is successful.
  • Create a page with the Cart Block on it, ensure the Shipping Calculator is enabled.
  • Add items to your cart and visit the Cart Block.
  • Use the shipping calculator, leave the free text fields blank, ensure validation errors appear.
  • Try to calculate shipping with validation errors present. Ensure the form doesn't submit.
  • Fix the validation errors, ensure the form submits and the address updates.
  • Add a coupon to your store.
  • Add an item to your cart and go to the Cart Block
  • Use the coupon input and enter an invalid coupon, try to apply it.
  • Ensure an error appears.
  • Type into the coupon box again and ensure the error disappears.
  • Type a valid coupon code and ensure it submits and the discount is applied to your cart.
  • Add the Checkout Block to a page, on the Shipping Address Block set require phone number to true.
  • In an incognito window add items to your cart and go to the Checkout Block.
  • Immediately press the Place order button.
  • Ensure the invalid fields in the form are highlighted.
  • Fill in your details, enter invalid data in each field (fill and then empty again in all cases) and ensure the ones that require validation show you errors.
  • You should see errors like this:
  • image
  • While errors are present, try to proceed with checkout. Ensure you cannot proceed by pressing the place order button until the errors are fixed.
  • Install the Stripe extension and set it up.
  • Go to the Cart Block and enter some invalid card details in the Stripe form.
  • Ensure you see validation errors on each field:

image

@tarunvijwani tarunvijwani added status: needs review type: enhancement The issue is a request for an enhancement. skip-changelog PRs that you don't want to appear in the changelog. type: task The issue is an internally driven task (e.g. from another A8c team). labels May 11, 2022
@tarunvijwani tarunvijwani requested a review from opr May 11, 2022 11:46
@tarunvijwani tarunvijwani self-assigned this May 11, 2022
@rubikuserbot rubikuserbot requested a review from a team May 11, 2022 11:47
@github-actions
Copy link
Contributor

github-actions bot commented May 11, 2022

Size Change: -1.61 kB (0%)

Total Size: 862 kB

Filename Size Change
build/active-filters-frontend.js 7.26 kB +7 B (0%)
build/active-filters.js 7.92 kB +5 B (0%)
build/all-products-frontend.js 18.1 kB -1 B (0%)
build/all-products.js 33.1 kB -304 B (-1%)
build/all-reviews.js 7.8 kB +3 B (0%)
build/attribute-filter-frontend.js 25 kB +3 B (0%)
build/attribute-filter.js 14.2 kB +6 B (0%)
build/blocks-checkout.js 17.5 kB +2 B (0%)
build/cart-blocks/cart-accepted-payment-methods-frontend.js 1.16 kB -1 B (0%)
build/cart-blocks/cart-express-payment-frontend.js 5.22 kB +37 B (+1%)
build/cart-blocks/cart-line-items--mini-cart-contents-block/products-table-frontend.js 5.26 kB -6 B (0%)
build/cart-blocks/cart-line-items-frontend.js 431 B -1 B (0%)
build/cart-blocks/cart-order-summary-frontend.js 1.1 kB -2 B (0%)
build/cart-blocks/empty-cart-frontend.js 346 B -1 B (0%)
build/cart-blocks/order-summary-coupon-form-frontend.js 2.71 kB +90 B (+3%)
build/cart-blocks/order-summary-discount-frontend.js 2.13 kB +9 B (0%)
build/cart-blocks/order-summary-heading-frontend.js 455 B +1 B (0%)
build/cart-blocks/order-summary-shipping--checkout-blocks/order-summary-shipping-frontend.js 6.51 kB +172 B (+3%)
build/cart-blocks/order-summary-subtotal-frontend.js 273 B +1 B (0%)
build/cart-blocks/proceed-to-checkout-frontend.js 1.19 kB +2 B (0%)
build/cart-frontend.js 43.2 kB -412 B (-1%)
build/cart.js 42.3 kB -202 B (0%)
build/checkout-blocks/actions-frontend.js 1.51 kB -4 B (0%)
build/checkout-blocks/billing-address--checkout-blocks/shipping-address-frontend.js 4.29 kB +121 B (+3%)
build/checkout-blocks/billing-address-frontend.js 929 B -1 B (0%)
build/checkout-blocks/contact-information-frontend.js 3 kB +92 B (+3%)
build/checkout-blocks/express-payment-frontend.js 5.53 kB +46 B (+1%)
build/checkout-blocks/order-summary-cart-items-frontend.js 3.65 kB -5 B (0%)
build/checkout-blocks/order-summary-coupon-form-frontend.js 2.87 kB +94 B (+3%)
build/checkout-blocks/order-summary-discount-frontend.js 2.26 kB +7 B (0%)
build/checkout-blocks/order-summary-shipping-frontend.js 603 B +1 B (0%)
build/checkout-blocks/payment-frontend.js 7.8 kB +53 B (+1%)
build/checkout-blocks/shipping-address-frontend.js 1.03 kB -2 B (0%)
build/checkout-blocks/shipping-methods-frontend.js 4.79 kB +3 B (0%)
build/checkout-blocks/terms-frontend.js 1.32 kB +3 B (0%)
build/checkout-frontend.js 45.6 kB -308 B (-1%)
build/checkout.js 43.6 kB -205 B (0%)
build/featured-category.js 13.2 kB +8 B (0%)
build/featured-product.js 13.5 kB +11 B (0%)
build/handpicked-products.js 7.37 kB +4 B (0%)
build/legacy-template.js 2.45 kB -2 B (0%)
build/mini-cart-component-frontend.js 16.6 kB -7 B (0%)
build/mini-cart-contents-block/footer-frontend.js 6.67 kB -381 B (-5%)
build/mini-cart-contents-block/items-frontend.js 225 B -1 B (0%)
build/mini-cart-contents-block/shopping-button-frontend.js 287 B -1 B (0%)
build/mini-cart-contents.js 19.7 kB -407 B (-2%)
build/mini-cart.js 6.62 kB -1 B (0%)
build/price-filter-frontend.js 13 kB -2 B (0%)
build/price-filter.js 9 kB +6 B (0%)
build/product-add-to-cart--product-button--product-category-list--product-image--product-price--product-r--a0326d00.js 223 B +1 B (0%)
build/product-add-to-cart--product-button--product-image--product-title.js 2.63 kB -1 B (0%)
build/product-add-to-cart-frontend.js 6.66 kB -289 B (-4%)
build/product-add-to-cart.js 6.33 kB -291 B (-4%)
build/product-button--product-category-list--product-image--product-price--product-rating--product-sale-b--e17c7c01.js 501 B +1 B (0%)
build/product-button-frontend.js 1.84 kB -4 B (0%)
build/product-categories.js 2.78 kB +2 B (0%)
build/product-category-list-frontend.js 922 B -2 B (0%)
build/product-category-list.js 501 B -1 B (0%)
build/product-category.js 8.53 kB +3 B (0%)
build/product-image-frontend.js 1.84 kB -3 B (0%)
build/product-image.js 1.07 kB -1 B (0%)
build/product-new.js 7.71 kB +2 B (0%)
build/product-on-sale.js 8.04 kB +7 B (0%)
build/product-price-frontend.js 1.93 kB -14 B (-1%)
build/product-price.js 1.5 kB -4 B (0%)
build/product-rating-frontend.js 1.15 kB -3 B (0%)
build/product-rating.js 735 B +4 B (+1%)
build/product-sale-badge.js 679 B -1 B (0%)
build/product-sku-frontend.js 380 B -1 B (0%)
build/product-stock-indicator-frontend.js 1.03 kB -1 B (0%)
build/product-stock-indicator.js 621 B +1 B (0%)
build/product-summary.js 916 B -2 B (0%)
build/product-tag-list-frontend.js 917 B -1 B (0%)
build/product-tag.js 8.09 kB +2 B (0%)
build/product-title-frontend.js 1.29 kB -3 B (0%)
build/product-top-rated.js 7.95 kB +1 B (0%)
build/products-by-attribute.js 8.63 kB +7 B (0%)
build/reviews-by-category.js 11.2 kB +5 B (0%)
build/reviews-by-product.js 12.3 kB -2 B (0%)
build/reviews-frontend.js 7.01 kB -1 B (0%)
build/single-product-frontend.js 21.4 kB +4 B (0%)
build/single-product.js 10 kB +8 B (0%)
build/stock-filter-frontend.js 7.35 kB +2 B (0%)
build/stock-filter.js 7.26 kB +9 B (0%)
build/vendors--cart-blocks/cart-line-items--cart-blocks/cart-order-summary--cart-blocks/order-summary-shi--c02aad66-frontend.js 5.26 kB -1 B (0%)
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--5b8feb0b-frontend.js 4.74 kB +4 B (0%)
build/vendors--cart-blocks/order-summary-shipping--checkout-blocks/billing-address--checkout-blocks/order--decc3dc6-frontend.js 20.5 kB +3 B (0%)
build/vendors--mini-cart-contents-block/footer-frontend.js 6.86 kB -1 B (0%)
build/vendors--product-add-to-cart-frontend.js 7.54 kB +3 B (0%)
build/wc-blocks-data.js 13.2 kB +412 B (+3%)
build/wc-blocks-style-rtl.css 22.1 kB -4 B (0%)
build/wc-blocks-style.css 22.1 kB -4 B (0%)
build/wc-blocks-vendors.js 59 kB +7 B (0%)
build/wc-blocks.js 2.63 kB +3 B (0%)
ℹ️ View Unchanged
Filename Size
build/cart-blocks/cart-items-frontend.js 299 B
build/cart-blocks/cart-totals-frontend.js 322 B
build/cart-blocks/filled-cart-frontend.js 782 B
build/cart-blocks/order-summary-fee-frontend.js 272 B
build/cart-blocks/order-summary-shipping-frontend.js 427 B
build/cart-blocks/order-summary-taxes-frontend.js 433 B
build/checkout-blocks/fields-frontend.js 345 B
build/checkout-blocks/order-note-frontend.js 1.13 kB
build/checkout-blocks/order-summary-fee-frontend.js 275 B
build/checkout-blocks/order-summary-frontend.js 1.11 kB
build/checkout-blocks/order-summary-subtotal-frontend.js 273 B
build/checkout-blocks/order-summary-taxes-frontend.js 433 B
build/checkout-blocks/totals-frontend.js 326 B
build/mini-cart-contents-block/empty-cart-frontend.js 365 B
build/mini-cart-contents-block/filled-cart-frontend.js 229 B
build/mini-cart-contents-block/products-table-frontend.js 590 B
build/mini-cart-contents-block/title-frontend.js 367 B
build/mini-cart-frontend.js 1.72 kB
build/price-format.js 1.19 kB
build/product-add-to-cart--product-button.js 564 B
build/product-best-sellers.js 7.43 kB
build/product-button.js 1.09 kB
build/product-sale-badge-frontend.js 1.09 kB
build/product-search.js 2.18 kB
build/product-sku.js 381 B
build/product-summary-frontend.js 1.33 kB
build/product-tag-list.js 495 B
build/product-title.js 911 B
build/vendors--cart-blocks/cart-line-items--checkout-blocks/order-summary-cart-items--mini-cart-contents---233ab542-frontend.js 3.14 kB
build/wc-blocks-editor-style-rtl.css 5.08 kB
build/wc-blocks-editor-style.css 5.08 kB
build/wc-blocks-google-analytics.js 1.56 kB
build/wc-blocks-middleware.js 930 B
build/wc-blocks-registry.js 2.7 kB
build/wc-blocks-shared-context.js 1.53 kB
build/wc-blocks-shared-hocs.js 1.14 kB
build/wc-blocks-vendors-style-rtl.css 1.28 kB
build/wc-blocks-vendors-style.css 1.28 kB
build/wc-payment-method-bacs.js 816 B
build/wc-payment-method-cheque.js 811 B
build/wc-payment-method-cod.js 909 B
build/wc-payment-method-paypal.js 837 B
build/wc-settings.js 2.61 kB

compressed-size-action

Copy link
Member

@alexflorisca alexflorisca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work Tarun 👏 ! Laying down some good foundations. I left a few comments inline for a few potential improvements

! isString( action.error ) ||
! state.hasOwnProperty( action.error )
) {
return state;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this filter based on hidden: false here? Otherwise we would also show the validation errors that are set to be hidden.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure I follow your question, this action SHOW_VALIDATION_ERROR sets hidden to be false on an error in the store, so the point of this is to show hidden ones, the checks above are for ensuring the error actually exists in the store.

} );
//Checks if it display a single error
it( 'Show single validation error', () => {
const state = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to add 2 more errors to the state here that have { hidden: false } to test wether this action will also hide any errors that are currently visible, and only show the specified one

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not the goal of this action actually, it's just to change whether a specific action is hidden or not. But good idea to add a visible one and ensure it remains visible after this action is applied to a different error!

//Test suite for validation selectors
describe( 'Validation selectors', () => {
//Checks if it get existing validation error
it( 'Can get the validation error', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would include the name of the selector we are testing in the test description in these tests to make it a bit clearer

expect( validationErrorID ).toEqual( `validate-error-validationError` );
} );
//Checks if state has validation error
it( 'Can check if state has any validation errors', () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test would pass if I changed the hasValidationErrors() function to always return true. Let's test the other option here as well and check that it returns false when there are no validation errors in the state

@@ -0,0 +1,238 @@
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's convert this file to TypeScript as we are moving to using TS throughout the codebase

@@ -0,0 +1,51 @@
/**
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's convert this file to TS as well

@opr opr force-pushed the fix/wpdata-validation branch from 2523161 to 67509d0 Compare June 6, 2022 13:54
@opr opr force-pushed the try/move-validation-to-wpdata branch from ffad257 to d95e3a3 Compare June 6, 2022 14:19
@opr opr assigned opr and unassigned tarunvijwani Jun 6, 2022
@opr opr changed the base branch from try/move-validation-to-wpdata to trunk June 6, 2022 17:39
@opr
Copy link
Contributor

opr commented Jun 7, 2022

@tarunvijwani - I've been working on this and I have updated the main PR description to include testing steps for what I changes! Thanks for your initial work on this PR, it was invaluable!

@opr opr requested review from alexflorisca and senadir June 7, 2022 01:05
@tarunvijwani
Copy link
Author

@tarunvijwani - I've been working on this and I have updated the main PR description to include testing steps for what I changes! Thanks for your initial work on this PR, it was invaluable!

@opr Thank you for working on this! 👍

@tarhi-saad tarhi-saad self-requested a review June 23, 2022 12:42
@alexflorisca alexflorisca mentioned this pull request Jun 24, 2022
18 tasks
@senadir senadir requested review from a team and removed request for senadir and a team June 25, 2022 00:39
@tarhi-saad tarhi-saad changed the base branch from trunk to feature/data-store-refactor June 27, 2022 14:26
Copy link
Contributor

@tarhi-saad tarhi-saad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, @opr, for this fantastic PR! You did an excellent job! I did review & test the changes thoroughly, and everything is working as expected. Below are some minor fixes to apply before merging our PR!

assets/js/data/validation/index.ts Outdated Show resolved Hide resolved
assets/js/base/components/validation-input-error/index.tsx Outdated Show resolved Hide resolved
assets/js/data/validation/test/reducers.ts Outdated Show resolved Hide resolved
assets/js/data/validation/test/selectors.ts Outdated Show resolved Hide resolved
@opr opr force-pushed the fix/wpdata-validation branch 2 times, most recently from 412c3de to b90fe27 Compare June 29, 2022 01:11
@tarhi-saad tarhi-saad force-pushed the fix/wpdata-validation branch from b90fe27 to 1cc0985 Compare June 30, 2022 12:37
@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2022

Gutenberg with Thunks was released in WP 6.0.

Gutenberg with Thunks was released in WP 6.0. Once 6.1 is released, remove the experimental flag here eslint-disable-next-line @typescript-eslint/ban-ts-comment


// TODO: Gutenberg with Thunks was released in WP 6.0. Once 6.1 is released, remove the experimental flag here
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore We pass this in case there is an older version of Gutenberg running.
__experimentalUseThunks: true,
};
const store = createReduxStore( STORE_KEY, config );
register( store );
export const VALIDATION_STORE_KEY = STORE_KEY;
declare module '@wordpress/data' {
function dispatch(

🚀 This comment was generated by the automations bot based on a todo comment in 570455d in #6402. cc @tarunvijwani

@tarhi-saad tarhi-saad merged commit 6b4dd69 into feature/data-store-refactor Jul 1, 2022
@tarhi-saad tarhi-saad deleted the fix/wpdata-validation branch July 1, 2022 23:06
@opr opr restored the fix/wpdata-validation branch July 27, 2022 08:54
opr added a commit that referenced this pull request Aug 23, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
opr added a commit that referenced this pull request Aug 24, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
opr added a commit that referenced this pull request Aug 25, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
opr added a commit that referenced this pull request Sep 5, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
opr added a commit that referenced this pull request Sep 5, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
opr added a commit that referenced this pull request Sep 15, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
alexflorisca pushed a commit that referenced this pull request Sep 28, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
alexflorisca pushed a commit that referenced this pull request Sep 28, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
alexflorisca pushed a commit that referenced this pull request Sep 28, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
senadir pushed a commit to senadir/woocommerce-blocks that referenced this pull request Nov 12, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
senadir pushed a commit to senadir/woocommerce-blocks that referenced this pull request Nov 12, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
senadir pushed a commit to senadir/woocommerce-blocks that referenced this pull request Nov 20, 2022
* Add validation reducers, actions, and action types

* Add selector for getValidationErrors

* Export store key and register store

* Export validation store key

* Move TextInput files to checkout package

* Export ValidatedTextInput from blocks-checkout package

* Update imports of ValidatedTextInput to reflect new location

* Use the validation wp-data store for showing error messages

* Export getValidationError in checkout package

* Move validation store to checkout package

* Move ValidationInputError to blocks-checkout package

* Only export "exposedSelectors" from validation

* Convert validation context to data store

* Fixed linting error

* Fixed linting error

* Change the validation selectors to return a function

* Convert reducer and selectors to TS

* Remove superfluous comments and improve test titles

* Test to ensure visible errors remain visible

* Make test for hasValidationErrors more robust

* Augment the wp-data module to include our selectors and actions

* Removed unused `exposedSelectors` variable

* Remove TS error because of `instanceId` on props

* Remove unnecessary as const

* Use function returned by getValidationError

* Use correct selector/action names now context has been decoupled

* hide validation error when input value changes

* Add correct aria-describedBy now we can get error id from store

* Clear validation error from store when component unmounts

* Clear validation error if input is valid

* convert ValidationInputError to TS and get correct id/error from store

* Ensure checkout block doesn't break when there are no errors

* Get validation data from the store instead of context

* Update country input to remove validation context

* Move validation store out of checkout package

* Move TextInput and ValidationInputError back out of the checkout package

* Remove duplicate internal styles comment

* Remove exports that no longer exist

* Get validation store key from block-data

* Make attribute-select-control use validation data store

* Export FieldValidationStatus type

* Make combobox use validation store not context

* Make Address use validation store not context

* Make Address use validation store not context

* Use hasValidationErrors selector as a function in shipping calculator

* Remove validation context from coupon story

* Import VALIDATION_STORE_KEY from correct location

* Stop coupon story from erroring

* Update useStoreCartCoupons to use validation store not context

* Make TotalsCoupon use validation store instead of context

* Make AddToCartFormContext use validation store not context

* Remove ValidationContext

* Import FieldValidationStatus from correct location

* Import ValidatedTextInput and ValidatedTextInput from correct location

* Remove ValidationContextProvider

* Update components to use validation store not context

* Update useValidation to use the data store

* Replace the validation context in checkout-events file

* Use the re-mapped path for the store key import

* Use "register" instead of the deprecated "registerStore"

* Fix import error of the "FieldValidationStatus" type

* Use TS instead of React's "PropTypes"

* Fix the type of "ValidationInputError" in the "payment-method-interface"

* Fix error not showing on the first place order click bug

We were mutating the state in the reducer, which prevented re-rendering
on state change

* Fix state mutation issue in the Validation reducer

Co-authored-by: Thomas Roberts <[email protected]>
Co-authored-by: Saad Tarhi <[email protected]>
@nielslange nielslange deleted the fix/wpdata-validation branch April 19, 2023 23:47
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
skip-changelog PRs that you don't want to appear in the changelog. type: enhancement The issue is a request for an enhancement. type: task The issue is an internally driven task (e.g. from another A8c team).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants