Commit Graph

1699 Commits

Author SHA1 Message Date
Mike Jolley 6df5903e0f Checkout Block Order Summary Styles (https://github.com/woocommerce/woocommerce-blocks/pull/2355)
* Update checkout styles

* remove item prices from summary
2020-04-30 10:51:08 +01:00
Albert Juhé Lluveras 2593c711ad Fix payment method error notices issues (https://github.com/woocommerce/woocommerce-blocks/pull/2352)
* Prevent payment method errors appearing twice. Fixes woocommerce/woocommerce-blocks#2327

* Remove payment method errors on submit. Fixes woocommerce/woocommerce-blocks#2217

* Simplify useEffect dependencies

* Pass context name to removeNotice
2020-04-30 11:43:56 +02:00
Darren Ethier 06d84997e5 Update testing instructions cart stock error. 2020-04-29 16:01:52 -04:00
Albert Juhé Lluveras fce0e2d71c Fix Cart block interaction in the editor (mobile) (https://github.com/woocommerce/woocommerce-blocks/pull/2354)
* Prevent SnackbarList from loading in the editor

* Fix snackbar styles leaking into the editor

* Prevent 'Proceed to Checkout' button being fixed to the bottom in the editor
2020-04-29 17:45:29 +02:00
Mike Jolley 8424934149 Update API status codes (https://github.com/woocommerce/woocommerce-blocks/pull/2353)
* Update HTTP status codes

* Catch JSON parsing errors.
2020-04-29 15:47:05 +01:00
Rua Haszard 7abe9dffb3 align cart main heading and totals sidebar heading: (https://github.com/woocommerce/woocommerce-blocks/pull/2346)
- set appropriate padding for main cart container
- card padding is currently provided by Gutenberg component (?)
- overriding padding on totals card to match main container
2020-04-29 13:35:42 +01:00
Mike Jolley 95809b30bb Update payment method config to include icons (https://github.com/woocommerce/woocommerce-blocks/pull/2267)
* Remove strong and cleanup existing configs

* Fix TS validation for blocks-registry

* Allow label to be string

* Split up button and icons for cart

* Make icons and payment methods available on cart page

* Fix payment method enqueuing

* Icon normalization and Stripe implementation

* PayPal Icon

* adjust spacing

* Fix string handling

* Remove paypal icon config

* Check for an object before creating icon

* Add payment icons to Stripe label

* Update common-icons.js

* Update Cart.php

* Update jest.config.json
2020-04-29 11:57:58 +01:00
Albert Juhé Lluveras 60cf16a334 Fix low stock badge not breaking in a new line (https://github.com/woocommerce/woocommerce-blocks/pull/2348) 2020-04-29 12:57:04 +02:00
Darren Ethier 58abb408c2 make sure we import from external not direct files (https://github.com/woocommerce/woocommerce-blocks/pull/2330) 2020-04-29 11:20:52 +01:00
Mike Jolley 8c88870d2d Merge branch 'add/pin-woocommerce' 2020-04-29 11:07:02 +01:00
renovate[bot] cb467c8696 Update dependency @types/wordpress__data to v4.6.7 (https://github.com/woocommerce/woocommerce-blocks/pull/2333)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:53:21 +01:00
Mike Jolley afe5f4d706 Update shipping should extend the correct route (https://github.com/woocommerce/woocommerce-blocks/pull/2328) 2020-04-29 10:44:07 +01:00
renovate[bot] 4785151037 Update Node.js to v12.16.3 (https://github.com/woocommerce/woocommerce-blocks/pull/2331)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:25:12 +01:00
renovate[bot] 0a6c23ba8e Update dependency @stripe/stripe-js to v1.5.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2332)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:24:52 +01:00
renovate[bot] 9c41e1bfcc Update dependency @types/wordpress__element to v2.4.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2334)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:23:55 +01:00
renovate[bot] 808e40a089 Update dependency css-loader to v3.5.3 (https://github.com/woocommerce/woocommerce-blocks/pull/2336)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:23:29 +01:00
renovate[bot] a9b14b2b4e Update dependency jest to v25.5.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2337)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-29 10:23:13 +01:00
Rua Haszard 1b596b94dc Quantity badge white separator + center tweak (https://github.com/woocommerce/woocommerce-blocks/pull/2347)
* add extra white border to quantity badge

* nudge checkout quantity badge so it's roughly centered with image corner
2020-04-29 10:22:12 +01:00
Mike Jolley a58420a60e Table creation validation for install routine (https://github.com/woocommerce/woocommerce-blocks/pull/2287)
* Bump package version for testing

* New install routine and db version

* Revert "Bump package version for testing"

This reverts commit c3fee55a34e75429b731cd7a2cc07e841010df6d.

* Update bootstrap to ensure blocks is installed properly before tests are ran

* Restore errors after install

* Use enabled method instead of comparing db version

* Moved installer code to admin_init

* Tweak test bootstrap
2020-04-28 16:36:37 +01:00
Mike Jolley ad93ddd891 Add PayPal Standard (https://github.com/woocommerce/woocommerce-blocks/pull/2288)
* Add paypal files

* Add PayPal Icon/resolve feedback
2020-04-28 11:13:48 +01:00
Seghir Nadir 476ae5dcd5 remove order note (https://github.com/woocommerce/woocommerce-blocks/pull/2318) 2020-04-28 11:07:05 +01:00
renovate[bot] 0a9ce1206b Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/2290)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-27 17:26:29 +01:00
Seghir Nadir 797ded1efc Add notice errors to add to cart button and All products (https://github.com/woocommerce/woocommerce-blocks/pull/2278)
* expose errors when adding to cart

* clear notices

* make notice dismissible

* decode entities
2020-04-27 17:24:54 +01:00
Mike Jolley e85b6fe9a9 Inject block attributes rather than save them (https://github.com/woocommerce/woocommerce-blocks/pull/2273)
* Inject attributes rather than saving them

* Update snaps
2020-04-27 12:06:58 -04:00
Mike Jolley 30ecea188f Avoid loading Assets API during REST requests (https://github.com/woocommerce/woocommerce-blocks/pull/2286)
* Move is built to method

* Moved payment related logic into single controller class for better organization

* Only load assets on non-rest requests
2020-04-27 16:51:50 +01:00
Seghir Nadir d70174aa57 Pin WooCommerce version 2020-04-26 14:30:31 +01:00
Mike Jolley e5589727fc Support itemized taxes (https://github.com/woocommerce/woocommerce-blocks/pull/2276) 2020-04-24 14:44:44 +01:00
Mike Jolley 8bf58b4596 Trigger fragment refresh after editing cart item quantities (https://github.com/woocommerce/woocommerce-blocks/pull/2266)
* Make util to fire legacy events

* Update button to use util

* Trigger event when quantity changes

* Trigger event on removal

* Move comments to util
2020-04-24 14:41:32 +01:00
Mike Jolley 7f85c1bcc0 Migrate REST API usage to the Store API (https://github.com/woocommerce/woocommerce-blocks/pull/2282)
* Remove unused wc/blocks/cart endpoint

* remove unused withProducts hoc

* Remove getProducts util

* Use store API products endpoint in product blocks

* Remove product endpoint tests

* Remove controller

* Switch attributes endpoint to store api

* Refactor withAttributes to use store API

* Migrate tags and cats to store API

* MIgrate variations to store api

* Migrate reviews to store API

* Drop dedicated variation endpoint

* Move tests

* Move cart init

* Fix reviews

* Comment out broken tests

* Remove old class based with-attributes test
2020-04-24 14:36:47 +01:00
Albert Juhé Lluveras 72c7b38022 Add screen reader text to remove item icon (https://github.com/woocommerce/woocommerce-blocks/pull/2285) 2020-04-24 15:11:14 +02:00
Albert Juhé Lluveras 96e8ccf1a4 Cart & Checkout: Update styles to better match designs (https://github.com/woocommerce/woocommerce-blocks/pull/2283)
* Add ending dot to sentence

* Open links to products from Cart and Checkut blocks in new tabs

* Makes sure product names are broken if they overflow the container

* Use native find instead of lodash method

* Update styles to better match designs

* Revert "Open links to products from Cart and Checkut blocks in new tabs"

This reverts commit 9b64aa5f2e81bf0cf09d5640a3cfe1cc1085c046.

* Fix product name overflowing remove menu on mobile

* Remove @todo comments from form step CSS

* Make letter-spacinguse em instead of px

* IE11: Correctly align text in quantity selector

* Fix long product names overflowing in Checkout block on IE11
2020-04-24 13:23:25 +01:00
Seghir Nadir 7863a99de7 Abstract Page selector and fix some issues in sidebar. (https://github.com/woocommerce/woocommerce-blocks/pull/2270)
* abstract pageSelector to its own component and fix titles

* fix unwrapped context

* move control styles outside editor-wrapper

* restore condition to previous state

* move condition outisde

* rename condition

* keep pageSelect visible till next refresh

* remove comment
2020-04-22 17:44:12 +01:00
Mike Jolley 953712941b Update StoreApi namespaces/move files (https://github.com/woocommerce/woocommerce-blocks/pull/2277)
* `use` is never relative - absolute is always used so backslash is not needed

* Move process_legacy_payment code to rest api class

* Move storeapi directory

* Updated namespaces and moved tests
2020-04-22 15:39:19 +01:00
Mike Jolley 5a2ee88905 Fixes to totals recalculation and taxes (https://github.com/woocommerce/woocommerce-blocks/pull/2275)
* Hide tax totals row when taxes are disabled in core

* Trigger recalcs if hash changes

* move recalc until later on in rest call

* Unused class
2020-04-22 14:16:17 +01:00
Albert Juhé Lluveras 7fa4b76c52 Prevent All Products block from crashing when error has no json method (https://github.com/woocommerce/woocommerce-blocks/pull/2269) 2020-04-22 12:09:20 +02:00
renovate[bot] 5d25790d95 Update dependency jest to v25.4.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2272)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-22 11:06:39 +01:00
renovate[bot] 3e9b6ad26c Update dependency eslint-config-prettier to v6.11.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2271)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-22 11:06:13 +01:00
Mike Jolley db145deb70 Decode billing address from server (https://github.com/woocommerce/woocommerce-blocks/pull/2268) 2020-04-21 15:24:04 +01:00
Mike Jolley 880d4e19b4 Decode entities in cart shipping data (https://github.com/woocommerce/woocommerce-blocks/pull/2265) 2020-04-21 14:43:49 +01:00
Mike Jolley d0d0cfc565 Checkout: Rename address2 attribute (https://github.com/woocommerce/woocommerce-blocks/pull/2264)
* Rename address2 attribute

* Update snap
2020-04-21 11:51:11 +01:00
Darren Ethier 493a826e44 modify emitters so it handles non object or invalid object responses correctly. (https://github.com/woocommerce/woocommerce-blocks/pull/2249)
With these changes:

- If an observer returns an object wthout a type property an error is thrown and the emitter is aborted with an error type response.
- For anything else returned from an observer, it’s discarded.

Tests are updated for the new expectations
2020-04-21 04:33:16 +02:00
Seghir Nadir a005649ab8 Move blocks to stable flag (https://github.com/woocommerce/woocommerce-blocks/pull/2261)
* remove feature flag

* catch blocks.ini error
2020-04-20 15:55:59 +01:00
Seghir Nadir 106e187bd7 Merge branch 'master' of https://github.com/woocommerce/woocommerce-gutenberg-products-block 2020-04-20 15:13:49 +01:00
Seghir Nadir dc2d0dd6ae mark heading in docs 2020-04-20 15:13:38 +01:00
Mike Jolley a074260266 Revert "Improvements to REST API performance (https://github.com/woocommerce/woocommerce-blocks/pull/2248)" (https://github.com/woocommerce/woocommerce-blocks/pull/2259)
This reverts commit 30c0182fbe.
2020-04-20 14:59:17 +01:00
Seghir Nadir bb9f688ee4 fix some typos in testing checklist 2020-04-20 14:58:19 +01:00
Seghir Nadir 3a71233d4b Testing checklist (https://github.com/woocommerce/woocommerce-blocks/pull/2196)
* initial draft for testing

* fix typos and add table of content

* add how to report section

* finish the rest of the docs

* add free shipping section

* add create todo badge

* fix misplaced button

* add a general flow section

* change image link

* fix typos
2020-04-20 14:47:11 +01:00
Seghir Nadir 2e9b21ef8a Fix snackbar being too high and covering coupon section (https://github.com/woocommerce/woocommerce-blocks/pull/2255)
* fix snackbar issue

* fix some styles
2020-04-20 14:23:44 +01:00
Mike Jolley 248c552baf Add quantity limit at product level (https://github.com/woocommerce/woocommerce-blocks/pull/2256)
* Add quantity limit at product level

* Stock checks only needed when backorders are disabled

* Use remaining stock, not stock qty in messages etc

* Prevent duplicate validation from core
2020-04-20 14:10:39 +01:00
Mike Jolley de53038872 Check for instance of WP_Block (https://github.com/woocommerce/woocommerce-blocks/pull/2258) 2020-04-20 14:07:08 +01:00
Mike Jolley 30c0182fbe Improvements to REST API performance (https://github.com/woocommerce/woocommerce-blocks/pull/2248)
* Rejig methods and only load assets on non-api requests

* Avoid cart recalc on every request

* link to pr
2020-04-20 14:06:30 +01:00
renovate[bot] 6a8643f531 Update dependency @stripe/stripe-js to v1.4.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2222)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-20 11:13:52 +01:00
Albert Juhé Lluveras 1b2e8dd435 Do not scroll to top when payment methods have an error (https://github.com/woocommerce/woocommerce-blocks/pull/2247)
* Do not scroll to top when payment methods emit an error

* Simplify code and add check for hasValidationErrors
2020-04-20 11:11:32 +01:00
renovate[bot] 75f6eb97fb Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/2254)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-20 10:37:25 +01:00
Mike Jolley 4dbb7fcfbb Coupon was removed, but array was not updated (https://github.com/woocommerce/woocommerce-blocks/pull/2253) 2020-04-20 10:15:08 +01:00
Darren Ethier 580015827a remove obsolete @todo 2020-04-17 17:00:43 -04:00
Mike Jolley 5b142b58ed Coupon and Cart Item Validation Fixes (https://github.com/woocommerce/woocommerce-blocks/pull/2245)
* Move validation calls to checkout API class

* Validate before payment

* Support additional error data

* Add coupon validation before payment, and hide hashes from user

* Implement validation and recalculation

* Abstract notice handler and implement legacy filters

* Handle generic cart item errors

* strip tags from coupon error messages woocommerce/woocommerce-blocks#2212

* Ensure item errors are surfaced when coupons are removed

* Fix wrong value passed to hook

* fix broken checkout when no payment method is there

* try fixing unit test errors

* if preview data has a receiveCart function use it, otherwise default to an anononymous function

* fix tests

Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-17 21:18:54 +01:00
Darren Ethier ae3a2dc7ad improve tocs in recently merged docs (https://github.com/woocommerce/woocommerce-blocks/pull/2246) 2020-04-17 11:42:51 -04:00
Darren Ethier 0a98037606 Add documentation for checkout flow and payment method integrations (https://github.com/woocommerce/woocommerce-blocks/pull/2246)
* add documentation for checkotu flow and payment method integrations

* Update docs/block-client-apis/README.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/README.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* standardize around capitalized API

* Remove extra dash.

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* Update docs/block-client-apis/checkout/checkout-api.md

Co-Authored-By: Mike Jolley <mike.jolley@me.com>

* remove 1st person narrative

* various other grammar fixes

* add table of contents to docs

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-04-17 11:37:09 -04:00
Rua Haszard f8489dc870 rename docker-related npm scripts so it's clear they are e2e infrastructure (https://github.com/woocommerce/woocommerce-blocks/pull/2237)
* rename docker-related npm scripts so it's clear they are e2e infrastructure

* fix travis e2e test job - update script name 😅
2020-04-17 10:44:29 +01:00
Mike Jolley 87fb1768a1 Documentation for the Store API (https://github.com/woocommerce/woocommerce-blocks/pull/2230)
* Products endpoint

* Updated STORE API docs

* Enable nonce protection for checkout endpoints and document

* feedback
2020-04-17 10:44:13 +01:00
Darren Ethier a8c2a015b4 use noticeContext properties for notice area (https://github.com/woocommerce/woocommerce-blocks/pull/2241) 2020-04-17 10:39:24 +01:00
renovate[bot] 59e4d12a7d Update dependency jest to v25.3.0 (https://github.com/woocommerce/woocommerce-blocks/pull/2226)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-17 10:27:28 +01:00
renovate[bot] 48ef1e5d93 Update dependency css-loader to v3.5.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2225)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-17 10:27:13 +01:00
renovate[bot] 71a1fbc7ae Update dependency autoprefixer to v9.7.6 (https://github.com/woocommerce/woocommerce-blocks/pull/2224)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-17 10:26:29 +01:00
renovate[bot] 5de3b8544e Update dependency @types/react to v16.9.34 (https://github.com/woocommerce/woocommerce-blocks/pull/2223)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-17 10:26:13 +01:00
renovate[bot] cba08c3392 Update Node.js to v12.16.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2221)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-17 10:25:37 +01:00
Mike Jolley 990949b302 Improve "sold individually" validation (https://github.com/woocommerce/woocommerce-blocks/pull/2234)
* API - Block qty > 1 for sold individually products

* Add item validation for sold individually to block checkout

* Fix validation check

* Add client side limit if sold individually

* Prevent never ending loading on failed add to cart

* Change cart button for sold individually errors
2020-04-17 10:24:44 +01:00
Seghir Nadir 2dfb8365de create a notice instead of throwing an errors (https://github.com/woocommerce/woocommerce-blocks/pull/2203) 2020-04-16 16:08:23 +01:00
Mike Jolley 216a7fc1bf Capture legacy payment notices (https://github.com/woocommerce/woocommerce-blocks/pull/2238)
* Convert woo notices into exceptions when processing legacy payments

* Prevent console errors when a message is not returned in the response

* include top level message property to capture REST error messages

* include capturing rest error messages on afterProcessing action

* clear notices before exception

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-16 15:39:46 +01:00
Mike Jolley 9260e7ad89 Add block asset documentation (https://github.com/woocommerce/woocommerce-blocks/pull/2209)
* Add block asset documentation

* feedback
2020-04-15 17:09:36 +01:00
Mike Jolley 21f75b61b0 Show feedback on buttons/checkout when processing (https://github.com/woocommerce/woocommerce-blocks/pull/2186)
* Allow buttons to show loading spinners

* Show spinner on cart checkout button press

* Disable fieldsets when processing

* Check icon when finished

* Style tweak to fix height

* Update events

* feedback

* Move button back
2020-04-15 17:09:15 +01:00
Darren Ethier 0501328902 Fix global validation error reporting and cheque payment method regressions (https://github.com/woocommerce/woocommerce-blocks/pull/2232)
* fix broken validation error handling after submit

* Add handling for when there are no observers for payment processing or all observers just return true.

* cheque no longer needs to hook into event emitter

* account for no data on complete status handling in reducer

* add handling for either no observers or all observers returning true for onAfterProcessingWithSuccess emitter
2020-04-15 11:43:03 -04:00
Albert Juhé Lluveras d5232c9903 Handle errors when loading payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/2228)
* Handle errors when loading payment methods

* Use an error boundary

* Fix missing initial state in block error boundary

* Cleanup

* Only show internal user messages if it's admin or in editor

* Fixes

* Add friendly error message
2020-04-15 17:15:56 +02:00
Mike Jolley ceaae16d23 Fix entities in coupon validation error messages (https://github.com/woocommerce/woocommerce-blocks/pull/2179)
* decodeEntities in error messages

* Add unslash to coupon field

* Decode when receiving error
2020-04-15 09:59:01 +02:00
Rua Haszard ace2d2bd81 show preview "saved payment methods" in editor (https://github.com/woocommerce/woocommerce-blocks/pull/2151)
* factor out editor preview data for saved payment methods to previews

* add missing imports lost in rebase

* use editorcontext to provide preview data to payment method context

* remove unused `activePaymentMethod` prop in CheckoutProvider and PaymentMethodDataProvider

* don't set the preview saved card as the default

* fix js error with cart in editor - fix EditorContext, pass previewData:
- editor context preview prop has changed;
  - update cart to pass { previewCart } in previewData prop
- correctly destructure cart from previewData in useStoreCart hook
- correct typedefs
  - EditorProvider props.previewData - now just Object
  - similar for EditorDataContext
- correct default for activePaymentMethod state - empty string as before

* preselect 'use a new payment method' in checkout block editor preview

* update unit tests for changes to editor context
2020-04-15 12:05:01 +12:00
Darren Ethier 6069b9b90a Lazy load stripe.js and preserve payment method registration order. (https://github.com/woocommerce/woocommerce-blocks/pull/2214)
* remove stripe.js registration because it is lazy loaded via the library used.

* refactor payment method registration to preserve registration order.

* register payment method asset handles as dependency on editor script as well.
2020-04-14 18:44:31 -04:00
Darren Ethier 5850966894 Refactor checkout status and event emitters to support stripe intents and more complex payment methods. (https://github.com/woocommerce/woocommerce-blocks/pull/2189)
* initial mapping out of stripe payment intents

* rename checkout processing statuses to be clearer

* Add new status and refactor checkout complete behaviour.

* Make sure payment result data is included in checkout processing response

* add payment intent handling

Still testing

* make sure promise is returned

* include site url with endpoint

* modify setComplete status to optionally receive redirectUrl for changing in state at the same time as setting status

* fix typo in property retrieval

* add error handling for after checkout processing event

* add notices area for payment methods

* implement error handling for stripe intents

* hook into stripe error processing and include error in payment response

* clear notices so they don’t show in block and merge payment details

* add notice handling to payment context

* modify error processing in checkout processor

* handle errors with fallback in checkout state context

* hook into after processing for stripe cc error handling

* set checkout to idle status if before processing emitters result in error

* Add emit response type-defs and normalize expectations for observer responses

* improve doc block

* switch checkoutIsComplete check to checkoutAfterProcessing for payment complete status change

* remove unneeded event emitters and consolidate some logic

* fix idle status set logic
2020-04-14 12:52:23 -04:00
renovate[bot] 6b63f19fcb Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/2198)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-14 15:19:48 +01:00
Mike Jolley 31b45a0989 Create block-assets.md
Syncing with hackmd
2020-04-14 13:12:59 +01:00
Albert Juhé Lluveras 923eef90ee Fix build styles incosistencies (https://github.com/woocommerce/woocommerce-blocks/pull/2208)
* Prevent select label/value breaking in two lines

* Make sure frontend and base styles are loaded in the same order

* Use link-button mixin for address button

* Refactor shipping rates control CSS to decrease specificity and overwrites

* Refactor sidebar panel CSS to decrease specificity and overwrites

* Fix link-button vertical-align
2020-04-14 13:43:10 +02:00
Seghir Nadir 32b80c40bb respect SHIPPING_ENABLED in Cart and Checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2202) 2020-04-14 08:01:59 +02:00
Darren Ethier 70f8b48165 implement editor previews for stripe cc and check payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/2190) 2020-04-14 08:01:29 +02:00
Seghir Nadir a00d06b7f2 Use icons directly from stripe (https://github.com/woocommerce/woocommerce-blocks/pull/2188)
* use icons from stripe

* rename classes

* use object instead of array

* update jsdocs
2020-04-09 15:31:03 -04:00
Mike Jolley c26fae204b Sync name and company to account (https://github.com/woocommerce/woocommerce-blocks/pull/2187) 2020-04-09 14:04:00 -04:00
Albert Juhé Lluveras c035a578a8 Fix currency format in On Sale badge (https://github.com/woocommerce/woocommerce-blocks/pull/2185)
* Fix currency format in On Sale badge

* Add back translators comment

* Use self-closing tag
2020-04-09 18:53:22 +02:00
Albert Juhé Lluveras 0663ac7f6f Prevent auto-scroll to invalid fields (https://github.com/woocommerce/woocommerce-blocks/pull/2184) 2020-04-09 18:42:53 +02:00
Darren Ethier e21883d69c Refactor logic for handling active payment method with express payment methods via checkout (https://github.com/woocommerce/woocommerce-blocks/pull/2170)
* remove logic server side for getting payment method from paymentdata

* ensure stripe accounts for payment request type payment methods

* make sure legacy payment method handling always runs last

* add processedPaymentMethodId to payment method data context state

* switch checkout processor to use new processedPaymentMethod id for submission

* implement returning paymentMethodId from payment-request-express

* include paymentMethodId in stripe cc success return value

* include paymentMethodId in cheque success return value

* add active payment method setting and handling via checkout

express payment methods still need to implement:

- onClick when their button is clicked
- onClose when the express payment interface is closed (cancelled etc).

* don’t expose setActivePaymentMethod on the payment method interface

* remove/fix artifacts from earlier iterations of the pull

* rename `id` property to `name` property for payment method registration

* Revert "include paymentMethodId in cheque success return value"

This reverts commit fe4ee8aced6d67bbd9033263ce61844349d18250.

* Revert "include paymentMethodId in stripe cc success return value"

This reverts commit 359a1f0089866110ec204182f8ffa14ab099c425.

* Revert "implement returning paymentMethodId from payment-request-express"

This reverts commit 117c68980b0876dee0acc78cec7754ccfe2a9bb1.

* Revert "switch checkout processor to use new processedPaymentMethod id for submission"

This reverts commit c38a05b63626dfc1336c7bb0e86417b798a803d6.

* Revert "add processedPaymentMethodId to payment method data context state"

This reverts commit 3d7923e7297f3c76efde536d26eaf68464ba9583.

* improve isSuccess response check and variable name

* implement paymentMethodId config option

* doh php ain’t javascript

* add missing dependency from rebase
2020-04-09 11:22:34 -04:00
Seghir Nadir 9e1adb7ea8 fix broken labels on twentyTwenty (https://github.com/woocommerce/woocommerce-blocks/pull/2181) 2020-04-09 15:26:16 +01:00
Albert Juhé Lluveras 93764f9f89 Check if cart needs payment before showing payment methods (https://github.com/woocommerce/woocommerce-blocks/pull/2177)
* Check if cart needs payment before showing payment methods

* Fix tests
2020-04-09 16:01:11 +02:00
Mike Jolley c02a7cb115 Update cart after conflicts (https://github.com/woocommerce/woocommerce-blocks/pull/2175)
* Return updated cart if there is a conflict (409 response) e.g. item no longer exists

* Receive updated carts

* Update tests and coupon handling

* Further rewording
2020-04-09 13:52:31 +01:00
Albert Juhé Lluveras fed597e5c8 Fix prices overflowing in some widths in the Order summary panel (https://github.com/woocommerce/woocommerce-blocks/pull/2178) 2020-04-09 13:50:00 +01:00
Mike Jolley 5e595d8794 Prevent data hydration on rest requests (https://github.com/woocommerce/woocommerce-blocks/pull/2176) 2020-04-09 13:51:27 +02:00
Darren Ethier 12b384374b Use cart data to provide country and currency_code for payment method registration config (https://github.com/woocommerce/woocommerce-blocks/pull/2169)
* use cart data to provide country and currency_code

* remove files that likely got added back in from a bad rebase.

* modify canMakePayment config property so it must be a function

* Feed cart data to registered payment methods `canMakePayment` function.

This can then be used by payment methods for determining whether to show the payment method or not.

* implement new canMakePayment signature for cheque

Now canMakePayment doesn’t need to be a promise (payment method registry will handle wrapping all values in a promise to treat them as promises.

* implement canMakePayment as a function
2020-04-09 07:44:29 -04:00
Darren Ethier d79f5ab271 Convert apple pay integration to payment request integration and finish implementation (https://github.com/woocommerce/woocommerce-blocks/pull/2127)
* add logic allowing payment method to be overridden via payment data in request

* hook in to trigger server side processing of stripe payment request

* improvements to shipping data context

- memoize event emitters
- split up emitted events (reduces how often events trigger)
- Include whether rate is being selected in exported data.

* expose `isSelectingRate` value to payment method interface

* fix typo in shipping emitters for emitter type

* include setting of shipping data in payment method success status call

- this also requires changing the nested order of providers in checkout provider

* fix priority logic for event emitters.

- lower priority is supposed to fire before higher priority.

* normalize postal code for comparisons

* move normalize functions into stripe-utils folder

* refactor stripePromise so that it provides a specific instance to each payment method.

This also provides it as a prop to the pm components.

* renadme apple pay express to payment request express

This adds full support for the stripe payment request api instead of just applePay (so GooglePay, MicrosoftPay and ApplePay are now supported).

Also adds numerous fixes to internal logic.

* add handling to skip core checkout validation logic if express payment method is handling payment

Express payment methods have their own internal validation so this removes the need for checkout validating fields. This is also necessary because checkout validation breaks the flow when making a payment using express payment methods because of the order of the flow for these methods.

* splitting out emmitter effects for checkout and improving logic

Splitting up effects limits the potential for firing off emitters more than needed.

* remove unnecessary ref definitions

* fix on cancel action erroring for payment request modal

* ensure unique stripe object for component and canPay

* set default total label if one isn’t configured on the server

* fix order of state changes

* simplify condition

* remove unnecessary dependency

* normalize to uppercase too

* simplify can make payment conditional

* update comment blocks
2020-04-08 12:36:04 -04:00
Darren Ethier bfdfa2f603 Move calculating state outside of checkout state (https://github.com/woocommerce/woocommerce-blocks/pull/2163)
* remove calculating as a checkout status (making it separate)

* include checkout is calculating for determining whether to flip payment status to process

* only change payment method state for status changes if needed

* fix reducer for shipping state

* include checkoutIsCalculating for determining whether to show validation errors in checkout block

* change where currentStatus is defined

* fix bug with saved payment method option
2020-04-08 11:46:34 -04:00
Albert Juhé Lluveras 10851a4e00 Handle errors in processOrder (https://github.com/woocommerce/woocommerce-blocks/pull/2156)
* Handle errors in processOrder

* Move scroll to top handler higher so error notices are visible

* Improve error messaging
2020-04-08 17:29:48 +02:00
Mike Jolley 4a8609737d Increase specificity of wc-block-totals__change-address-button (https://github.com/woocommerce/woocommerce-blocks/pull/2162) 2020-04-08 17:23:17 +02:00
Mike Jolley 55d0067426 Update previews and editor styles for cart and checkout blocks (https://github.com/woocommerce/woocommerce-blocks/pull/2160)
* Update cart block editor styles to more closely match frontend

* Checkout editor styles

* Add image assets for previews and correct totals

* Add new previews

* Cart Preview

* Checkout preview

* Remove optional chaining
2020-04-08 16:03:39 +01:00
Mike Jolley 45fdcf16fc Render the shortcode if on an endpoint page (https://github.com/woocommerce/woocommerce-blocks/pull/2161) 2020-04-08 15:51:44 +01:00
Mike Jolley d73d9ca12e Refactor some of the shipping hooks/context usage (https://github.com/woocommerce/woocommerce-blocks/pull/2146)
* Counting helpers for shipping rates and packages

* Use new helpers

* Make shipping calculator use shipping context directly

* Totals should use current address

* Avoid useShippingRates

* Return rates and other items from useShippingRatse in useStoreCart instead

* Update tests

* Merge conflict

* Merge conflict
2020-04-08 12:20:41 +01:00
renovate[bot] 9a4fc8e2cc Update dependency @stripe/stripe-js to v1.3.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2150)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-08 12:20:31 +01:00
Mike Jolley bb20212390 Fix cached shipping fees on consecutive orders (https://github.com/woocommerce/woocommerce-blocks/pull/2144)
* Rest API - Ensure totals are up to date on init

* Update cart controller to bail if the cart does not need shipping

* Update todos and wc supported version to match status of core

* Add todos

* Fix customer address population

* exit early
2020-04-08 11:23:25 +01:00
renovate[bot] bbf19ed59f Update dependency @stripe/react-stripe-js to v1.1.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2149)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-08 11:21:15 +01:00
renovate[bot] 0742e8a3aa Update dependency @babel/preset-env to v7.9.5 (https://github.com/woocommerce/woocommerce-blocks/pull/2148)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-08 11:20:39 +01:00
renovate[bot] f9a754ea40 Pin dependency source-map-explorer to 2.4.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2147)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-08 11:20:22 +01:00
renovate[bot] be35f98b06 Update dependency @types/jest to v25.2.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2152)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-08 11:19:56 +01:00
Albert Juhé Lluveras db4f7820c6 Use new util functions in ShippingRatesControl (https://github.com/woocommerce/woocommerce-blocks/pull/2153)
* Use new util functions in ShippingRatesControl

* Import from base-utils
2020-04-08 11:19:05 +01:00
Mike Jolley 0000cac384 Don't show "select" labels for shipping or payment method steps if there is only one option (https://github.com/woocommerce/woocommerce-blocks/pull/2133)
* Only show descriptions if shipping/payment methods > 1

* Hide descriptions if no description text is set

* Fix object length

* methods->options

* Counting helpers for shipping rates and packages

* Use new helpers
2020-04-08 10:00:31 +02:00
Rua Haszard 0b956e1a4f Revert "show a "preview" saved card in the editor (first cut!)"
This reverts commit f409908eda.

(Accidental push to master)
2020-04-08 12:12:00 +12:00
Rua Haszard f409908eda show a "preview" saved card in the editor (first cut!) 2020-04-08 12:04:23 +12:00
Seghir Nadir 736d437316 Get preview data from Editor Context / (https://github.com/woocommerce/woocommerce-blocks/pull/2134)
* move preview to editor data and alias it no nothing in frontend builds

* seperate context and provider

* pass previewData as a prop to provider

* address comments
2020-04-07 16:41:22 +01:00
Albert Juhé Lluveras 5bcdc8f84a CheckboxControl: stop using Gutenberg's CheckboxControl (https://github.com/woocommerce/woocommerce-blocks/pull/2137)
* CheckboxControl: stop using Gutenberg's CheckboxControl

* Simplify styles and make them work fine in the editor
2020-04-07 16:37:03 +01:00
Mike Jolley 8ae3e1d195 Show "save payment information" checkbox only if customer ID > 0 (https://github.com/woocommerce/woocommerce-blocks/pull/2138)
* Add customer ID to checkout API response

* Add customer ID to checkout context

* Show/hide remember payment checkbox based on checkout context

* Pass via payment interface instead

* Missing commas
2020-04-07 15:29:59 +01:00
Seghir Nadir 5160d9d794 Disable continue to checkout if Item quantity is being updated and immediately remove items. (https://github.com/woocommerce/woocommerce-blocks/pull/2106)
* disable continue to checkout if item is being removed

* rename isPending and selectors/actions to isPendingDelete

* switch itemPendingDelete params order

* change to watching quantity changes not removal

* yield RECEIVE_REMOVED_ITEM

* update types and add return to select

* update tests

* switch params back

* only delete item after response from server

* update tests

* handle errors and unrelated unmounts

* disable row if is loading
2020-04-07 12:03:22 +01:00
Rua Haszard 3f0dcf00bc Revert "Record a tracks event when merchant toggles cart shipping calculator: (https://github.com/woocommerce/woocommerce-blocks/pull/1975)" (https://github.com/woocommerce/woocommerce-blocks/pull/2136)
This reverts commit 7921c3e5ba.
2020-04-07 12:11:14 +02:00
Jason Conroy dc8cc7681f Update CONTRIBUTING links (https://github.com/woocommerce/woocommerce-blocks/pull/2135) 2020-04-07 09:56:17 +02:00
Albert Juhé Lluveras 8c7d4805a4 Show validation errors again (https://github.com/woocommerce/woocommerce-blocks/pull/2124)
* Make validation errors appear

* Make validation errors appear all at once

* Simplify diff

* Expose shippingErrorStatus from shipping context

* Memoize currentErrorStatus

* Pass currentErrorStatus to observers

* Add missing type-def property

* Fix typo in constant name

* Refactor emitEvent so false responses don't return true

* Make onCheckoutProcessing observers return errorMessage and validationErrors properties
2020-04-06 16:36:19 -04:00
Mike Jolley 9085f8aa8d Bump required jetpack autoloader version (https://github.com/woocommerce/woocommerce-blocks/pull/2132) 2020-04-06 17:37:23 +01:00
Seghir Nadir 0ca78dd654 Remove Keep me updated (https://github.com/woocommerce/woocommerce-blocks/pull/2057)
* remove checkbox of keep me updated

* remove double margin on useSameForBilling
2020-04-06 16:57:38 +01:00
Mike Jolley 5d2a630a07 Use mousedown event so view switches before blur event prevents the switch (https://github.com/woocommerce/woocommerce-blocks/pull/2129) 2020-04-06 16:36:03 +01:00
Mike Jolley cc3ed31feb Disable checkout form in the editor (https://github.com/woocommerce/woocommerce-blocks/pull/2128)
* Move no-shipping-placeholder to block - allow pointer events

* Allow payments placeholder to have pointer events

* Enable pointer events for children

* Wrap checkout with disabled
2020-04-06 16:35:09 +01:00
Darren Ethier 22ea154c6f Implement stripe server-side handling (stripe cc) (https://github.com/woocommerce/woocommerce-blocks/pull/2120)
* remove usage of paymentstatus dispatcher from apple pay

* add type-def for payment data response objects

* make sure shape of payment data for stripe cc is as server expects

* include payment data in checkout processor request

* fix bug that got reintroduced in rebase

* rename typedef
2020-04-06 08:44:00 -04:00
Darren Ethier d108e5ea96 Update stripe payment methods to work with new event emitters (https://github.com/woocommerce/woocommerce-blocks/pull/2115)
* Add interface for setting an express payment error notice.

* fix typedefs

* remove usage of paymentstatus dispatcher from stripe cc

* remove usage of paymentstatus dispatcher from apple pay

* remove any existing express payment notice on click

* revert buggy change with abort payment call

- also ensure that completePayment sets applePayProcessing to false
2020-04-06 08:18:35 -04:00
Mike Jolley 3ac335e1f9 Storefront compatibility for sticky proceed to checkout button on mobile (https://github.com/woocommerce/woocommerce-blocks/pull/1999)
* Storefront compatibility

* Remove storefront actions
2020-04-06 07:50:33 -04:00
Darren Ethier 4baa99cf65 Refactor payment method interface to remove payment status dispatcher (https://github.com/woocommerce/woocommerce-blocks/pull/2116)
* don’t expose payment method status dispatcher on payment method interface

* update apple-pay-express to use new currentPaymetnStatus object shape
2020-04-06 07:28:46 -04:00
Mike Jolley d637c28d62 Update add to cart to useStoreCart hook (https://github.com/woocommerce/woocommerce-blocks/pull/2103)
* Switch add to cart events to useStoreCart hook

* Add to cart endpoint

* Inject dependenct schemas

* Feedback, cart items are based on product schema

* Variable typo

* Move hook to base

* Update totals correcrly

* Update tests to use schema/routes class

* Update tests to correctly use schema

* Remove type hint to prevent strict standards error
2020-04-06 11:36:28 +01:00
Seghir Nadir ea703c4a13 Add forcing source map on production to analyze tree-shaking (https://github.com/woocommerce/woocommerce-blocks/pull/2117)
* add forcing source map on production

* rename command to explore
2020-04-06 10:00:47 +01:00
Darren Ethier 4f990fd475 switch from event subscription to status watch (https://github.com/woocommerce/woocommerce-blocks/pull/2119) 2020-04-04 13:36:46 -04:00
renovate[bot] e54e08bccf Update npm to v6.14.4 (https://github.com/woocommerce/woocommerce-blocks/pull/1989)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-03 14:58:32 +01:00
Albert Juhé Lluveras 72801baf97 Switch 'Try reloading the page' from links to buttons (https://github.com/woocommerce/woocommerce-blocks/pull/2105)
* Switch 'Reload page' from links to buttons

* Rename class to wp-block-link-button

* Remove no longer needed CSS property
2020-04-03 15:22:56 +02:00
Mike Jolley d83214ed44 Ensure `AbstractBlock::enqueue_data` is only run once in the editor request. (https://github.com/woocommerce/woocommerce-blocks/pull/2113)
* Enqueue assets once

* Updates classes extending AbstractBlock to use enqueue_scripts
2020-04-03 14:17:32 +01:00
Albert Juhé Lluveras 8a78371703 Checkout: fix skeleton and responsive styles (https://github.com/woocommerce/woocommerce-blocks/pull/2109) 2020-04-03 14:17:09 +01:00
Darren Ethier 30fb8bef28 Fix flaw with event emitters and complete checkout flow for the cheque payment method. (https://github.com/woocommerce/woocommerce-blocks/pull/2108)
* Allow for priority to be set on event emitters

* Add payment event emitters

* add new actions/status to checkout state context

* implement event emitters in payment data context

* refactor checkout state context to use new actions in event emitters

* refactor checkout processor to handle new event emitters

* fix type-defs for registered payment methods

* register observer for cheque payment method integration

* add inline todo

* fix sort

* fix tests and add test for priority usage in event emitters

* remove todo and just add explanatory comment

* condense sort logic

* lowercase test description

* abstract emitter callback to reduce code

* don’t process passed in errors if it’s undefined

* improve error response expectation for payment processing event observer
2020-04-03 07:50:54 -04:00
Seghir Nadir c361a158c4 Respect needs_shipping in Cart and Checkout (https://github.com/woocommerce/woocommerce-blocks/pull/2101)
* replace SHIPPING_ENABLED with needsShipping

* rename needsShipping variable

* only show shipping in checkout sidebar if we need shipping
2020-04-02 18:10:36 +01:00
Seghir Nadir cede3a0acf disable proceed to checkout if rates are loading or being selected (https://github.com/woocommerce/woocommerce-blocks/pull/1978)
* disable proceed to checkout if isCalculating is true

* add checkout provider

* remove unnecessary duplicate checkout count increment/decrement.

* remove redudant checkoutProvider

* remove already handled todo

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-02 18:05:08 +01:00
Mike Jolley f0b4be8bc8 Add Payment Methods Registry for registering scripts and data (https://github.com/woocommerce/woocommerce-blocks/pull/2090)
* Added cheque gateway and payment method registration system

Fix promises

Remove log

Use status, not checkoutstate

Bug @nerrad showed me

Payment method type registry

Refactor integrations to register themselves.

Stripe and Cheque Integrations/registration

Splt gateways into separate files on build

Add settings from server to cheque gateway

Merge apple and credit card stripe scripts

* Missing files from rebase

* Tweaks to payment-methods-registry (https://github.com/woocommerce/woocommerce-blocks/pull/2091)

* Small tweaks and docblock updates

* Handle undefined settings

* rebase fix

* Simplify promise

* Remove filesuffix for payment methods config

* Fix typo

* Rebase fix

* Update cart and block actions

* Add woocommerce_blocks_payment_method_type_registration

* Missing method names

* Missing name in stripe

* replace actions with script dependencies

* Scripts are needed in admin context too, by default

* Put back the hooks...

* Add is_active check to see if assets need to be enqueued or not

Co-authored-by: Darren Ethier <darren@roughsmootheng.in>
2020-04-02 18:04:15 +01:00
Seghir Nadir 0ac3300ebf fix broken e2e-tests (https://github.com/woocommerce/woocommerce-blocks/pull/2102) 2020-04-02 16:10:27 +01:00
renovate[bot] 11a63860a9 Update babel monorepo (https://github.com/woocommerce/woocommerce-blocks/pull/2014)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 15:10:55 +01:00
Mike Jolley 8468869319 Cart item validation and notices in cart/checkout (https://github.com/woocommerce/woocommerce-blocks/pull/2079)
* Add error handling to cart API

* Handle new error codes in checkout

* Display errors in cart

* Fix failing test

* Move error codes to constants
2020-04-02 15:04:43 +01:00
renovate[bot] 95c1a53b2f Update dependency @types/react to v16.9.31 (https://github.com/woocommerce/woocommerce-blocks/pull/2015)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:50:15 +01:00
renovate[bot] fd6c4b2e73 Update dependency autoprefixer to v9.7.5 (https://github.com/woocommerce/woocommerce-blocks/pull/2016)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:48:33 +01:00
renovate[bot] cfb4d83d2c Update storybook monorepo to v5.3.18 (https://github.com/woocommerce/woocommerce-blocks/pull/1990)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:47:50 +01:00
Albert Juhé Lluveras 503fb9bd70 Update Checkout skeleton to match layout introduced in woocommerce/woocommerce-blocks#2041 (https://github.com/woocommerce/woocommerce-blocks/pull/2099) 2020-04-02 14:40:49 +01:00
renovate[bot] 2117453656 Update mariadb Docker tag to v10.5 (https://github.com/woocommerce/woocommerce-blocks/pull/1988)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:40:27 +01:00
renovate[bot] 3958de2f88 Pin dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/2084)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:39:33 +01:00
renovate[bot] d98a0d89f9 Update dependency eslint-config-prettier to v6.10.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2086)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 14:38:59 +01:00
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
renovate[bot] 837a52f44f Update dependency config to v3.3.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2085)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 10:36:41 +02:00
renovate[bot] 6e70e3b9c1 Update dependency jest to v25.2.4 (https://github.com/woocommerce/woocommerce-blocks/pull/2087)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-04-02 10:33:47 +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
Darren Ethier 355c1269d8 Implement mechanism for reliably passing through server data in editor context. (https://github.com/woocommerce/woocommerce-blocks/pull/2076)
* add method for enqueueing editor assets for the block editor

* configure Checkout to ensure editor assets are loaded in the block editor.

* move common functions to abstract

* ensure cart has server data passed through to editor

* ensure `enqueue_data` is only ever called once.

* make sure we enqueue data for cart

* add missing attributes arg

* remove logic that doesn’t do anything
2020-03-31 09:20:49 -04:00
Seghir Nadir 0046b73bbf delete passed arg to useShippingRates since it's not needed 2020-03-31 13:22:41 +01:00
Seghir Nadir 868f21c62c dont include stripe with Cart block 2020-03-31 13:21:25 +01:00
Darren Ethier 6c75dd9eae make sure payment method assets are loaded in block editor (https://github.com/woocommerce/woocommerce-blocks/pull/2075) 2020-03-31 12:56:32 +01:00
Rua Haszard 9d2fec68d0 add extra checks to checkout/cart/order APIs to avoid editor errors (https://github.com/woocommerce/woocommerce-blocks/pull/2072)
* add extra checks to checkout/cart/order APIs to avoid editor errors

* remove redundant register_block_script, introduced in rebase of woocommerce/woocommerce-blocks#2071

* prevent JS errors in checkout block in editor:
- add fallback state in defaults
- this is needed because checkoutData setting is null in admin

* Revert "add extra checks to checkout/cart/order APIs to avoid editor errors"

This reverts commit a26045b4a4675eb90b6b7235e2df0d29ca776915.

* Revert "prevent JS errors in checkout block in editor:"

This reverts commit 79729617f17c855ad71938af7703119fa5ccdabf.

* Hydrate from API conditonally

Co-authored-by: Mike Jolley <mike.jolley@me.com>
2020-03-31 11:57:28 +01:00
Albert Juhé Lluveras 4d19b0a18a Add 2.5.15 changelog 2020-03-31 12:54:12 +02: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
Mike Jolley bf8715707d [Experiment] Add container to run php unit tests in docker (https://github.com/woocommerce/woocommerce-blocks/pull/2004)
* Add container to run php unit tests in docker

* Improvemnets to entrypoints

* Simplfiy dockerfile
2020-03-31 11:47:40 +01:00
Albert Juhé Lluveras 6df879a922 Load product grid styles in WP <=5.2 (https://github.com/woocommerce/woocommerce-blocks/pull/2000)
* Load product grid styles in WP <=5.2

* Explicitly exclude 'product-list-style' from default builds
2020-03-31 12:46:38 +02:00
Darren Ethier f2b5448c66 Revert "Ensure woocommerceanalytics checkout event fires for checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/2038)"
This reverts commit 5d4ae04a3f.
2020-03-31 06:44:31 -04:00
Rua Haszard 5d4ae04a3f Ensure woocommerceanalytics checkout event fires for checkout block (https://github.com/woocommerce/woocommerce-blocks/pull/2038)
* fire woocommerce_after_checkout_form hook after checkout block

* fix bad whitespace after rebase
2020-03-31 10:44:23 +13:00
Rua Haszard 71beb6163f Add storybook info to dev docs (https://github.com/woocommerce/woocommerce-blocks/pull/2051)
* add basic doc for storybook

* link to storybook from main doc
2020-03-31 08:38:11 +13: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
Mike Jolley 676e10b805 Update checkout API endpoint to process orders (https://github.com/woocommerce/woocommerce-blocks/pull/2011)
* Add processing logic

* Add WOOCOMMERCE_STORE_API_DISABLE_NONCE_CHECKS constant

* Processing fixes

* Responses

* Legacy and updated payment processing

* Customer updates
2020-03-27 11:36:45 +00: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
renovate[bot] e61a098d84 Update dependency dinero.js to v1.8.1 (https://github.com/woocommerce/woocommerce-blocks/pull/2017)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-25 16:40:11 +00: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
renovate[bot] f8e05ef09d Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/2008)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-23 11:54:24 +00: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
Darren Ethier d07b7c6b52 Add badges to readme (https://github.com/woocommerce/woocommerce-blocks/pull/2007)
* add badges to readme

* fix travis badge
2020-03-22 12:47:23 -04:00
Darren Ethier 114cb63f51 try another configuration 2020-03-22 12:31:57 -04:00
Darren Ethier 71faf76a89 fix travis config for deploy step
Since the defined language is php, travis will attempt to run phpunit by default as the script. So we need an empty script config for the deploy stage.
2020-03-22 12:02:05 -04:00
Darren Ethier 7525028fbf build storybook to github pages on pushes to master (https://github.com/woocommerce/woocommerce-blocks/pull/2006) 2020-03-22 11:40:42 -04:00
Darren Ethier 41b774a3e7 Add bundle size github workflow (https://github.com/woocommerce/woocommerce-blocks/pull/2005)
* Add bundle size github workflow

This workflow implements a bundle-size monitoring utility for our repository to give better metrics on increases in bundle-sizes. I basically copied the configuration for the WordPress gutenberg project workflow and it utilizes the [`preactjs/compressed-size-action`](https://github.com/preactjs/compressed-size-action).

If this works well, it will replace our existing bundlesize implementation.

* remove bundlewatch and related scripts

* more lint job fixes

- remove build:ci because it was only used for bundlesize check. No need to build files for linting checks.
- add lint:ci npm script for doing build lint checks
- update travis job config to use new script and update title

* change name of workflow
2020-03-21 12:10:53 -04: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
renovate[bot] a630ebfc2d Pin dependencies (https://github.com/woocommerce/woocommerce-blocks/pull/1985)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-18 18:02:55 +01:00
renovate[bot] d04296fc68 Update dependency use-debounce to v3.4.0 (https://github.com/woocommerce/woocommerce-blocks/pull/1987)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-18 18:02:31 +01:00
renovate[bot] 11cff899f8 Update dependency bundlewatch to v0.2.6 (https://github.com/woocommerce/woocommerce-blocks/pull/1986)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-18 18:01:33 +01: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
Mike Jolley 8d76bcb33e Update Cart Order and Checkout Routes (https://github.com/woocommerce/woocommerce-blocks/pull/1958)
* Remove CartShippingRates endpoint

This was moved to the /cart endpoint

* Unused customer endpoint

* Split controllers into routes

* Update/fix tests

* Add draft order ID property to the Cart schema.

* Fix status check

* cart/order-create endpoint

* Placeholder for checkout endpoint

* Resolve merge conflict

* Update classes to match master

* Use correct schema
2020-03-16 12:44:00 +00:00
renovate[bot] 757aea3d34 Lock file maintenance (https://github.com/woocommerce/woocommerce-blocks/pull/1974)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-16 11:48:23 +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
Mike Jolley c20f1bd7bf Break down Store API controllers into specific routes (https://github.com/woocommerce/woocommerce-blocks/pull/1957)
* Remove CartShippingRates endpoint

This was moved to the /cart endpoint

* Unused customer endpoint

* Split controllers into routes

* Update/fix tests

* Create RouteException and single handler per route

* Move exception to cart controller
2020-03-13 12:41:01 +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
renovate[bot] 47025baeb2 Update dependency webpack to v4.42.0 (https://github.com/woocommerce/woocommerce-blocks/pull/1935)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-12 11:32:03 +01:00
renovate[bot] dc0878aa52 Update dependency webpack-cli to v3.3.11 (https://github.com/woocommerce/woocommerce-blocks/pull/1936)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-12 11:01:53 +01:00
renovate[bot] e9826817b2 Update dependency typescript to v3.8.3 (https://github.com/woocommerce/woocommerce-blocks/pull/1934)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-12 11:01:27 +01:00
renovate[bot] fc44104ccf Update dependency eslint-plugin-jest to v23.8.2 (https://github.com/woocommerce/woocommerce-blocks/pull/1933)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-12 11:00:01 +01: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
renovate[bot] 401fe1d6c5 Update dependency @types/jest to v25.1.4 (https://github.com/woocommerce/woocommerce-blocks/pull/1932)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-12 10:59:33 +01:00
renovate[bot] 67c6ee2e2a Update babel monorepo to v7.8.7 (https://github.com/woocommerce/woocommerce-blocks/pull/1931)
Co-authored-by: Renovate Bot <bot@renovateapp.com>
2020-03-12 10:58:47 +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
Albert Juhé Lluveras 2f58d86fa6 Update build-plugin-zip.sh intro text (https://github.com/woocommerce/woocommerce-blocks/pull/1922) 2020-03-10 11:35:17 +00: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
Darren Ethier b6c0ce4299 bump up budget for checkout-frontend.js script (https://github.com/woocommerce/woocommerce-blocks/pull/1912) 2020-03-09 15:14:48 -04: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