Files
Beyhan Oğur 2a5b661443 first commit
2026-04-26 21:46:42 +03:00

60 lines
1.8 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"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} />,
},
]