Giter VIP home page Giter VIP logo

checkout-system's Introduction

Checkout System

This project implements the checkout logic with discount and deals applied.

Project setup

  • Run npm install
  • Run npm start
  • Browser will be automatically launched. If not, go to http://localhost:3000/

Project Detail

According to the level of the user (Associate or Diamond), the discounted amounts are pre-configured as 5% for Associate and 20% for Diamond.

Initial Page

Two products are initially included. Quantity can be increased or decreased by clicking on + and - buttons respectively for each product. Once quantity is greater than zero, different discount and deal logics will be applied.

Associate User

For Associate user, only discount 5% will be applied for products.

Diamond User

For Diamond user, both special deals and discount logics will be considered and applied according to the quantity specified.

Deals

  • Get a discount on Kone where 3 or more purchased. The price dropped to RM 2588.99 per unit
  • Get a 3 for 2 deal on Ironhide Cartridge

Test case

  • RECIPIENT: Diamond
  • Cart Items: Kone, Kone, Kone, Kone, Ironhide Cartridge
  • Total Expected: RM 10779.95

Diamond User

For testing purpose, user level selector is included in the top right corner.

Deals Negotiation

Currently, how to discount price according to deals is specified as below.

{
    id: 2,
    name: 'Ironhide Cartridge',
    price: 529.99,
    currency: 'RM',
    quantity: 0,
    discount: [
        // For Diamond Level user, if they buy 3 items, they will only have to pay for 2.
        {
            level: USER_LEVEL.DIAMOND,
            type: DISCOUNT_TYPE.DEAL,
            buy: 3,
            pay: 2,
        },
    ],
}

For easy configuration, different deal types can be specified to differnt level of users. Deal logic will be applied in calculating the subtotal.

Testing

Testing is done by @testing-library/react and tests are defined in __test__ folders for respective react functional components at both page level and component level. Tests can be checked by running npm test or npm run test.

Test

checkout-system's People

Contributors

arkarmintun1 avatar

Watchers

James Cloos avatar  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.