Shipping Calculator
A component for calculating shipping costs based on ZIP code and product size.
Shipping Calculator
ZIP code-based shipping calculator with validation
Shipping Information
Usage
The ShippingCalculator component allows users to enter their ZIP code to calculate shipping costs. It validates the ZIP code format, determines the nearest warehouse, and calculates a shipping cost based on distance and product size.
Props
warehouses- Array of warehouse objects with id, name, zipCode, and locationselectedSize- Currently selected product size (affects shipping cost)onShippingCalculated- Function called when shipping is calculated with the shipping info
Shipping Info Object
The component returns a shipping info object with the following properties:
warehouse- Name of the nearest warehouselocation- Location of the nearest warehousecost- Calculated shipping costdistance- Estimated distance in miles