| 1 | import { CarProps, FilterProps } from "@types"; |
| 2 | |
| 3 | export const calculateCarRent = (city_mpg: number, year: number) => { |
| 4 | const basePricePerDay = 50; // Base rental price per day in dollars |
| 5 | const mileageFactor = 0.1; // Additional rate per mile driven |
| 6 | const ageFactor = 0.05; // Additional rate per year of vehicle age |
| 7 | |
| 8 | // Calculate additional rate based on mileage and age |
| 9 | const mileageRate = city_mpg * mileageFactor; |
| 10 | const ageRate = (new Date().getFullYear() - year) * ageFactor; |
| 11 | |
| 12 | // Calculate total rental rate per day |
| 13 | const rentalRatePerDay = basePricePerDay + mileageRate + ageRate; |
| 14 | |
| 15 | return rentalRatePerDay.toFixed(0); |
| 16 | }; |
| 17 | |
| 18 | export const updateSearchParams = (type: string, value: string) => { |
| 19 | // Get the current URL search params |