@@ -96,6 +101,10 @@ function LogModal({ onClose }: { onClose: () => void }) {
setError("All fields are required.");
return;
}
+ if (!validateEarthquakeCode(earthquakeCode)) {
+ setError("Earthquake Code must be in format: EX-M.M-Country-##### (e.g., EC-3.9-Belgium-05467)");
+ return;
+ }
setIsSubmitting(true);
try {
await axios.post("/api/warehouse/log", {
@@ -107,7 +116,6 @@ function LogModal({ onClose }: { onClose: () => void }) {
warehouseLocation,
});
- // todo replace with better alert
alert(`Logged ${name} to storage: ${warehouseLocation}`);
onClose();
} catch {
@@ -137,7 +145,7 @@ function LogModal({ onClose }: { onClose: () => void }) {
/>
setType(e.target.value)}
className="w-full p-2 border border-neutral-300 rounded-md placeholder-neutral-400 focus:ring-2 focus:ring-blue-500"
@@ -163,9 +171,8 @@ function LogModal({ onClose }: { onClose: () => void }) {
/>
setEarthquakeCode(e.target.value)}
className="w-full p-2 border border-neutral-300 rounded-md placeholder-neutral-400 focus:ring-2 focus:ring-blue-500"
aria-label="Earthquake ID"
@@ -259,7 +266,6 @@ function BulkLogModal({ onClose }: { onClose: () => void }) {
warehouseLocation,
});
- // todo replace with better alert
alert(`Logged bulk pallet to storage: ${warehouseLocation}`);
onClose();
} catch {
@@ -362,8 +368,13 @@ function EditModal({ artefact, onClose }: { artefact: ExtendedArtefact; onClose:
setError("All fields are required.");
return;
}
+ if (!validateEarthquakeCode(earthquakeCode)) {
+ setError("Earthquake Code must be in format: XX-M.M-Country-##### (e.g., EC-3.9-Belgium-05467)");
+ return;
+ }
setIsSubmitting(true);
try {
+ // todo add api route
await new Promise((resolve) => setTimeout(resolve, 500)); // Simulated API call
alert(`Updated artefact ${name}`);
onClose();
@@ -430,7 +441,7 @@ function EditModal({ artefact, onClose }: { artefact: ExtendedArtefact; onClose:
type="checkbox"
checked={isSold}
onChange={(e) => setIsSold(e.target.checked)}
- className="h-4 w-4 text-blue-600 border-neutral-300 rounded focus:ring-blue-500"
+ className="w-4 h-4 text-blue-600 border-neutral-300 rounded focus:ring-blue-500"
aria-label="Sold Artefact"
disabled={isSubmitting}
/>
@@ -483,7 +494,7 @@ function EditModal({ artefact, onClose }: { artefact: ExtendedArtefact; onClose:
Saving...