Skip to content

wangc9/delivery-fee-calculator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkedIn


Delivery fee calculator

Calculate the delivery fee with simple clicks


Table of Contents
  1. About The Project
  2. Getting Started
  3. Roadmap
  4. License
  5. Contact
  6. Acknowledgements

About The Project

Delivery fee calculator

This is a simplified delivery fee calculator. Users can type in the value of products, the distance of the delivery, the total number of products, and finally the favourable order time, to calculate the fee for delivering all the products. Users also have the chance to change the data if needed before calculating the final fees.

The calculator follows the following rules when calculating the fee:

  • If the cart value is less than 10€, the difference between the cart value and 10€ is added as a surcharge.
  • All orders within 1000 meters are charged a basic delivery fee of 2€. An additional 1€ is charged for every additional 500 meters. Additional distances less than 500 meters are rounded up and counted as full 500 meters.
  • If there are five or more items, each item above and including the fifth one is charged 50 cents. If the total number of items is more than 12, a separate 1,2€ is charged in addition to the surcharge for each item.
  • For orders whose order time is between 3 p.m. and 7 p.m. on Friday, the total fee is multiplied by 1.2.
  • The maximum possible delivery fee is 15€.
  • All orders with a cart value of more than 200€ enjoy free delivery.

When first loaded, the user is prompted to the front page to type in information. Note that the submit button is disabled at first. It will automatically be enabled once all input fields have received proper inputs. Wrong inputNormal input

After clicking the submit button, the user is prompted to confirm the input or cancel and re-enter the information.confirm input

If the user chooses to confirm the order, a new page will show up with the confirmed information and the final delivery fee. The user can then choose to return to the front page by pressing the return button.result page

(back to top)

Built With

  • Vite
  • React
  • Redux
  • React-Router
  • MaterialUI
  • Eslint
  • Prettier
  • Jest
  • Testling-Library
  • cypress

(back to top)

Getting Started

This project is deployed on Render. Note: The website is deployed using a free CPU thus it will take some time for the page to load! However, you could still try it locally. There are two options to deploy the project locally. You can use the Docker image provided in this project. It is also possible to try out the project without Docker. This project follows the Test-driven Development (TDD) practice. There are different types of tests in the project. Detailed instructions on how to run them are provided later.

Prerequisites

In order to run this project locally, Node.js is needed. Please have a look at the official website and install the latest LTS version Node 20. The Docker file provided has Node configured. Therefore, if you choose to use Docker, it is required that you have Docker additionally installed on your machine. To install Docker, please have a look at the official installation guide at Get Docker.

Installation

Using Docker

  1. Make sure that you have successfully installed Docker on your machine and that it can work properly. If this is not possible, please skip to Using own machine.

  2. At the root directory, run the following command to start the web page

    docker compose -f docker-compose.yml up --build

    The command will build an image and a container to run the webpage. Please note that the build process may take some time. Once the build process is finished, you should see information like the following appears in the terminal:

    INFO Accepting connections at http://localhost:3000

    After the aforementioned message has appeared, you can open the webpage at http://localhost:5173.

  3. After you've finished using the webpage, please use Ctrl + c in the same terminal that docker is running to stop the container.

Using own machine

  1. At the root directory, install all the dependencies used in this project

    npm install
  2. Method 1 Run the project with

    npm run build

    After the build has finished, run the following command

    npm run preview

    You should see messages like this after some time

    vite preview

    -> Local: http://localhost:4173

    After you've seen this message, you can view the web page at http://localhost:4173. This is a preview of the production version of the webpage.

    After you've finished trying the webpage, use Ctrl + c in the terminal to stop the webpage.

    Method 2 Run the project with

    npm start

    You should see something similar to this in your terminal:

    VITE v5.0.12

    ->Local: http://localhost:5173

    After seeing this message, you can open the webpage at http://localhost:5173. This method shows the development version of the webpage. After you've finished trying the webpage, use Ctrl + c in the terminal to stop the webpage.

Running unit and integration tests

  1. If you've previously used Docker, first use the following command at the root directory to install all packages

    npm install
  2. To run all the tests for this project, use

    npm run test

Running e2e tests

  1. At the root directory, run

    npm install

    if hasn't been done before to install all the packages needed

  2. Start the webpage according to the method chosen.

    Docker:

    docker compose -f docker-compose.yml up

    Own machine:

    npm start

    Make sure that the webpage is actually running before moving on to the next step

  3. If you prefer to use a UI for the e2e tests, in a new terminal at the root directory, run

    npm run cypress:open

    This command will prompt a window similar to the following one: cypress-front-page

    Choose E2E testing and choose one of the browsers listed on the next page. After the selection, the next page should look similar to the following: cypress-spec Choose the test file to start running the e2e tests.

    Alternatively, in a new terminal under the same root directory, run

    npm run cypress:run

    to run all the e2e tests in the terminal.

(back to top)

Roadmap

See the change log for a full list of changes.

See the reflection for a reflection on the project, including technology choices, experience, and possible improvements.

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Chen Wang - wang.756090@gmail.com

(back to top)

Acknowledgements

  • This project uses the material provided in Wolt's media kit.

(back to top)

About

A calculator for computing delivery fee

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published