added in admin pages to add models and parts

This commit is contained in:
2025-11-24 18:06:26 +00:00
parent f8bb195159
commit 2682308015
30 changed files with 1569 additions and 57 deletions
+48
View File
@@ -0,0 +1,48 @@
"use client";
import { useState } from "react";
import { supabaseBrowser } from "@/lib/supabaseClient";
import { useRouter } from "next/navigation";
export default function NewModelPage() {
const [form, setForm] = useState({
name: "",
brand: "",
scale: "",
chassis_type: "",
notes: "",
});
const router = useRouter();
async function save() {
const { error } = await supabaseBrowser.from("models").insert(form);
if (!error) router.push("/admin/models");
}
return (
<div>
<h1 className="text-2xl font-bold mb-6">Add New Model</h1>
<div className="space-y-4 max-w-lg">
{Object.entries(form).map(([key, value]) => (
<div key={key}>
<label className="block mb-1 capitalize">{key.replace("_", " ")}</label>
<input
className="w-full p-2 border rounded"
value={value}
onChange={(e) => setForm({ ...form, [key]: e.target.value })}
/>
</div>
))}
<button
onClick={save}
className="px-4 py-2 bg-black text-white rounded"
>
Save
</button>
</div>
</div>
);
}