Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIF-965 - Implement client side checkout for CIF #106

Merged
merged 80 commits into from Sep 9, 2019
Merged

Conversation

dplaton
Copy link
Contributor

@dplaton dplaton commented Aug 30, 2019

This PR is huge because it contains all the React components needed to render the MiniCart.

Description

The MiniCart is a React app which renders in the minicart placeholder div. The component uses React hooks provided by Apollo to fetch/mutate cart data.
The "Cart Trigger" icon has been converted to a React component as well because it was easier to interact with it (change the style when there are items in cart and increase de cart counter). The "Cart Trigger" is rendered in the header using React Portals .
The Add to cart button has been updated to work with the new minicart component.

The checkout process is covered by the Checkout component and it's driven by GraphQL queries.

How to test it on a local instance

Prerequisites:

  • Make sure you have a CIF project using the latest release of aem-core-cif-components.
  • Make sure you have a Mangento 2.3.2 instance running on HTTPS
  • Make sure you have your dispatcher set up
  • (Optional) Make sure you have the repo command installed so that the build process can push the clientlib to AEM

Once the above requirements are met go to ui.apps/src/main/javascript/minicart and run

yarn install && yarn build:clientlib

The build:clientlib command will copy the files from the ./dist folder to the clientlib and also run the repo command to upload them to AEM. If you don't have repo utility installed then you can just copy the ./dist folder in ./ui.apps/src/main/content/jcr_root/apps/core/cif/components/commerce/minicart/v1/minicart/clientlib and then install the components content-package.

Leftovers

There are still some minor things to do:

  • the styles are not 100% on par with Venia, especially the loading states.
  • there are no tests yet

There are also some things that could be done better, such as leveraging React Context instead of just passing function handlers along a (quite deep) tree of components.

Related Issue

CIF-961 / CIF-965

Motivation and Context

Align with the technology used by Magento PWA

How Has This Been Tested?

Functional testing

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have signed the Adobe Open Source CLA.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes and the overall coverage did not decrease.
  • All unit tests pass on CircleCi.
  • I ran all tests locally and they pass.

Remove old minicart component client-library
Bootstrap the new React project for the MiniCart component. Both components (MiniCart and Checkout) will live in the same React project and will be rendered in AEM by the same component (minicart).
Rename the output file to `index`.
Update `.gitignore`
Expand the Webpack configuration to extract accompanying styles.
Add eslint rules
Remove the component from the webpack config of the content package.
Add the components required to render a minicart and wire them to the Apollo provider.
Add context menu for product
Add product image (doesn't work ATM).
Update the `postbuild` script to also deploy the client library to AEM
Implement the drop-down menu for cart items.
Add the mutation to remove an item from the cart.
Get rid of the initial container component, it brought nothing to the table.
Switch from the `useQuery` hook from Peregrine to the one in Apollo.
Start implementing the "Edit item" feature
Fix the issue with the images not being displayed in the minicart
Add the 'Add to cart' capability. The 'Add to cart' button has been updated to send an event instead of calling the MiniCart API
Replace the cart trigger with a React component so that it can interact with the Minicart component.
Add the totals panel in the minicart footer section
Fix the issue with the loading animation not showing up. Clean up the project
Read the cart id from the user cookie. If the cookie is not planted yet, create the guest cart and write the cookie.
Update the unit tests for the `Add to cart` component to test the new behavior of the component.
Follow-up on the review.
Clean-up linting warning, remove `console.log`s
Fix an issue with the prop types of the `Body` component which specified that `editItem.id` is required.

Fix an issue with the `useGuestCart()` hook.
…hQL API

Fix an issue which was causing an error to popup in the log, saying that the `Select` component was rendered with an invalid property (string instead of number)
Implement the functionality for the "Shipping Methods" form
Add the guest email on the cart.
Add the "Place order" feature. After the order, it just shows a receipt in the cart component.
Add the "Continue Shopping" button to the empty minicart
dplaton and others added 6 commits August 30, 2019 13:21
Add the 'Place Order' mutation.
Fix issues found during end-to-end testing
Fix small issues:
- setting the shipping method doesn't throw a method anymore
- disabled the "use" button when submitting the shipping address
- integrate minicart/checkout build into pom.xml
@codecov-io
Copy link

codecov-io commented Sep 2, 2019

Codecov Report

Merging #106 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff            @@
##             master     #106   +/-   ##
=========================================
  Coverage     82.63%   82.63%           
  Complexity      336      336           
=========================================
  Files            38       38           
  Lines          1307     1307           
  Branches        102      102           
=========================================
  Hits           1080     1080           
  Misses          158      158           
  Partials         69       69
Flag Coverage Δ Complexity Δ
#karma 93.61% <100%> (ø) 0 <0> (ø) ⬇️
#unittests 79.6% <ø> (ø) 336 <ø> (ø) ⬇️
Impacted Files Coverage Δ Complexity Δ
...merce/product/v1/product/clientlib/js/addToCart.js 96.42% <100%> (ø) 0 <0> (ø) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dea75b6...1824827. Read the comment docs.

@mhaack mhaack merged commit 7e3f585 into master Sep 9, 2019
@delete-merged-branch delete-merged-branch bot deleted the issue/CIF-965 branch September 9, 2019 08:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants