carservice: initial commit

This commit is contained in:
Hermes
2026-07-20 21:17:12 +01:00
commit d315323191
69 changed files with 9255 additions and 0 deletions
+269
View File
@@ -0,0 +1,269 @@
"use client";
import { useParams } from "next/navigation";
import Link from "next/link";
import { useState, useMemo } from "react";
import useSWR from "swr";
import {
Car,
Wrench,
FileText,
Clock,
ChevronDown,
ChevronRight,
Printer,
PackageOpen,
} from "lucide-react";
import { HistoryData } from "@/types";
import { formatDate } from "@/lib/format";
import BackLink from "@/components/BackLink";
import Loading from "@/components/Loading";
import Navbar from "@/components/Navbar";
const fetcher = (url: string) => fetch(url).then((r) => r.json());
export default function CarHistoryPage() {
const { id } = useParams();
const { data: history } = useSWR<HistoryData>(`/api/cars/${id}/history`, fetcher);
const [bundle, setBundle] = useState(true);
const [expanded, setExpanded] = useState<Record<string, boolean>>({});
const expandAll = () => {
if (!grouped) return;
const all: Record<string, boolean> = {};
for (const g of grouped) all[g.title] = true;
setExpanded(all);
};
const collapseAll = () => {
if (!grouped) return;
const all: Record<string, boolean> = {};
for (const g of grouped) all[g.title] = false;
setExpanded(all);
};
const grouped = useMemo(() => {
if (!history || !bundle) return null;
const map = new Map<string, HistoryData["tasks"]>();
for (const task of history.tasks) {
const key = task.title.trim();
if (!map.has(key)) map.set(key, []);
map.get(key)!.push(task);
}
return Array.from(map.entries())
.map(([title, tasks]) => ({ title, tasks, count: tasks.length }))
.sort((a, b) => a.title.localeCompare(b.title));
}, [history?.tasks, bundle]);
const toggleGroup = (title: string) =>
setExpanded((e) => ({ ...e, [title]: !e[title] }));
if (!history) return <Loading />;
return (
<div className="min-h-screen pb-12">
<header className="bg-brand-700 text-white shadow no-print">
<div className="max-w-5xl mx-auto px-4 py-4">
<h1 className="text-xl font-bold flex items-center gap-2">
<Car className="w-6 h-6" /> {history.car.regNumber} Service history
</h1>
</div>
</header>
<main className="max-w-5xl mx-auto px-4 py-6">
<div className="no-print">
<BackLink href={`/cars/${history.car.id}`} label="Car" />
</div>
<section className="bg-white rounded-lg shadow p-5 mb-6">
<h2 className="text-lg font-bold mb-3 flex items-center gap-2">
<FileText className="w-5 h-5" /> Car details
</h2>
<div className="grid sm:grid-cols-2 md:grid-cols-3 gap-4 text-sm">
<Info label="Make" value={history.car.make} />
<Info label="Model" value={history.car.model} />
<Info label="Colour" value={history.car.color} />
<Info label="Year" value={history.car.year ? String(history.car.year) : undefined} />
<Info label="Owner" value={history.car.ownerName} />
<Info label="Mileage" value={history.car.mileage != null ? history.car.mileage.toLocaleString() : undefined} />
</div>
</section>
<section className="bg-white rounded-lg shadow p-5">
<div className="flex items-center justify-between mb-4 no-print">
<h2 className="text-lg font-bold flex items-center gap-2">
<Wrench className="w-5 h-5" /> Service tasks
</h2>
<div className="flex items-center gap-2">
{bundle && grouped && (
<>
<button
onClick={expandAll}
className="px-3 py-1.5 text-sm border rounded-md hover:bg-steel-50 inline-flex items-center gap-1"
>
<ChevronDown className="w-4 h-4" /> Expand all
</button>
<button
onClick={collapseAll}
className="px-3 py-1.5 text-sm border rounded-md hover:bg-steel-50 inline-flex items-center gap-1"
>
<ChevronRight className="w-4 h-4" /> Collapse all
</button>
</>
)}
<button
onClick={() => setBundle((b) => !b)}
className={`px-3 py-1.5 text-sm border rounded-md inline-flex items-center gap-1 ${
bundle
? "bg-brand-100 border-brand-300 text-brand-800"
: "hover:bg-steel-50"
}`}
aria-pressed={bundle}
>
<PackageOpen className="w-4 h-4" />
{bundle ? "Ungroup" : "Bundle same tasks"}
</button>
<Link
href={`/cars/${history.car.id}/history/print`}
className="px-3 py-1.5 text-sm border rounded-md hover:bg-steel-50 inline-flex items-center gap-1"
>
<Printer className="w-4 h-4" /> Print
</Link>
</div>
</div>
<h2 className="text-lg font-bold mb-4 print-only flex items-center gap-2">
<Wrench className="w-5 h-5" /> Service tasks
</h2>
{history.tasks.length === 0 ? (
<p className="text-steel-500">No service history yet.</p>
) : bundle && grouped ? (
<div className="space-y-3">
{grouped.map((group) => {
const isOpen = expanded[group.title] ?? false;
return (
<div key={group.title} className="border rounded-lg overflow-hidden">
<button
onClick={() => toggleGroup(group.title)}
className="w-full flex items-center justify-between px-4 py-3 bg-steel-50 hover:bg-steel-100 text-left no-print"
>
<div className="flex items-center gap-2">
{isOpen ? (
<ChevronDown className="w-4 h-4 text-steel-500" />
) : (
<ChevronRight className="w-4 h-4 text-steel-500" />
)}
<span className="font-semibold">{group.title}</span>
<span className="text-xs bg-brand-100 text-brand-800 px-2 py-0.5 rounded-full">
{group.count}
</span>
<span className="text-xs text-steel-500 hidden sm:inline">
latest {formatDate(getLatestDate(group.tasks))}
{getLatestMileage(group.tasks) != null
? `${getLatestMileage(group.tasks)!.toLocaleString()} mi`
: ""}
</span>
</div>
</button>
<div className={`px-4 py-3 ${isOpen ? "block" : "hidden"} no-print`}>
<ul className="space-y-2">
{group.tasks.map((task) => (
<TaskItem key={task.id} task={task} showLink />
))}
</ul>
</div>
<div className="px-4 py-3 print-only">
<p className="font-semibold mb-2">
{group.title}{" "}
<span className="text-xs font-normal text-steel-500">({group.count})</span>
</p>
<ul className="space-y-1">
{group.tasks.map((task) => (
<li key={task.id} className="text-sm text-steel-700">
{formatDate(task.finishedAt || task.createdAt)} Order #{task.orderId}
{task.orderMileage != null ? `${task.orderMileage.toLocaleString()} mi` : ""}
{task.notes ? `${task.notes}` : ""}
</li>
))}
</ul>
</div>
</div>
);
})}
</div>
) : (
<ul className="space-y-2">
{history.tasks.map((task) => (
<TaskItem key={task.id} task={task} showLink />
))}
</ul>
)}
</section>
</main>
</div>
);
}
function getLatestDate(tasks: HistoryData["tasks"]) {
return tasks.reduce((latest, t) => {
const d = new Date(t.finishedAt || t.createdAt);
return d > latest ? d : latest;
}, new Date(0));
}
function getLatestMileage(tasks: HistoryData["tasks"]) {
for (const t of [...tasks].sort(
(a, b) =>
new Date(b.finishedAt || b.createdAt).getTime() -
new Date(a.finishedAt || a.createdAt).getTime(),
)) {
if (t.orderMileage != null) return t.orderMileage;
}
return null;
}
function Info({ label, value }: { label: string; value?: string | null }) {
return (
<div>
<div className="text-xs text-steel-500 uppercase">{label}</div>
<div className="font-medium">{value || "—"}</div>
</div>
);
}
function TaskItem({
task,
showLink,
}: {
task: HistoryData["tasks"][number];
showLink?: boolean;
}) {
const date = task.finishedAt || task.createdAt;
return (
<li className="flex items-start gap-3 text-sm border-l-2 border-brand-200 pl-3">
<div className="flex-1">
<div className="font-medium">{task.title}</div>
{task.notes && <div className="text-steel-600 mt-0.5 italic">{task.notes}</div>}
<div className="text-xs text-steel-500 flex flex-wrap items-center gap-1 mt-0.5">
<span className="flex items-center gap-1">
<Clock className="w-3 h-3" />
{formatDate(date)} Order #{task.orderId}
{task.orderMileage != null && `${task.orderMileage.toLocaleString()} mi`}
</span>
{showLink && (
<Link
href={`/orders/${task.orderId}`}
data-testid={`open-order-${task.orderId}`}
className="text-brand-600 hover:underline no-print"
>
Open
</Link>
)}
</div>
</div>
</li>
);
}
+117
View File
@@ -0,0 +1,117 @@
"use client";
import { useParams } from "next/navigation";
import Link from "next/link";
import { useMemo } from "react";
import useSWR from "swr";
import { Car, Wrench, FileText, Clock, Printer, ArrowLeft } from "lucide-react";
import { HistoryData } from "@/types";
import { formatDate } from "@/lib/format";
import Loading from "@/components/Loading";
const fetcher = (url: string) => fetch(url).then((r) => r.json());
export default function CarHistoryPrintPage() {
const { id } = useParams();
const { data: history } = useSWR<HistoryData>(`/api/cars/${id}/history`, fetcher);
const grouped = useMemo(() => {
if (!history) return [];
const map = new Map<string, HistoryData["tasks"]>();
for (const task of history.tasks) {
const key = task.title.trim();
if (!map.has(key)) map.set(key, []);
map.get(key)!.push(task);
}
return Array.from(map.entries())
.map(([title, tasks]) => ({ title, tasks, count: tasks.length }))
.sort((a, b) => a.title.localeCompare(b.title));
}, [history]);
if (!history) return <Loading />;
return (
<div className="min-h-screen bg-white">
<div className="max-w-5xl mx-auto px-8 py-8">
<div className="flex items-center justify-between mb-8 no-print">
<Link
href={`/cars/${history.car.id}/history`}
className="inline-flex items-center gap-1 text-sm text-steel-600 hover:text-brand-600"
>
<ArrowLeft className="w-4 h-4" /> Back to history
</Link>
<button
onClick={() => window.print()}
className="px-4 py-2 bg-brand-600 text-white rounded-md text-sm inline-flex items-center gap-2 hover:bg-brand-700"
>
<Printer className="w-4 h-4" /> Print
</button>
</div>
<header className="border-b pb-6 mb-6">
<div className="flex items-center gap-3 mb-2">
<Car className="w-8 h-8 text-brand-600" />
<h1 className="text-2xl font-bold">{history.car.regNumber} Service history</h1>
</div>
<div className="grid sm:grid-cols-2 md:grid-cols-4 gap-4 text-sm text-steel-700">
<Info label="Make" value={history.car.make} />
<Info label="Model" value={history.car.model} />
<Info label="Colour" value={history.car.color} />
<Info label="Year" value={history.car.year ? String(history.car.year) : undefined} />
<Info label="Owner" value={history.car.ownerName} />
<Info label="Phone" value={history.car.ownerPhone} />
<Info label="Email" value={history.car.ownerEmail} />
<Info label="Mileage" value={history.car.mileage != null ? history.car.mileage.toLocaleString() : undefined} />
</div>
</header>
<section>
<h2 className="text-lg font-bold mb-4 flex items-center gap-2">
<Wrench className="w-5 h-5 text-steel-600" /> Service tasks
</h2>
{history.tasks.length === 0 ? (
<p className="text-steel-500">No service history yet.</p>
) : (
<div className="space-y-6">
{grouped.map((group) => (
<div key={group.title}>
<h3 className="font-bold text-steel-900 mb-2 border-b pb-1">
{group.title}{" "}
<span className="text-sm font-normal text-steel-500">({group.count})</span>
</h3>
<ul className="space-y-2">
{group.tasks.map((task) => (
<li key={task.id} className="text-sm text-steel-700 flex flex-wrap items-center gap-2">
<span className="inline-flex items-center gap-1 text-steel-500">
<Clock className="w-3 h-3" />
{formatDate(task.finishedAt || task.createdAt)}
</span>
<span>Order #{task.orderId}</span>
{task.orderMileage != null && <span> {task.orderMileage.toLocaleString()} mi</span>}
{task.notes && <span> {task.notes}</span>}
</li>
))}
</ul>
</div>
))}
</div>
)}
</section>
<footer className="mt-12 pt-6 border-t text-xs text-steel-400 print-only">
Printed from Andris Car Service on {new Date().toLocaleDateString("en-IE")}.
</footer>
</div>
</div>
);
}
function Info({ label, value }: { label: string; value?: string | null }) {
return (
<div>
<div className="text-xs text-steel-500 uppercase">{label}</div>
<div className="font-medium">{value || "—"}</div>
</div>
);
}
+474
View File
@@ -0,0 +1,474 @@
"use client";
import { useParams, useRouter } from "next/navigation";
import Link from "next/link";
import { useState } from "react";
import useSWR from "swr";
import {
Plus,
Wrench,
Car,
Loader2,
Pencil,
Trash2,
Save,
X,
MoreHorizontal,
FileText,
} from "lucide-react";
import { CarWithRelations } from "@/types";
import { formatDate } from "@/lib/format";
import BackLink from "@/components/BackLink";
import Loading from "@/components/Loading";
import Navbar from "@/components/Navbar";
const fetcher = (url: string) => fetch(url).then((r) => r.json());
export default function CarDetailPage() {
const { id } = useParams();
const router = useRouter();
const { data: car, mutate } = useSWR<CarWithRelations>(
`/api/cars/${id}`,
fetcher,
);
const [creating, setCreating] = useState(false);
const [editing, setEditing] = useState(false);
const [saving, setSaving] = useState(false);
const [deleting, setDeleting] = useState(false);
const [form, setForm] = useState<Partial<CarWithRelations>>({});
function startEdit() {
setForm({
regNumber: car?.regNumber,
make: car?.make,
model: car?.model,
color: car?.color,
year: car?.year,
ownerName: car?.ownerName,
ownerPhone: car?.ownerPhone,
ownerEmail: car?.ownerEmail,
vin: car?.vin,
engineNumber: car?.engineNumber,
mileage: car?.mileage,
notes: car?.notes,
});
setEditing(true);
}
async function saveCar(e: React.FormEvent) {
e.preventDefault();
if (!car || saving) return;
setSaving(true);
const res = await fetch(`/api/cars/${car.id}`, {
method: "PATCH",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(form),
});
const json = await res.json();
setSaving(false);
if (res.ok && json.id) {
mutate(json, false);
setEditing(false);
setForm({});
}
}
async function deleteCar() {
if (!car || deleting) return;
const ok = window.confirm(
"Delete this car and all its orders? This cannot be undone.",
);
if (!ok) return;
setDeleting(true);
await fetch(`/api/cars/${car.id}`, { method: "DELETE" });
setDeleting(false);
router.push("/");
}
async function createOrderForCar() {
if (!car || creating) return;
setCreating(true);
const res = await fetch("/api/orders", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ carId: car.id }),
});
const json = await res.json();
setCreating(false);
if (res.ok && json.id) {
router.push(`/orders/${json.id}`);
} else {
alert(json.error || "Failed to create order");
}
}
if (!car) return <Loading />;
if (!("id" in car)) {
return (
<div className="min-h-screen pb-12">
<Navbar title="Car" subtitle="Not found" />
<main className="max-w-5xl mx-auto px-4 py-6">
<BackLink href="/cars" label="Cars" />
<p className="text-steel-600">This car does not exist or has been removed.</p>
</main>
</div>
);
}
return (
<div className="min-h-screen pb-12">
<Navbar title={car.regNumber} subtitle="Car details" />
<main className="max-w-5xl mx-auto px-4 py-6">
<BackLink href="/cars" label="Cars" />
<section className="bg-white rounded-lg shadow p-5 mb-6">
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4 mb-5">
<div className="flex items-center gap-3">
<div className="bg-brand-100 text-brand-700 p-3 rounded-xl">
<Car className="w-7 h-7" />
</div>
<div>
<div className="text-2xl font-bold text-steel-800">
{car.regNumber}
</div>
<p className="text-sm text-steel-500">
{car.make || "—"} {car.model || ""}{" "}
{car.year && `(${car.year})`}
</p>
</div>
</div>
<div
data-testid="car-header-actions"
className="flex flex-wrap items-center gap-2"
>
{editing ? (
<>
<button
data-testid="car-edit-cancel"
onClick={() => setEditing(false)}
className="touch-target px-4 border rounded-xl hover:bg-steel-50 flex items-center gap-2 text-base"
>
<X className="w-5 h-5" /> Cancel
</button>
<button
data-testid="car-edit-save"
onClick={saveCar}
disabled={saving}
className="touch-target px-4 bg-brand-600 text-white rounded-xl hover:bg-brand-700 disabled:opacity-50 flex items-center gap-2 text-base"
>
{saving ? (
<Loader2 className="w-5 h-5 animate-spin" />
) : (
<Save className="w-5 h-5" />
)}
Save
</button>
</>
) : (
<>
<button
data-testid="car-edit-button"
onClick={startEdit}
className="touch-target px-4 border rounded-xl hover:bg-steel-50 flex items-center gap-2 text-base"
>
<Pencil className="w-5 h-5" /> Edit
</button>
<button
data-testid="car-delete-button"
onClick={deleteCar}
disabled={deleting}
className="touch-target px-4 border border-red-300 text-red-700 rounded-xl hover:bg-red-50 disabled:opacity-50 flex items-center gap-2 text-base"
>
{deleting ? (
<Loader2 className="w-5 h-5 animate-spin" />
) : (
<Trash2 className="w-5 h-5" />
)}
Delete
</button>
</>
)}
</div>
</div>
<div className="border-t border-steel-100 pt-4 mb-5">
<div
data-testid="car-quick-links"
className="flex flex-wrap gap-2"
>
<Link
href={`/cars/${car.id}/history`}
data-testid="car-history-link"
className="touch-target px-4 border rounded-xl hover:bg-steel-50 inline-flex items-center gap-2 text-base bg-steel-50"
>
<Wrench className="w-5 h-5" /> History
</Link>
<button
data-testid="car-new-order-button"
onClick={createOrderForCar}
disabled={creating}
className="touch-target bg-brand-600 text-white px-4 rounded-xl text-base flex items-center gap-2 hover:bg-brand-700 disabled:opacity-50"
>
{creating ? (
<Loader2 className="w-5 h-5 animate-spin" />
) : (
<Plus className="w-5 h-5" />
)}
New order
</button>
</div>
</div>
{editing ? (
<form
onSubmit={saveCar}
className="grid sm:grid-cols-2 md:grid-cols-3 gap-5 text-base"
>
<Field
testId="car-reg-input"
label="Reg"
value={form.regNumber ?? ""}
onChange={(v) => setForm((f) => ({ ...f, regNumber: v }))}
/>
<Field
testId="car-make-input"
label="Make"
value={form.make ?? ""}
onChange={(v) => setForm((f) => ({ ...f, make: v }))}
/>
<Field
testId="car-model-input"
label="Model"
value={form.model ?? ""}
onChange={(v) => setForm((f) => ({ ...f, model: v }))}
/>
<Field
testId="car-color-input"
label="Colour"
value={form.color ?? ""}
onChange={(v) => setForm((f) => ({ ...f, color: v }))}
/>
<Field
testId="car-year-input"
label="Year"
value={form.year ? String(form.year) : ""}
onChange={(v) =>
setForm((f) => ({ ...f, year: v ? Number(v) : null }))
}
inputMode="numeric"
/>
<Field
testId="car-owner-input"
label="Owner"
value={form.ownerName ?? ""}
onChange={(v) => setForm((f) => ({ ...f, ownerName: v }))}
/>
<Field
testId="car-phone-input"
label="Phone"
value={form.ownerPhone ?? ""}
onChange={(v) => setForm((f) => ({ ...f, ownerPhone: v }))}
/>
<Field
testId="car-email-input"
label="Email"
value={form.ownerEmail ?? ""}
onChange={(v) => setForm((f) => ({ ...f, ownerEmail: v }))}
/>
<Field
testId="car-vin-input"
label="VIN"
value={form.vin ?? ""}
onChange={(v) => setForm((f) => ({ ...f, vin: v }))}
/>
<Field
testId="car-engine-input"
label="Engine no."
value={form.engineNumber ?? ""}
onChange={(v) => setForm((f) => ({ ...f, engineNumber: v }))}
/>
<Field
testId="car-mileage-input"
label="Mileage"
value={form.mileage != null ? String(form.mileage) : ""}
onChange={(v) =>
setForm((f) => ({ ...f, mileage: v ? Number(v) : null }))
}
inputMode="numeric"
/>
<div className="sm:col-span-2 md:col-span-3">
<label
htmlFor="car-notes-input"
className="text-sm text-steel-500 uppercase"
>
Notes
</label>
<textarea
id="car-notes-input"
data-testid="car-notes-input"
value={form.notes ?? ""}
onChange={(e) =>
setForm((f) => ({ ...f, notes: e.target.value }))
}
className="w-full mt-1 border rounded-lg px-4 py-3 text-base focus:outline-none focus:ring-2 focus:ring-brand-500 focus:ring-offset-1"
rows={3}
/>
</div>
</form>
) : (
<>
<div className="grid sm:grid-cols-2 md:grid-cols-3 gap-5 text-base">
<Info label="Make" value={car.make} />
<Info label="Model" value={car.model} />
<Info label="Colour" value={car.color} />
<Info
label="Year"
value={car.year ? String(car.year) : undefined}
/>
<Info label="Owner" value={car.ownerName} />
<Info label="Phone" value={car.ownerPhone} />
<Info label="Email" value={car.ownerEmail} />
<Info label="VIN" value={car.vin} />
<Info label="Engine no." value={car.engineNumber} />
<Info
label="Mileage"
value={car.mileage != null ? String(car.mileage) : undefined}
/>
</div>
{car.notes && (
<div className="mt-5 text-base text-steel-600 bg-steel-50 p-4 rounded-lg">
{car.notes}
</div>
)}
</>
)}
</section>
<section className="bg-white rounded-lg shadow p-5">
<div className="flex items-center justify-between mb-4">
<h2 className="text-lg font-bold flex items-center gap-2">
<Wrench className="w-5 h-5" /> Recent orders
</h2>
<span className="text-sm text-steel-500">
{car.orders.length} order{car.orders.length === 1 ? "" : "s"}
</span>
</div>
{car.orders.length === 0 ? (
<p className="text-steel-500">No service history yet.</p>
) : (
<div className="grid gap-4 sm:grid-cols-2">
{car.orders.map((order) => (
<div
key={order.id}
data-testid={`recent-order-${order.id}`}
className="border rounded-xl p-4 hover:border-brand-300 transition-colors flex flex-col"
>
<div className="flex items-start justify-between gap-3">
<div className="min-w-0">
<div className="font-bold">
Order #{order.id} {formatDate(order.createdAt)}
</div>
<div className="text-sm text-steel-500">
{
order.tasks.filter((t) => t.status === "finished")
.length
}
/{order.tasks.length} tasks done
</div>
</div>
<Link
href={`/orders/${order.id}`}
data-testid={`open-order-${order.id}`}
className="touch-target px-3 border border-brand-300 text-brand-700 rounded-lg hover:bg-brand-50 text-base inline-flex items-center shrink-0"
>
{order.tasks.length > 0 &&
order.tasks.every((t) => t.status === "finished")
? "Finish"
: "Open"}
</Link>
</div>
{order.tasks.length > 0 ? (
<ul className="mt-3 text-sm text-steel-600 space-y-1">
{order.tasks.map((t) => (
<li
key={t.id}
data-testid={`recent-task-${t.id}`}
data-task-status={t.status}
className="flex items-center gap-2"
>
<span
className={`w-2 h-2 rounded-full ${t.status === "finished" ? "bg-green-500" : "bg-steel-300"}`}
/>
<span
className={
t.status === "finished"
? "line-through text-steel-400"
: "truncate"
}
>
{t.title}
</span>
</li>
))}
</ul>
) : (
<p className="mt-3 text-sm text-steel-400">
No tasks recorded.
</p>
)}
</div>
))}
</div>
)}
</section>
</main>
</div>
);
}
function Info({ label, value }: { label: string; value?: string | null }) {
return (
<div>
<div className="text-sm text-steel-500 uppercase">{label}</div>
<div className="font-medium">{value || "—"}</div>
</div>
);
}
function Field({
label,
value,
onChange,
inputMode,
testId,
}: {
label: string;
value: string;
onChange: (value: string) => void;
inputMode?: React.HTMLAttributes<HTMLInputElement>["inputMode"];
testId?: string;
}) {
const id =
testId ||
"car-field-" + label.toLowerCase().replace(/\s+/g, "-").replace(/\./g, "");
return (
<div>
<label htmlFor={id} className="text-sm text-steel-500 uppercase">
{label}
</label>
<input
id={id}
data-testid={testId}
type={inputMode === "numeric" ? "number" : "text"}
inputMode={inputMode}
value={value}
onChange={(e) => onChange(e.target.value)}
className="w-full mt-1 border rounded-lg px-4 py-3 text-base focus:outline-none focus:ring-2 focus:ring-brand-500 focus:ring-offset-1"
/>
</div>
);
}