feat: add full CRUD management for product categories in admin panel
This commit is contained in:
46
shop/app/admin/categories/page.tsx
Normal file
46
shop/app/admin/categories/page.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
import { getCategories } from '@/lib/actions/products'
|
||||
import { CategoryList } from '@/components/admin/category-list'
|
||||
import { CategoryDialog } from '@/components/admin/category-dialog'
|
||||
import { LayoutGrid, Plus } from 'lucide-react'
|
||||
import { Suspense } from 'react'
|
||||
|
||||
export default async function AdminCategoriesPage() {
|
||||
return (
|
||||
<div className="flex-1 space-y-8 p-8 pt-6">
|
||||
<div className="flex items-center justify-between space-y-2">
|
||||
<div>
|
||||
<h2 className="text-3xl font-bold tracking-tight text-gradient flex items-center gap-3">
|
||||
<LayoutGrid className="w-8 h-8 text-primary" />
|
||||
Kategorien
|
||||
</h2>
|
||||
<p className="text-muted-foreground">
|
||||
Verwalten Sie die Struktur Ihres Webshops.
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Suspense fallback={<div className="h-10 w-32 animate-pulse bg-white/5 rounded-md" />}>
|
||||
<CreateCategoryAction />
|
||||
</Suspense>
|
||||
</div>
|
||||
</div>
|
||||
<Suspense fallback={<div className="h-40 w-full animate-pulse bg-white/5 rounded-xl" />}>
|
||||
<CategoryDataWrapper />
|
||||
</Suspense>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
async function CategoryDataWrapper() {
|
||||
const categories = await getCategories()
|
||||
return <CategoryList initialCategories={categories} />
|
||||
}
|
||||
|
||||
async function CreateCategoryAction() {
|
||||
return (
|
||||
<CategoryDialog>
|
||||
<button className="inline-flex items-center justify-center rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground shadow transition-colors hover:bg-primary/90 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50">
|
||||
<Plus className="mr-2 h-4 w-4" /> Kategorie hinzufügen
|
||||
</button>
|
||||
</CategoryDialog>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user