// app/admin/categories/page.tsx "use client"; import { useEffect, useState } from "react"; import { useAuth } from "@/context/AuthContext"; import { fetchAdminCategories, type AdminCategory, } from "@/lib/api/adminCategoryMappings"; export default function AdminCategoriesPage() { const { token } = useAuth(); const [categories, setCategories] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); useEffect(() => { if (!token) return; const load = async () => { try { setLoading(true); const cats = await fetchAdminCategories(token); setCategories(cats); } catch (e: any) { console.error(e); setError(e?.message ?? "Failed to load categories"); } finally { setLoading(false); } }; load(); }, [token]); if (!token) { return (
You must be logged in to view this page.
); } return (
{/* Header */}

Canonical categories

These are your standardized builder categories and their groupings.

{/* Placeholder for future actions (add/edit) */} {/* */}
{/* Error */} {error && (
{error}
)} {/* Table */} {loading ? (
Loading…
) : (
{categories.map((cat) => ( ))} {categories.length === 0 && ( )}
Group Name Slug Sort order Description
{cat.groupName ?? "—"} {cat.name} {cat.slug} {cat.sortOrder ?? "—"} {cat.description || ( No description )}
No categories found. Seed the part_categories{" "} table to get started.
)}
); }