BoikoSV / zoo-market

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

To start the project, paste the command into the terminal: docker-compose up. You will be able to access the project at http://localhost:80.

The project consists of two parts, created as Docker containers. The frontend part was built using Vue, Vee Validate, Yup, Vuetify, and Vue3-toastify. When the frontend app is mounted, it fetches a list of companies from the backend and displays it in a dropdown select. There are some basic rules for validating inputs, such as requiring input and setting minimum and maximum weights. This data is stored on the frontend. When a user enters data into the inputs, Vee Validate checks the rules and can display errors if the data is not valid. If a user clicks the button to calculate the price and the data is not valid, Vue3-toastify displays a message that the data isn't valid. When a user inputs valid data and clicks the button, a request is sent to the route to calculate the price.

On the backend, there are two routes. One sends a list of available companies to the select dropdown, and the other calculates the price. To calculate the price, a ShippingService has been created, located in app/Services/Shipping/ShippingService.php. This file is responsible for the calculation service, but the main logic of the calculation is located in other classes. These classes are located in app/Services/Shipping/Providers. In this folder, there are several files. One of them is the abstract file ShippingProvider.php, which describes the interface for the child classes. Each child class describes separate logic for every shipping company. For example, if anyone wants to add one more shipping provider, all they need to do is add a new class to this directory, define the calculatePrice method with the main logic, and several methods to store information about the provider. This information is used to generate a dynamic list of shipping providers for selection in the form. When a user makes a request to calculate data, the API route uses specific parameters to understand which shipping provider the user wants to receive, and the script will automatically include an example of some shipping provider class located in app/Services/Shipping/Providers. This app doesn't use any database; there is no data to store except for the names of shipping companies. In a real application, this data should be stored in a database.

About


Languages

Language:PHP 68.7%Language:Blade 25.3%Language:Vue 3.8%Language:JavaScript 1.1%Language:Dockerfile 0.8%Language:HTML 0.3%