Commit Graph

665 Commits

Author SHA1 Message Date
Albert Juhé Lluveras 73d1432b02 Hook up checkout validation with context (https://github.com/woocommerce/woocommerce-blocks/pull/2033)
* Hook up checkout validation with context

* Make sure hasValidationErrors is up to date in onCheckoutProcessing

* Move validation check inside CheckoutProcessor's processCheckout

* Make sure all checkout form fields have a unique ID

* Don't clear checkout context errors in shipping context

* Move CheckoutProcessor to the top so scrollToTop works

* Do not disable Place Order Button if there are errors

* Split checkValidation and processCheckout in Checkout Provider

* Refactor event emitter to use Maps

* Save payment method errors to validation context

* Show an notice when a payment method has an error

* Make sure JS errors during payment are displayed

* Remove error notice when payment method doesn't return an error anymore

* Make sure payment methods know if shipping and billing addresses are the same

* Make sure checkout is only processed if payment methods didn't fail

* Make sure state input also has an id

* Clear input and select errors on unmount

* Pass id to CountryInput and StateInput

* Fix function name

* Add missing default context values

* Move onCheckoutCompleteError effect to CheckoutBlock

* Remove conditional from shipping setHasError
2020-04-02 11:27:54 +02:00
Darren Ethier b0370b44b9 split up payment-methods.js file into smaller bits (https://github.com/woocommerce/woocommerce-blocks/pull/2089)
- adds more inline docs
- improves/adds more type-defs
2020-04-01 10:58:50 -04:00
Darren Ethier 2d53b2ace1 Refactor checkout context provider to be more flexible and implement CartProvider (https://github.com/woocommerce/woocommerce-blocks/pull/2083)
* Rename and move existing checkout provider to checkout-state provider.

This allows us to re-use the interface exposed on this provider for cart and checkout blocks.

* refactor checkout provider to implement the new checkout state provider.

* Add Cart provider and export

* fix type-defs

* fix editor context provider and ensure all `isEditor` checks come from this provider

* fix type definition

* implement cart provider
2020-04-01 05:27:53 -04:00
Darren Ethier df851aaff3 refactor checkout error status dispatcher (https://github.com/woocommerce/woocommerce-blocks/pull/2082)
- setHasError now receives a boolean that determines what state to set.
- remove clearError dispatcher
- fix related type-defs in checkout context.
2020-03-31 15:28:36 -04:00
Mike Jolley 9b0f545398 Parse error response before rejecting (https://github.com/woocommerce/woocommerce-blocks/pull/2080) 2020-03-31 17:00:03 +01:00
Darren Ethier d3fdc4b358 Finish wiring up shipping data context provider and add disabled state to checkout submit button (https://github.com/woocommerce/woocommerce-blocks/pull/2070)
* add selecting rate resolution state to the cart store

* expose whether rate is being selected on useSelectShippingRate

* Cleanup and refactor ShippingDataProvider

- remove un-needed component and move shipping rates into context provider
- remove error handling (currently the ui/ux for the checkout should result in no errors and any api errors are non-recoverable).
- Add logic for shipping rate selection into context provider and add event emitters for it.
- increment/decrement checkout calculation counts when shipping rates are being selected.

* dispatch checkout error if there is an error

* disable place order button if checkout is calculating or has error

* update doc block

* fix convention for js comment blocks
2020-03-31 11:40:27 -04:00
Albert Juhé Lluveras 8bac7b8264 Fix minor Stripe payment method issues (https://github.com/woocommerce/woocommerce-blocks/pull/2078)
* Fix params mismatch in Stripe

* Wrap Strip onSubmit with a try/catch block

* Fix createSource signature
2020-03-31 15:21:54 +02:00
Seghir Nadir 0046b73bbf delete passed arg to useShippingRates since it's not needed 2020-03-31 13:22:41 +01:00
Mike Jolley 61a5b7b132 Add checkout error state (https://github.com/woocommerce/woocommerce-blocks/pull/2069)
* Add checkout error state

* Update message wording and icon
2020-03-31 11:47:48 +01:00
Albert Juhé Lluveras 140bdc39d0 Add tests to some cart and checkout hooks (https://github.com/woocommerce/woocommerce-blocks/pull/2013) 2020-03-30 20:32:28 +02:00
Mike Jolley 2bca9840c6 Checkout processing and order creation APIs (https://github.com/woocommerce/woocommerce-blocks/pull/2044)
* CheckoutProcessing work

add missing memoization and implement useRef strategically

This prevents effects from firing unnecessarily.

Tweak assets registration

Order hydration and checkout/ endpoint updates

Fix error handling

Error handling

* Missing isset in stripe

* Fedeback

* rename draft order ID action

* Todos
2020-03-30 15:32:23 +01:00
Albert Juhé Lluveras 5e78c47e4d Move some base components to subfolders (https://github.com/woocommerce/woocommerce-blocks/pull/2034) 2020-03-30 15:04:27 +02:00
Albert Juhé Lluveras e6f6dc9915 Cart and Checkout accessibility fixes (https://github.com/woocommerce/woocommerce-blocks/pull/2041)
* Make Product Price component accessible

* Render checkout form step number before the content instead of after

* Announce changes in the Shipping Rates Control results

* Render product name before product price in the Checkout sidebar

* Verify error element id exists before using it in describedBy

* Avoid reading 'Choose a shipping method' if no shipping methods are available

* Hide product image from screen readers if there is no alt text and make link not focusable

* Move Checkout block buttons below the sidebar

* Simplify selector

* Remove ternary to make code easier to understand

* Fix rebase issue

* Fix step number not visible for payment methods
2020-03-30 14:43:42 +02:00
Darren Ethier fb3cae67e6 Implement Stripe CC and Stripe ApplePay payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/1983)
* Server side changes for payment method integrations

Including adding a stripe class temporarily

* update needed npm packages (and add some types)

* updates to contexts

* remove stepContent from payment config for payment methods

* update payment method interface and typedefs

Exposing a components property to pass along components that payment methods can use (so we keep styles consistent for them)

* add apple pay and stripe cc integration and remove paypal

* remove save payment checkbox from checkout block

It is handled by payment methods.

* Include an id prop for tabs

* fix activePaymentMethod pass through on rendered payment method element

also adds an id for the rendered tab

* add styles for payment method fields

If payment methods use these classes for their fields then the styles will get applied. It _could_ allow for consistent styling, we may have to provide design documentation for this?

These are styles in cases where payment methods have to use elements provided by the gateway (eg. Stripe elements). In future iterations we could look at providing components to payment methods to use (if they aren’t restricted by the gateway).

* fix rebase conflict

* do a test payment request for applePay to determine if the current browser supports it

* don’t console.error for stripe loading.

* Fix placeholder errors in the editor

* improve styling and add missing validation for inline card element

* update pacakge-lock

* rename payment-methods-demo folder to payment-methods-extension

* expose checkbox control on payment method interface

* export payment-methods-extension to it’s own asset build

This allows us to more accurately demonstrate how payment extensions would hook in to the blocks.

* don’t enqueue a style that doesn’t exist

* add full stop to comments and remove obsolete comment blcok

* fix spacing

* switch `activeContent` to `content` for payment method registration config
2020-03-30 08:07:49 -04:00
Darren Ethier 1648e651b4 Fix build issues for production builds (https://github.com/woocommerce/woocommerce-blocks/pull/2042)
* add payment-methods-demo config to sideEffects and install @wordpress/icons and @wordpress/primitives to be used directly.

* configure dependency extraction to ignore imports we want to use directly

* fix style issues for production builds

It looks like when a style is imported on the entrypoint of a component (or in a file with just exports), it get’s treeshaken from the final build _regardless of exception rules_.

* fix style imports from wordpress components

* fix loading skeleton showing on production builds

* fix block skeleton showing on production builds for cart

* import side effectful code

* add treatment for `@wordpress/warning` too

* fix typo

* exclude `settings/block` from sideEffects

* rollback `wordpress-components` update and keep sideEffects fixes

* remove unnecessary handle handling

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-03-27 16:56:48 -04:00
Albert Juhé Lluveras 86215d064d Shipping data context: replace address state with useShippingAddress() (https://github.com/woocommerce/woocommerce-blocks/pull/2037)
* Shipping data context: replace address state with useShippingAddress()

* Move External dependencies to the top

* Remove unnecessary useCallback
2020-03-27 12:14:32 +01:00
Mike Jolley 6d0ee74157 Add billing data context (https://github.com/woocommerce/woocommerce-blocks/pull/2027)
* Checkout class tidyup

* CheckoutProcessor placeholder

* ShippingMethodDataX to ShippingDataX

* Remove billing from checkout provider

* Remove billing data hook

* Remove billing from payment methods state

* Update typedefs

* Billing context

* Fix billing and shipping context persistence bugs

* Remove address form change

* Move phone back; another PR can deal with this

* Remove unused state
2020-03-26 13:31:09 +00:00
Seghir Nadir f3af7f7dfe fix rates not updating if you change coupon (https://github.com/woocommerce/woocommerce-blocks/pull/2026) 2020-03-26 13:43:11 +01:00
Seghir Nadir 06d4042567 Reinitialise useSelectShippingRate when rates change. (https://github.com/woocommerce/woocommerce-blocks/pull/2012)
* reinitilize the selected shipping rate

* useMemo instead of usePrevious
2020-03-26 13:40:56 +01:00
Albert Juhé Lluveras 4b80ef79ef Fix blocks not being added in WP <= 5.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2001)
* Only update grid default attributes on WP >= 5.3

* Use @wordpress/compose from external in Reviews sort-select

* Import withInstanceId from external only on legacy builds

* FallbackModule: add extensions to paths if it's missing

* Use path package to extract path extension

* Make all components import from the base withInstanceId HOC
2020-03-26 13:39:54 +01:00
Albert Juhé Lluveras 7bcf1eb5df Add URL to feedback prompt (https://github.com/woocommerce/woocommerce-blocks/pull/2028) 2020-03-26 12:02:45 +00:00
Darren Ethier 690f61ec93 Move payment method registration state to payment data context and add saved payment methods handling (https://github.com/woocommerce/woocommerce-blocks/pull/2029)
* Add saved-payment-method options handling and improve payment method registration initialization

* add server side exposure of saved customer payment methods

* fix reducer for express payment method state

* fix default for customerPaymentMethods
2020-03-26 07:11:46 -04:00
Rua Haszard 7921c3e5ba Record a tracks event when merchant toggles cart shipping calculator: (https://github.com/woocommerce/woocommerce-blocks/pull/1975)
* record a tracks event when merchant toggles cart shipping calculator:
- add tracks utility func for blocks
  - adds standard event name prefix
  - supplies post id & type params (an example)
- hook this up to UI when user toggles shipping calc
- pass enabled as boolean prop

* fix typo - call isTracksAvailable() !

* remove unnecessary temporary boolean

* update event name based on best practice guidelines

* remove isTracksAvailable preflight check:
- if site opts out, recordEvent is an empty function
- add in standard fallback boilerplate to ensure function exists
Note: currently no mechanism to detect if tracks is available on front end.
2020-03-26 10:12:34 +13:00
Seghir Nadir 4d1b99491d fix weird print in editor (https://github.com/woocommerce/woocommerce-blocks/pull/2024) 2020-03-25 16:39:39 +00:00
Albert Juhé Lluveras b67e5a5f10 Fix 'Show Sorting Dropdown' attribute ignored in All Products block (https://github.com/woocommerce/woocommerce-blocks/pull/2019)
* Fix 'Show Sorting Dropdown' attribute ignored in All Products block

* Update snapshot
2020-03-25 12:19:24 +01:00
Albert Juhé Lluveras c7e20c29d9 Decode address entities in shipping calculator (https://github.com/woocommerce/woocommerce-blocks/pull/2009)
* Fix wrong optional label for city

* Decode all address entities in shipping calculator

* Move decodeEntities to useShippingRates

* Move decodeEntities to useShippingAddress
2020-03-24 11:28:19 +01:00
Seghir Nadir 2ba75fdc25 Refactor useBillingData to useCheckoutContext and hooking it up to form (https://github.com/woocommerce/woocommerce-blocks/pull/2002)
* Add line pricing for cart items in the API (https://github.com/woocommerce/woocommerce-blocks/pull/1979)

* Add line pricing for cart items

* Update checkout linePrice

* Fix tests

* Update schema - add dinero

* Implement dinero in cart totals

* Update preview and remove line totals

* Update package lock

* Update checkout review

* Fix preview and default data shapes

* return first and last name in shipping address

* remove shippingAsBilling option from editor settings

* remove billing data from store

* move to context

* hook billing to hook and sync with shipping

* add email to billingData

* hydrate billing data

* some refactors

* move hydrated billing data to reducer initial state and fix stale dependencies

* fix stale useCallback

* better checks in php types

* get isEditor from context

* update typedefs

* skip state update if nothing changed

* fix rebase

* update snapshots

* rebase package

* wrap setEmail in useCallback

* remove ValidationContextProvider

* fix docs

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-03-23 21:13:41 +01:00
Darren Ethier 1d210e184b Fix event-emitters not accounting for observers as Object type. (https://github.com/woocommerce/woocommerce-blocks/pull/2010)
* Fix assumption of eventemitters stored in state as an arry.

* update tests to mock expected emitter state
2020-03-23 11:32:52 -04:00
Albert Juhé Lluveras 2593fcf7da Add Checkout form validation (https://github.com/woocommerce/woocommerce-blocks/pull/1993)
* Add Checkout form validation

* Add back validation when filling the address without having set a country

* Split TextInput and Select so they can be used with or without validation

* Cleanup

* Only display the missing country error if city, state or postcode are entered

* Fix CSS specificity conflict

* Remove unnecessary semicolon

* Rename areThereValidationErrors to hasValidationErrors
2020-03-23 12:22:00 +01:00
Mike Jolley 8abad3ad04 Add no payment methods placeholder (https://github.com/woocommerce/woocommerce-blocks/pull/1998)
* Update tabs and payment methods component classnames to meet standards

* Tidied up logic and added NoPaymentMethods placeholder

* Consistent "NO" placeholders

* frontend notices

* comments

* Update assets/js/base/components/payment-methods/no-payment-methods/style.scss

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Address feedback

* Moar bundle size

* Another notice

* Tweak text

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-03-20 12:48:11 -04:00
Darren Ethier e4a82aa1ce Convert emitters to promise (https://github.com/woocommerce/woocommerce-blocks/pull/2003)
* restructure event-emit directory and convert emitters to promises

- also add emitEventWithAbort function

* implement event emitters as promises

* clean up logic

- return from for loop
- define response as const on each iteration.
- return true if loop completes successfully.

* rename event_emit folder to event-emit
2020-03-20 12:46:24 -04:00
Mike Jolley 8ca9fc9b6f Update empty states (https://github.com/woocommerce/woocommerce-blocks/pull/1996)
* Add empty state template

* Checkout empty state

* Update other icons

* Blank alt
2020-03-19 15:50:36 +00:00
Mike Jolley 2ff854e212 Add nonces to Store API endpoints (https://github.com/woocommerce/woocommerce-blocks/pull/1992)
* Disable authentication for the Store API completely.

This may also resolve woocommerce/woocommerce-blocks#1991

* Add nonce handling to the abstract route

* Default state

* Add shared controls including nonce api fetch

* Use shared controls

* Hydrate inital nonce

* Update data stores

* Update nonce validation

* Fix tests by setting nonces

* Remove print_r debug

* Revert useStoreCart change

* Add nonce middleware

Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>

* Switch back to apiFetchWithHeaders

* Docs

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-03-19 11:50:51 +00:00
Mike Jolley cba3b9712f Add checkout skeleton whilst loading (https://github.com/woocommerce/woocommerce-blocks/pull/1995)
* Add checkout skeleton as loading state and remove placeholder text from save method

* Hide skeleton when not loading

* add loading class

* Update snap
2020-03-19 10:39:04 +00:00
Mike Jolley dadebfebbc Add line pricing for cart items in the API (https://github.com/woocommerce/woocommerce-blocks/pull/1979)
* Add line pricing for cart items

* Update checkout linePrice

* Fix tests

* Update schema - add dinero

* Implement dinero in cart totals

* Update preview and remove line totals

* Update package lock

* Update checkout review

* Fix preview and default data shapes
2020-03-17 15:34:33 +00:00
Mike Jolley 84b4a24bfa Use correct count from useStoreCart/API (https://github.com/woocommerce/woocommerce-blocks/pull/1980)
* Use correct count from useStoreCart/API

* Correct preview data counts

* Missing var from rebase
2020-03-17 12:11:30 +00:00
Darren Ethier ad4c981793 Add validation context provider and implement validation for shipping country and coupons. (https://github.com/woocommerce/woocommerce-blocks/pull/1972)
* add errormessage handling to countryinput (along with storybook)

* add types for react

* Add validation context and implement

* implement validation context for country field validation

* tweak ValidationInputError so that it can receive property name for getting error from

* improve storybook webpack config to pull from tsconfig.json

* update storybook story to cover changes with context

* Wrap Checkout Provider with Validation Context Provider

* add screen-reader-text style to storybook

* add styles for input error validation to text input

* improve styling for ValidationInputError component

* add validation error handling to TotalsCouponCode component

And story

* make sure errors are cleared on successful receive/remove item

* dispatch loading cancellation on catching errors

This is needed because loading would be cancelled before the error is thrown so any error handling after the thrown error will not be able to rely on loading.

* implement validation setting for coupon errors

* add error color to labels on inputs too

* fix borders back and force border color

* remove extra structure and improve validation error with alignment for coupon code

* add aria-describedby for text inputs

* add back in validation context provider to fix rebase issue

* rework validation so it works for both checkout and cart

* Some styling tweaks

* more style fixes

* remove unnecessary method

* make sure new function is included in context defaults

* package.lock update? seems harmless so rolling with it.
2020-03-17 12:45:33 +01:00
Mike Jolley bd6c7f657c Configure link for the proceed to checkout button (https://github.com/woocommerce/woocommerce-blocks/pull/1981)
* Add link for proceed to checkout button

* Fixes to indenting/types

* Update snaps

* Update notice
2020-03-17 10:30:52 +00:00
Darren Ethier cdfb457341 Add snackbar notices to notices system and implement for coupon ui/ux (https://github.com/woocommerce/woocommerce-blocks/pull/1973)
* add snackbarnotices to notices system

* implement snackbar notices for coupon code ui

* improve styles with mobile styles as well

* some more css fixes

* use native filter

* remove usage of lodash filter and dont’ output container if there are no regular notices

* remove unnecessary duplication of styles

- load default snackbar styles from WordPress components
- override for frontend to make them fixed to the window (including mobile treatement).

* simplify css class generation (save some bytes)

* improve proptypes definition

h/t: @aljullu

* consistent style handle name

* increase bundle size budget
2020-03-16 16:57:12 -04:00
Mike Jolley 01602f90bf Implement "return to cart" and "place order" buttons on checkout (https://github.com/woocommerce/woocommerce-blocks/pull/1926)
* Add back icon

* Add cart URL constant

* Add button components

* Implement button components into checkout

* Update checkout styles to match mockup incl updates to margins and padding

* Add options to control return to cart link

* Use checkout context

* Update snapshot

* Update context

* href

* Color/arrow styling

* Implement select instead of open URL field

* Add notice and updated settings control

* Show notice conditonally

* Store permalinks to avoid extra API requests, and get pages via API

* Update snapshots

* Fix double layout conflict

* Switch back to ID and add permalink via block setting

* snaps

* Fix snapshot; add default shape for pages

* Feedback

* Better undefined handling

* Update assets/js/blocks/cart-checkout/checkout/block.js

Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-03-16 16:38:24 +00:00
Seghir Nadir 3e7a2d41e4 disable coupon button if the field is empty (https://github.com/woocommerce/woocommerce-blocks/pull/1977) 2020-03-16 14:15:35 +01:00
Albert Juhé Lluveras 361d924c11 Fix layout issues after merges (https://github.com/woocommerce/woocommerce-blocks/pull/1968)
* Fix address form layout broken because select was occupying too much space

* Fix shipping rates appearing in the Checkout sidebar

* Center button text
2020-03-16 14:13:04 +01:00
Darren Ethier 437f80d38b Implement error handling for shipping rates and selected shipping rates. (https://github.com/woocommerce/woocommerce-blocks/pull/1956)
* add a hook for throwing errors in a hook callback.

* implement new useThrowError hook

* throw errors when selected shipping rate results in a rest error

* add error handling for various shipping rate error response types

* fix borked merge conflict resolution

* remove throwing error and use correct property for coupons

* add missing default address in use-store-cart

* add missing notices provider
2020-03-13 16:05:45 -04:00
Darren Ethier 80f692404f Refactor Cart to include shippingAddress (https://github.com/woocommerce/woocommerce-blocks/pull/1960)
* Include shipping and billing address data in cart schema

* update cart hook (and data api) with new properties from endpoint

* add use-shipping-address hook and implement in use-shipping-rates

* update usages of useShippingRates through code

* update tests for use-shipping-rates

* update use-payment-method-interface and typedef to remove country field

This is provided reliably via the shippingAddress now.

* restore pluck comparison to effect.

Also added some clarification docs for why `iniitalAddress` is not included in the effect dependencies.

* remove billingAddress from cart schema

* clear city and postcode when changing country

* Update REST Api schemas aftere rebase

- CustomerSchema no longer exists
- Added ShippingAddressSchema implemented by Cart and Order schemas
- fix broken js because of bad merge conflict resolution.

* remove duplicate keys
2020-03-13 15:04:03 -04:00
Albert Juhé Lluveras 5d1d8f0394 Add Order Summary card to Checkout sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/1959)
* Add missing props to sidebar-layout components

* Move specific CSS class to checkout block

* Add comment on top of @wordpress/components styles in webpack entry

* Make it so our styles load after vendor styles

* Remove unnecessary @todo comment

* Add Order Summary card to Checkout sidebar

* Improve responsive layout

* Increase cart.js bundlewatch size

* Remove wrong comment

* Remove unnecessary usage of useStoreCartItemQuantity

* Refactor layout so the product description can occupy more width

* Move paddings to the button so focus styles look better
2020-03-13 16:49:33 +01:00
Albert Juhé Lluveras bef5514044 Fix IE11 issues with the Checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/1941)
* Refactor useShippingRates so it doesn't use Object.fromEntries

* Refactor Checkout form CSS so it doesn't use grid autopositioning

* Fix Payment Methods title occupying too much space in IE11

* Fix payment methods tab icons not centered in IE11
2020-03-13 15:41:04 +01:00
Mike Jolley 128ac6d63d Refactor cart shipping settings and shipping calculator (https://github.com/woocommerce/woocommerce-blocks/pull/1943)
* Move cart attributes to attributes file

* Stop feedback prompt jumping around; consolodate strings

* Update option labels and descriptions

* Match checkout save function

* hasShippingRate helper

* Refactor full cart/frontend views for shipping calc

* Add hasShippingAddress to useShippingRates hook

* Initial shipping calculator in totals row implementation

* Create cart context

* Update preview data to match API response

* Use context provider for cart

* Provide default cart item for placeholder with correct shape

* Remove outdated shape validation from cartlineitemrow

* Use preview data in editor context

* Tidy up components

* Tests/lint

* Update assets/js/base/components/totals/totals-shipping-item/has-shipping-rate.js

Co-Authored-By: Seghir Nadir <nadir.seghir@gmail.com>

* No need to camel case previewdata

* Use isValidElement

* Implement EditorContext

* Use select if no post is given

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-03-13 13:41:59 +00:00
Albert Juhé Lluveras 1c81066bc4 CSS editor fixes for Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/1949)
* Set min-height to 0 for Country & State hidden inputs

* Fix button styles broken in the Cart block in editor

* Avoid having editor.scss specific stylesheets for button and totals

* Move Button inside cart-checkout subfolder
2020-03-13 12:02:08 +00:00
Seghir Nadir f55adc41cb Fix select rates when multiple packages exists (https://github.com/woocommerce/woocommerce-blocks/pull/1945)
* Select rates when multiple packages exists

* switch to using package_id

* update docs

* ponyfill fromEntries

* revert useShippingRates fromEntries fix
2020-03-12 10:59:43 +01:00
Albert Juhé Lluveras 2147e8a22a Add checkout sidebar (https://github.com/woocommerce/woocommerce-blocks/pull/1921) 2020-03-12 10:41:35 +01:00
Albert Juhé Lluveras 87b87cee8a Hydrate Checkout block with API data (https://github.com/woocommerce/woocommerce-blocks/pull/1937) 2020-03-12 10:24:50 +01:00
Darren Ethier e2fca8cf02 Update/extract prepare total items to utility (https://github.com/woocommerce/woocommerce-blocks/pull/1950)
* add valueWithTax to CartTotalItem typedef

* Finish off `prepareTotalItems` to include totals with taxes and also add tests

* add whether prices should include tax to the payment method interface

* only export the hook, not the util function

* Indicate values are in subunits

* rename property so it’s consistent with typedef and implement
2020-03-11 21:08:20 -04:00
Darren Ethier 09248192c2 Fix invalid coupon thrown error and form not connected console warning. (https://github.com/woocommerce/woocommerce-blocks/pull/1952)
* remove throwing errors if there’s an error in state.

These type of errors should be surfaced to user as needed via an error notice, not as a blocking error boundary. Error boundary should only be for non-recoverable errors.

* prevent default behaviour for applyCoupon button
2020-03-11 16:23:14 -04:00
Darren Ethier 74fe220f89 Add new hooks related to payment methods and checkout and remove obsolete. (https://github.com/woocommerce/woocommerce-blocks/pull/1929)
* add various hooks and improve hooks folder structure

- Also restructures hooks directory to make things a bit more organized
- Add useStoreOrder placeholder (followed up in future pull)
- Add useBillingData hook.

* implement usePaymentMethodInterface hook in payment method components

* remove obsolete hooks and implement new checkout context hooks

- add useCheckoutSubmit which exposes checkout submit button interface
- add useCheckoutRedirectUrl which exposes checkout redirect url interface

* add alias for `@woocommerce/base-utils` to jest config

* use consistent variable names for payment method id
2020-03-11 06:50:12 -04:00
Rua Haszard 14a593a4bb Make checkout button sticky footer on mobile (https://github.com/woocommerce/woocommerce-blocks/pull/1917)
* sticky footer checkout submit button on mobile

* fix storefront footer icons overlaying sticky checkout CTA footer:
- bump z-index of sticky CTA container
- storefront icons have weird z-index due to css opacity

* hide storefront footer on woo cart page only

* remove storefront specific bug fix for sticky cart footer:
- will log this issue separately
2020-03-11 11:27:52 +13:00
Albert Juhé Lluveras 3b807d5e04 Fix Cart block making 404 requests in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/1925) 2020-03-10 17:50:18 +01:00
Darren Ethier 3e355f8ac2 Update payment registration config to include `edit` components (https://github.com/woocommerce/woocommerce-blocks/pull/1928)
* add isEditor to checkotu context and implement in provider usage

* modify configuration expectations for payment method registration api

* update registration of payment methods in demo

* implement new configuration in payment method components

* fix argument order and update jsdocs
2020-03-10 12:35:30 -04:00
Albert Juhé Lluveras d0cb38d37d Handle cart api errors (https://github.com/woocommerce/woocommerce-blocks/pull/1907) 2020-03-10 16:49:26 +01:00
Darren Ethier 4b4dff1297 Fix PropTypes warning for CartLineItem component (https://github.com/woocommerce/woocommerce-blocks/pull/1927)
* fix proptypes declaration.

This ensures that when `lowStockRemaining` is included it’s either null or a number.

* Ensure backorders_allowed value is boolean.

* add missing properties to cart preview
2020-03-10 11:14:05 -04:00
Mike Jolley e6dfe243f9 Switch out usage from withComponentId to tree-shaken withInstanceId (https://github.com/woocommerce/woocommerce-blocks/pull/1923) 2020-03-10 14:40:30 +00:00
Darren Ethier 2aa2093dfb Add contexts for checkout (https://github.com/woocommerce/woocommerce-blocks/pull/1915)
- restructures `@woocommerce/base-context` imports so it pulls from `index.js` in the `base/context` folder. That way tree-shaking will be used if possible. This also helps with organizing the folder structure a bit better for the new contexts.
- Fixes all the various imports through the code due to the above change.
- Adds `CheckoutContextProvider`, `useCheckoutContext` and related files.
- Adds `PaymentMethodDataProvider`, `usePaymentMethodDataContext` and related files.
- Adds `ShippingMethodDataProvider`, `useShippingMethodDataContext` and related files.
- Adds typedefs used for the various context interfaces.
2020-03-10 09:39:21 -04:00
Seghir Nadir 5ca0593fbd Default to the first state when selecting a country with states (https://github.com/woocommerce/woocommerce-blocks/pull/1919)
* default to the first state

* Update assets/js/base/components/state-input/state-input.js

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-03-10 13:27:58 +01:00
Darren Ethier 0cacf5e0da Disallow selecting quantity of stock past what's available. (https://github.com/woocommerce/woocommerce-blocks/pull/1905)
- `useStoreCartItemQuantity` now receives the cartItem instead of the `cartItemKey` as an argument. I didn't notice in previous reviews how it's used in the context where we already have a cartItem so implementing this reduces complexity and makes the hook more precise for it's purpose.
- Add `backorders_allowed` to the CartItem schema for the API. This allows for client to have correct logic for maximum quantity when this value is true.
- Implement the above in the `CartLineItemRow` so that quantity picker is limited by the amount of stock remaining if that is available (`lowStockRemaining`) and the `backorders_allowed` is false.
- maximum quantity is currently hardcoded to a (filtered) value of `99` when other conditions don't apply (see related issue in woocommerce/woocommerce-blocks#1913)
2020-03-10 07:43:57 -04:00
Mike Jolley 514642395a Prevent wp.components loading on frontend (https://github.com/woocommerce/woocommerce-blocks/pull/1918)
* Avoid importing @wordpress/components in icon library

* Avoid @wordpress/compose and @wordpress/components in `base`

* Move hocs used on frontend to base

* Revert "Move hocs used on frontend to base"

This reverts commit bf09016fdc2fc1bea2f465018fecc76945f69d5e.
2020-03-10 11:20:40 +00:00
Seghir Nadir 952638a3ed Link shipping form fields to shipping rates to load them. (https://github.com/woocommerce/woocommerce-blocks/pull/1890)
* add plukedAddress util function in order to use it for shallowEqual

* refactor useShipping so it accepts and returns the address

* refactor fields

* fix test and return shippingRates to hook

* remove unneeded shippingAddress from ShippingRatesControl

* move keys logic to hook

* refactor tests again

* increase cart size
2020-03-10 11:55:19 +01:00
Albert Juhé Lluveras f14fc54faf Refactor 'Hide shipping costs' Cart attribute logic (https://github.com/woocommerce/woocommerce-blocks/pull/1909)
* Use kebab-case for Cart block attributes

* Simplify Cart edit function

* Refactor showShippingCosts logic

* Update snapshots
2020-03-10 10:09:34 +01:00
Rua Haszard 12f942948e mobile layout fixes for cart totals (https://github.com/woocommerce/woocommerce-blocks/pull/1898)
* tidy cart totals layout on mobile:
- totals column is full width
- reset container (card) borders and padding

* increase specificity of mobile cart styles to ensure skeleton hides after load

* use "not loading" && "not skeleton" approach for more readable mobile style selector
2020-03-10 10:16:03 +13:00
Mike Jolley 38890b3ff9 Add "or continue below" separator to checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/1906)
* Update express checkout component to match coding standards doc

* Improve express checkout spacing/styling

* Add continue rule
2020-03-09 15:49:01 +00:00
Mike Jolley 168ce52935 Include address fields in the AddressForm component (https://github.com/woocommerce/woocommerce-blocks/pull/1892)
* Move default address fields to blocks; normalise address i18n

* Use optionalLabel and other props from addressFields

* Fix apartment field display

* Country address fields

* Fix default field order

* Update for countries with no states

* Add type defs
2020-03-09 14:23:16 +00:00
Darren Ethier 02b3f2fccc add defaults for cart data totals object (https://github.com/woocommerce/woocommerce-blocks/pull/1896) 2020-03-09 08:52:25 -04:00
Darren Ethier 89ab1579b0 Followup for useStoreCartItem work (change hook name and improve typedefs) (https://github.com/woocommerce/woocommerce-blocks/pull/1900)
* add typedefs for CartItem

* remove cartItem from StoreCartItem typedef

* Implement new typedef and fix defaults as well as returned object.

Now that `cartItem` is only used internally, the default set on the state only has to be the properties required internally in the hook.

* add typedefs for shared settings and implement typedef comments.

* change hook name
2020-03-09 08:24:56 -04:00
Albert Juhé Lluveras b7da7ad198 Make Shipping packages collapsible in Cart page (https://github.com/woocommerce/woocommerce-blocks/pull/1867)
* Make Shipping packages collapsible in Cart page

* Fix Cart block radio controls not looking properly in the editor

* Simplify CSS
2020-03-09 12:28:26 +01:00
Rua Haszard 76f5ed5030 improve responsiveness when setting cart item quantities (https://github.com/woocommerce/woocommerce-blocks/pull/1864)
* rework the quantity change generator action so the UI updates quick:
- work in progress - still need to figure out how to debounce API call
- add new action for updating quantity for an item
- don't set cart item as pending while quantity is updating
  - this leaves QuantitySelector enabled so user can click more/less
- use receiveCartItemQuantity to update quantity in UI before sending request

* debounce line item quantity first cut:
- use local state for quantity, so ui allows multiple clicks up/down
- debounce store updates (and server/API call)

* correct comment on cart item quantity reducer

* remove recieveCartItemQuantity - no longer needed

* remove delegation for deleted RECEIVE_CART_ITEM_QUANTITY

* only update quantity in component sideffect if it has changed:
- reduces unnecessary renders

* factor out debounced quantity update into cartItem hook (hat tip @senadir)

* use quantity from store, instead of passing in to hook +
+ fix latent bug in useStoreCartItem - the cartItem value is now object:
  - was previously single-item array
  - (note no client code is using this at present)

* tidy/refactor cart item hook - separate dispatch from select

* remove dud reset of item pending flag (came back in rebase)

* add quantity to StoreCartItem hook return value typedef

* fix js error when adding cart block in editor – cartItem not found

* fix typedef

* fix logic for debouncing

* don’t update quantity on server unnecessarily

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-03-09 15:09:47 +13:00
Seghir Nadir e769516758 better default to array and use length as condition (https://github.com/woocommerce/woocommerce-blocks/pull/1891) 2020-03-06 15:40:07 +00:00
Albert Juhé Lluveras 427a229591 Split Full Cart sidebar totals into several components (https://github.com/woocommerce/woocommerce-blocks/pull/1885) 2020-03-06 12:27:54 +00:00
Mike Jolley 1942491822 Checkout Block: Add Legal links (https://github.com/woocommerce/woocommerce-blocks/pull/1881)
* Create policy component

* Create page constants

* Add toggle options

* Update assets/js/base/components/checkout/policies/style.scss

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Update assets/css/editor.scss

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

* Feedback

* update snapshot

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-03-06 12:20:17 +00:00
Mike Jolley 0a722b1708 Cart and checkout error boundaries (https://github.com/woocommerce/woocommerce-blocks/pull/1853)
* Add error boundries

Revert block error move

webpack config

fix path

* type in config

* change text allowed type

* Pass error boundary props to renderfrontend

* Editor error boundaries

* Add errorMessagePrefix

* merge rules

* Remove <disabled>

* Update reload page link
2020-03-06 11:43:40 +00:00
Albert Juhé Lluveras 20da4900c2 Add styling to checkboxes (https://github.com/woocommerce/woocommerce-blocks/pull/1880)
* Add styling to checkboxes

* Add resets for some themes

* Simplify props
2020-03-06 11:26:03 +01:00
Seghir Nadir 2c8388f0a8 Update and select shipping rates dynamically (https://github.com/woocommerce/woocommerce-blocks/pull/1794)
* add select shipping endpoint to router

* add select shipping method

* add selected rates to cart

* better select rates

* move schema function to seperate function

* move validation to Cart Controller

* fix wrong session key

* Update shipping/cart endpoints (https://github.com/woocommerce/woocommerce-blocks/pull/1833)

* Items should not have keys in API response

* Include package ID in response (this is just a basic index)

* /cart/select-shipping-rate/package_id

* Add package_id to package array

* Update responses and add shipping-rates to main cart endpoint

* update-shipping endpoint

* Add querying selected shipping rate to the store (https://github.com/woocommerce/woocommerce-blocks/pull/1829)

* add selecting shipping to store

* directly call useSelectShippingRate

* refactor cart keys transformation to reducer

* remove selecting first result and accept selecting

* move update shipping to new endpoint

* pass selected rates down

* select shipping right directly and fix editor issues

* fix some broken prop types

* key -> package id

* Update and fix cart/shipping-rate tests

* fix case for when rates are set

* Update useShippingRates test

* add args to rest endpoint

* move selecting shipping rate logic to hook

* fix some naming issues

* update propTypes

* update action call

* fully watch cart state

* address review issues

* fix prop type issues

* fix issue with rates not loading in checkout

* remove extra package for shipping

* move ShippingCalculatorOptions to outside

Co-authored-by: Mike Jolley <mike.jolley@me.com>
Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-03-05 20:54:05 +01:00
Rua Haszard 5a26d2708e ensure cart totals update when items are removed or quantity changed (https://github.com/woocommerce/woocommerce-blocks/pull/1840)
* ensure cart totals update when items are removed (prototype):
- return complete cart object from DELETE cart/items/:key
- use receiveCart on client to update whole cart including total

* move API endpoint for removing cart items to cart controller:
- returns full cart schema so should be part of cart controller
- is now a POST request with param - not strict REST
- fix up client action to use new API

* move API test for removing cart items (API has moved)

* use correct path for remove API in tests (doh!)

* add extra API test for remove_cart_item with bad key => 404 (experiment)

* experiment: delete test_remove_cart_item, does test_remove_bad_cart_item work?

* reinstate test_remove_cart_item with single valid request

* remove unnecessary newline

* tidy comments in PHP api tests, rerun travis?

* remove test_remove_cart_item which may be causing problems

* reinstate troublesome remove cart item api test (experiment):
- see if this works now travis issue is resolved

* whitespace

* show correct total when changing cart item quantity:
- move update cart item quantity API to cart controller
  - & return full cart response
- update js action to new API route & receive full cart response

* simplify test_remove_cart_item API test - now just tests a valid remove succeeds

* remove test_update_item (API has moved) +
+ experimentally remove test_remove_bad_cart_item
  - testing if cart remove tests interact with each other

* fix tests (🤞) - pass params in body, not as query params

* reinstate test for re-deleting same item

* update API docs - update/delete cart item have moved to /cart

* add response data checks to new cart API tests:
- extra protection against expected 404 "false positives"

* reinstate API test for changing cart item quantity

* fix remove cart item body tests - MIA items return error code, not cart

* fix test - quantity param is int not string

* attempt fix 404ing test_update_item:
- only allow POST, remove trailing `/`
- align array equals for good measure :)

* fix action for update-item - method=POST, now takes body params

* fix response body asserts in test_update_item

* reinstate update_item and delete_item on CartItems controller

* typos + examples in new cart items API docs

* reorder previous cart item docs to minimise diff/churn

* reinstate tabs in docs response example
2020-03-06 08:11:39 +13:00
Mike Jolley 52feba4f85 Add skeleton markup to the cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1866)
* Add skeleton markup

* Add shipping title to skeleton and match styling/spacing

* Combine skeleton and loading styles
2020-03-05 14:15:28 +00:00
Mike Jolley dd54ce1136 Checkout form options to control field visibility (https://github.com/woocommerce/woocommerce-blocks/pull/1868)
* Fix background overlap of feedback box

* TS notices

* Add company name toggle

* Implement new attributes and toggles in editor

* Handle field config in address component

* Remove other hoc rule from tsconfig

* map -> forEach

* Remove return from forEach

* Export and extend field config

* Fix optional text for all field types

* unit text

* Update snapshot
2020-03-05 13:06:47 +00:00
Mike Jolley 401f50a607 Tidy cart items mobile layout (https://github.com/woocommerce/woocommerce-blocks/pull/1875)
* add a smaller min-width for cart column on smaller screens

* ensure full price is inline on mobile (when visible)

* ensure line item totals are bottom aligned even if quantity cell is huge

* revert price vertical alignment - in design they are aligned with quantity digit
2020-03-05 13:05:42 +00:00
Mike Jolley c4c31bd926 make product name display block to push stock badge on to its own line (https://github.com/woocommerce/woocommerce-blocks/pull/1874) 2020-03-05 12:56:57 +00:00
Albert Juhé Lluveras 2544ffd7d1 Option to 'use shipping address for billing': add attribute and make it work in the frontend (https://github.com/woocommerce/woocommerce-blocks/pull/1857)
* Create useShippingAsBilling attribute

* Fix missing prop

* Refactor FormStep so stepNumber is generated by CSS instead of being passed as a prop

* Add billing address form

* Add text before controls

* Remove old @todo comment
2020-03-04 15:13:38 +00:00
Albert Juhé Lluveras e2f769eedf Do not allow focus on Country and State input hidden fields (https://github.com/woocommerce/woocommerce-blocks/pull/1842) 2020-03-04 14:35:18 +00:00
Mike Jolley ea19fad14e Add useStoreCartApiHydration HOC (https://github.com/woocommerce/woocommerce-blocks/pull/1845)
* Add useStoreCartApiHydration hoc

* comment

* indenting

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
2020-03-04 12:40:03 +00:00
Albert Juhé Lluveras e97ffd2821 Hide package name when there is only one (https://github.com/woocommerce/woocommerce-blocks/pull/1852) 2020-03-03 12:38:21 +00:00
Albert Juhé Lluveras 81c09d180b Create AddressForm component and change its fields dynamically based on country (https://github.com/woocommerce/woocommerce-blocks/pull/1847) 2020-03-03 11:46:53 +01:00
Mike Jolley d3a9dc3d6b Create Context Provider for Notices w/ Notices API (https://github.com/woocommerce/woocommerce-blocks/pull/1843)
* Working on store provider

* Working on store provider

* Reducer implementation

* Implement core/notices

* Add notices to store coupon hook with context

* Improve store notice text and styling

* Improve JS side API for notices

* Wrap functions with context additon

* Update test to []

* Implement props feedback and useInstanceId

* Update assets/js/base/context/store-notices-context.js

Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>

* Update assets/js/base/context/store-notices-context.js

Co-Authored-By: Darren Ethier <darren@roughsmootheng.in>

* remove instance id

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-03-03 10:26:02 +00:00
Mike Jolley 5fcf9b0fca Correctly handle store tax options in cart block (https://github.com/woocommerce/woocommerce-blocks/pull/1846)
* Correctly show prices with incl or excl taxes

* Move taxes below shipping

* TaxAmount case
2020-03-03 10:12:18 +00:00
Rua Haszard 201cb4ff50 Support updating quantity of cart items & sold_individually product option (https://github.com/woocommerce/woocommerce-blocks/pull/1824)
* first cut - removing an item from cart:
- add actions to cart store for removing an item and keeping track of
pending removal API call
- add reducer logic for storing pending state on an item, and removing
an item
- expose removeCartItem on new useStoreCartItems hook
- hook it up to remove link / trashcan icon in row item

* disable cart quantity picker/remove link while API request in progress:
- expose cart item pending status from store using selector
- use selector to disable quantity related components in line item row

* add typedef for cart items store object provided by hook

* allow user to change quantity of cart items (first cut):
- add action for replacing a cart item in the store
- add generator action for changing quantity
- expose change quantity action on useStoreCartItems hook
- hook up to quantity UI in cart block
(work in progress)

* post-rebase fixes & fix broken typedef:
- rework cart item change quantity callback - now supplies item key like
remove callback
- fix hook StoreCartItem return value typedef - single item with
specified key, was array of all items
- add quantity JSDoc for changeCartItemQuantity action
- remove changeQuantity callback from UI (currently infinite looping)

* fix bug in recieveCartItem reducer - check keys for equality:
- was key === object

* fix invalid url in POST cart/items/quantity request

* hook up cart line item quantity to API:
- remove internal state/ref for QuantitySelector, is now a controlled
component
- call changeQuantity action from QuantitySelector change callback

* QuantitySelector no longer needs a ref to wrangle number input value

* hoist quantity state out of QuantitySelector into story (fix storybook)

* add product sold_individually option to cart item API response

* limit sold_individually items to 1 per cart/order:
- support optional max value in QuantitySelector
- set maximum dependent on sold_individually API field

* prevent user from requesting zero x cart item (API 500 errors):
- add minimum limit to QuantitySelector
- default limit to 1
+ fix bug with limiting to maximum value in number input change handler

* remove useStoreCartItems, zombie hook coming back from rebase 🧟‍♂️

* address various review feedback:
- inline undefined check, don't use lodash
- quantityInputOnKeyDown callback hook depends on canIncrease/canDecrease
- also removed undefined check for minimum, as minimum has default 0

* use safer typeof check for presence of maximum prop
2020-03-03 14:08:19 +13:00
Albert Juhé Lluveras f2cdd2ade7 Fix Product Search block in last Gutenberg release (https://github.com/woocommerce/woocommerce-blocks/pull/1841)
* Fix Product search block in last Gutenberg release

* Convert ProductSearchBlock to a functional component

* Split ProductSearchBlock into two components
2020-03-02 14:46:56 +01:00
Darren Ethier 12a28556db Switch lint:js command to use wp-scripts and address errors. (https://github.com/woocommerce/woocommerce-blocks/pull/1837)
* switch js lint command to use wp-scripts.

* fix lint warning for improper jsdoc syntax

* fix linting errors
2020-02-28 16:54:07 -05:00
Darren Ethier 6b110d00f2 Fixes some typedef errors (https://github.com/woocommerce/woocommerce-blocks/pull/1832) 2020-02-28 06:51:30 -05:00
Rua Haszard 69ea94378b support removing cart items (https://github.com/woocommerce/woocommerce-blocks/pull/1813)
* first cut - removing an item from cart:
- add actions to cart store for removing an item and keeping track of
pending removal API call
- add reducer logic for storing pending state on an item, and removing
an item
- expose removeCartItem on new useStoreCartItems hook
- hook it up to remove link / trashcan icon in row item

* disable cart quantity picker/remove link while API request in progress:
- expose cart item pending status from store using selector
- use selector to disable quantity related components in line item row

* fix jsdoc - getCartItem returns undefined if not found

* add typedef for cart items store object provided by hook

* fix rebase error - key prop went awol

* orient useStoreCartItem hook to single cart item:
- simplify interface for client component
  - isPending bool (was callback)
  - removeItem callback no need to specify item key
+ reinstate disabled prop on remove link when updating (lost in rebase)

* move cart item pending state out of cartItems, preserve API state shape:
- pending is now stored as array of keys
- fix isItemQuantityPending selector (now much simpler)

* ensure react knows that our useSelect depends on cartItemKey
2020-02-28 15:05:10 +13:00
Rua Haszard bb637bbaa3 support disabled QuantitySelector [in progress] (https://github.com/woocommerce/woocommerce-blocks/pull/1823)
* add basic story for QuantitySelector (so can easily test disabled)

* add disabled prop to QuantitySelector:
- apply to all input controls
- add storybook knob for testing
- use disabled grey for number edit when disabled

* fix indentation of jsdoc comment (linter is coming)

* use self-closing tag in QuantitySelector story

Co-Authored-By: Albert Juhé Lluveras <aljullu@gmail.com>

Co-authored-by: Albert Juhé Lluveras <aljullu@gmail.com>
2020-02-28 09:52:18 +13:00
Albert Juhé Lluveras 185149f2bd Persist previous shipping rates while loading and show its package name (https://github.com/woocommerce/woocommerce-blocks/pull/1806)
* Persist previous shipping rates while loading

* Refactor ShippingRatesControl LoadingMask

* Show package name

* Simplify CSS to avoid using the adjacent selector

* Add comment to explain why 'selected' is hardcoded in the editor

* Rename package 'index' to 'key'
2020-02-27 19:28:36 +01:00
Mike Jolley d4e843fd65 Update snapshot to fix broken tests 2020-02-27 11:53:12 +00:00
Mike Jolley 6ac5b8288f Add chip component for coupons in the cart (https://github.com/woocommerce/woocommerce-blocks/pull/1807)
* Chip componet and styling

* Tests

* Move coupon code for API requests to body - fixes issues with coupon codes containing special characters

* Implement chip component in cart page

* Revert "Move coupon code for API requests to body - fixes issues with coupon codes containing special characters"

This reverts commit ac5a72f55d51d939bb989f3936e28cf993af19a6.

* Update comment

* prevent overflow

* Add screen reader text for coupon name

* Adjust icon alignment and padding/hit box

* update string
2020-02-26 17:09:18 +00:00