From 95399cf45a4cfacc14b1c3e0a360c33856aa9f5a Mon Sep 17 00:00:00 2001 From: Steve Dogiakos Date: Thu, 6 Feb 2025 12:29:29 -0700 Subject: [PATCH] Make similar changes to the form to match API --- components/GasFillupForm.tsx | 73 +++++------------------------------- 1 file changed, 10 insertions(+), 63 deletions(-) diff --git a/components/GasFillupForm.tsx b/components/GasFillupForm.tsx index 8448773..6a10bd1 100644 --- a/components/GasFillupForm.tsx +++ b/components/GasFillupForm.tsx @@ -17,10 +17,10 @@ interface Vehicle { export default function GasFillupForm() { const { toast } = useToast() - const [name, setName] = useState("") const [vehicle, setVehicle] = useState("") const [mileage, setMileage] = useState("") const [fuelAmount, setFuelAmount] = useState("") + const [fuelCost, setFuelCost] = useState("") const [vehicles, setVehicles] = useState([]) const [isLoading, setIsLoading] = useState(false) const [isSubmitting, setIsSubmitting] = useState(false) @@ -51,10 +51,12 @@ export default function GasFillupForm() { try { await submitGasFillup({ - name, vehicleId: vehicle, mileage: Number(mileage), gallons: Number(fuelAmount), + cost: Number(fuelCost), + isFillToFull: true, + missedFuelUp: false, }) toast({ @@ -63,10 +65,10 @@ export default function GasFillupForm() { }) // Reset form - setName("") setVehicle("") setMileage("") setFuelAmount("") + setFuelCost("") } catch (error) { toast({ title: "Error", @@ -90,76 +92,22 @@ export default function GasFillupForm() {
- - setName(e.target.value)} - required - className="border-mdc-blue focus:ring-secondary" - disabled={isSubmitting} - /> -
- -
- +
-
- - setMileage(e.target.value)} - required - min="0" - step="1" - className="border-mdc-blue focus:ring-secondary" - disabled={isSubmitting} - /> -
- -
- - setFuelAmount(e.target.value)} - required - min="0" - step="0.001" - className="border-mdc-blue focus:ring-secondary" - disabled={isSubmitting} - /> -
- -
@@ -168,4 +116,3 @@ export default function GasFillupForm() { ) } -