60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
"use client"
|
||
|
||
import { ColumnDef } from "@tanstack/react-table"
|
||
import { Hero } from "@/types/hero"
|
||
import { Badge } from "@/components/ui/badge"
|
||
import { HeroRowActions } from "./hero-row-actions"
|
||
|
||
export const getColumns = (onSuccess: () => void): ColumnDef<Hero>[] => [
|
||
{
|
||
accessorKey: "image",
|
||
header: "Görsel",
|
||
cell: ({ row }) => {
|
||
const imagePath = row.getValue("image") as string
|
||
if (!imagePath) return <div className="w-16 h-9 bg-gray-100 rounded" />
|
||
|
||
return (
|
||
<div className="w-24 h-14 relative rounded overflow-hidden border">
|
||
{/* eslint-disable-next-line @next/next/no-img-element */}
|
||
<img
|
||
src={`${process.env.NEXT_PUBLIC_API_URL}${imagePath}`}
|
||
alt={row.original.title}
|
||
className="object-cover w-full h-full"
|
||
/>
|
||
</div>
|
||
)
|
||
},
|
||
},
|
||
{
|
||
accessorKey: "title",
|
||
header: "Başlık",
|
||
},
|
||
{
|
||
accessorKey: "is_active",
|
||
header: "Durum",
|
||
cell: ({ row }) => {
|
||
const isActive = row.getValue("is_active") as boolean
|
||
return (
|
||
<Badge variant={isActive ? "default" : "secondary"}>
|
||
{isActive ? "Aktif" : "Pasif"}
|
||
</Badge>
|
||
)
|
||
},
|
||
},
|
||
{
|
||
accessorKey: "DeletedAt",
|
||
header: "Silinme Durumu",
|
||
cell: ({ row }) => {
|
||
const deletedAt = row.getValue("DeletedAt")
|
||
if (deletedAt) {
|
||
return <Badge variant="destructive">Silinmiş</Badge>
|
||
}
|
||
return null
|
||
}
|
||
},
|
||
{
|
||
id: "actions",
|
||
cell: ({ row }) => <HeroRowActions row={row} onSuccess={onSuccess} />,
|
||
},
|
||
]
|