58 lines
1.5 KiB
TypeScript
58 lines
1.5 KiB
TypeScript
"use client";
|
|
|
|
import { useRouter } from 'next/navigation'
|
|
import { Article } from "../../types/catalog"
|
|
|
|
import { articleDelete } from "../../actions/article.actions";
|
|
import { sites } from "../../_config/sites";
|
|
import Link from "next/link";
|
|
import { Eye, OctagonX } from 'lucide-react';
|
|
|
|
|
|
interface Params {
|
|
articles: Article[]
|
|
}
|
|
|
|
export const ArticleList = ({ articles }: Params) => {
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
const handlerOnDelete = (id: string) => {
|
|
articleDelete(id)
|
|
router.refresh();
|
|
}
|
|
|
|
return (
|
|
<div className='p-4 '>
|
|
{articles.map((a) => (
|
|
<div key={a._id} className="flex gap-4 border-b-1 p-4 border-gray-200">
|
|
<div className='flex gap-4 wa'>
|
|
<div className='w-32'>
|
|
{a.name}
|
|
</div>
|
|
<div className='w-8'>
|
|
<Link href={`${sites.article.update.url}/${a._id}`}>
|
|
<Eye className=''></Eye>
|
|
</Link>
|
|
|
|
|
|
</div>
|
|
<div className='w-8 '>
|
|
<button className='flex gap-2' onClick={() => handlerOnDelete(a._id)}>
|
|
<OctagonX className='' enableBackground={'green'} color='red'></OctagonX>
|
|
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>))}
|
|
|
|
</div>
|
|
)
|
|
|
|
|
|
|
|
|
|
}
|
|
|