diff --git a/app/qr-test/page.tsx b/app/qr-test/page.tsx index fcac1e0..8ec82ec 100644 --- a/app/qr-test/page.tsx +++ b/app/qr-test/page.tsx @@ -13,8 +13,8 @@ export default function QRTestPage() { const [fuelAmount, setFuelAmount] = useState('500'); const [fuelUnit, setFuelUnit] = useState<'liters' | 'gallons'>('liters'); const [customAmount, setCustomAmount] = useState('5'); - const [vesselName, setVesselName] = useState('Test Yacht'); - const [imo, setImo] = useState('1234567'); + const [vesselName, setVesselName] = useState(''); + const [imo, setImo] = useState(''); // Response state const [isLoading, setIsLoading] = useState(false); @@ -99,6 +99,20 @@ export default function QRTestPage() { body: JSON.stringify(requestData), }); + // Check HTTP status first + if (!res.ok) { + let errorMessage = `HTTP ${res.status}: ${res.statusText}`; + try { + const errorData = await res.json(); + if (errorData.error) { + errorMessage = errorData.error; + } + } catch { + // Not JSON, use status text + } + throw new Error(errorMessage); + } + const result = await res.json(); if (!result.success) { @@ -199,37 +213,6 @@ export default function QRTestPage() { - {/* Vessel Information */} -
+ Note: Vessel name and IMO are stored as metadata only. They are not used in carbon calculations. +
+