"use client"; import useSWR from "swr"; import { Dispatch, SetStateAction, useMemo, useState } from "react"; import { FaTimes } from "react-icons/fa"; import { FaCalendarPlus, FaCartShopping, FaWarehouse } from "react-icons/fa6"; import { IoFilter, IoToday } from "react-icons/io5"; import { ExtendedArtefact } from "@appTypes/ApiTypes"; import { fetcher } from "@utils/axiosHelpers"; // Filter Component function FilterInput({ value, onChange, type = "text", options, }: { value: string; onChange: (value: string) => void; type?: string; options?: string[]; }) { const showSelectedFilter = type === "text" && !["true", "false"].includes(options?.at(-1)!); return (
{options ? (
{options.map((opt) => (
onChange(opt)}> {opt ? (opt === "true" ? "Yes" : "No") : "All"}
))}
) : ( onChange(e.target.value)} className="w-full p-1 border border-neutral-300 rounded-md text-sm" placeholder="Filter..." aria-label="Filter input" /> )}
{value && showSelectedFilter && (
{value === "true" ? "Yes" : value === "false" ? "No" : value} onChange("")} />
)}
); } // Modal Component for Logging Artefact function LogModal({ onClose }: { onClose: () => void }) { const [name, setName] = useState(""); const [description, setDescription] = useState(""); const [location, setLocation] = useState(""); const [earthquakeId, setEarthquakeId] = useState(""); const [storageLocation, setStorageLocation] = useState(""); const [isRequired, setIsRequired] = useState(true); const [error, setError] = useState(""); const [isSubmitting, setIsSubmitting] = useState(false); const handleOverlayClick = (e: { target: any; currentTarget: any }) => { if (e.target === e.currentTarget) { onClose(); } }; const handleLog = async () => { if (!name || !description || !location || !earthquakeId || !storageLocation) { setError("All fields are required."); return; } setIsSubmitting(true); try { await new Promise((resolve) => setTimeout(resolve, 500)); // Simulated API call alert(`Logged ${name} to storage: ${storageLocation}`); onClose(); } catch { setError("Failed to log artefact. Please try again."); } finally { setIsSubmitting(false); } }; return (

Log New Artefact

{error &&

{error}

}
setName(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="Artefact Name" disabled={isSubmitting} />