Giter VIP home page Giter VIP logo

lerna-deity's Introduction

Product Reviews Plugin for falcon.deity.io platform

This plugin was written as an example on how we can implement different business requirements on a shop that has the FE built using falcon.de

Client requirements

On the product page (PDP) business wants to render the last 10 reviews of that product given by past clients. Display will be made as an accordion ( displaying only the email with button to show/hide the rest of the review )

Tech stach used

List of packages

  • deity-reviews-api - package that does the communication with the reviews servers to pull the reviews and give them back to the grapql client
  • deity-reviews-data - contains the graphql queries wrappers used by React frontend compoents to fetch info from graphql server
  • deity-reviews-extension - contains the graphql schema definition
  • deity-reviews-ui - implements the React components that displays the reviews received from graphql server

Quick start

Steps to quick install and use this component.

  • Clone the example shop falcon.deity from here: https://github.com/deity-io/falcon

    • use yarn instead of npm ( via npm can throuh some errors)
  • Inside the cloned folder navigate to examples/shop-with-blog/server folder.

    • Edit package.json and add these 2 packages under dependencies node:

      "dependencies": {
          ...
          "@npmapopovici/deity-reviews-extension": "0.0.16",
          "@npmapopovici/deity-reviews-api": "0.1.1"
      }
      • Please update 0.0.16 and 0.0.6 with the latest version of these packages if different
    • Edit config/default.json file. Under apis node add the reviewsapi node:

      "apis": {
          ...
          "reviewsapi": {
              "package": "@npmapopovici/deity-reviews-api",
              "config": {
                  "host": "jsonplaceholder.typicode.com",
                  "protocol": "https",
                  "apiPrefix": "/comments"
              }
          }

      and under extensions node add the reviews node:

      "extensions": {
          ...
          "reviews": {
              "package": "@npmapopovici/deity-reviews-extension",
              "config": {
                  "api": "reviewsapi"
              }
          }
    • From command line under ``examples/shop-with-blog/server` install server dependencies

      yarn install
      
  • Navigate to the examples/shop-with-blog/client folder.

    • Edit package.json file, under devDependencies node add 2 packages:
      "devDependencies": {
          ...
          "@npmapopovici/deity-reviews-data": "^0.0.18",
          "@npmapopovici/deity-reviews-ui": "^0.1.1"
      }
    • Install the newly added packages from command line inside client folder:
      yarn install
      
    • Edit this React file under client folder: src/pages/shop/Product.js.
      • Import the 'ProductReviews' component after the other imports but before const ProductPage:
        ...
        import { ProductReviews } from '@npmapopovici/deity-reviews-ui';
        
        const ProductPage = ({ match: { params } }) => (
            ...
        
      • Navigate throught the code and around line 57 after the <ProductDescription ... /> line add our ProductReviews:
        ...
        <ProductReviews productId={parseInt(product.id)} />
        ...
        
      • Try to see the network requests. The product.id is being matched to the postId on the reviews api. But the test reviews list only has postId's up to 100. If no reviews are being displayed on the page, replace parseInt(product.id) with any int value under 100. Usually browsing categories under "Gear" have products with id under 100.
  • Go to the root of the project where it was cloned ( you should see files like lerna.json, package.json) and from command line in this folder run "yarn run start". Once the server are up naviate to http://localhost:3000 and go to any PDP page.

lerna-deity's People

Contributors

popoviciandrei avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.