Untitled

 avatar
Anis
plain_text
7 months ago
1.6 kB
1
Indexable
Never
import Image from 'next/image';
import Link from 'next/link';
import { ImBin } from 'react-icons/im';
import { MdEditNote } from 'react-icons/md';

export default function NewsGridView({ news, deleteNewsModalHandler }) {
  return (
    <div className="grid grid-cols-1 items-center justify-items-center bg-gray-100 rounded-md gap-5 p-2">
      <div className="col-span-1">
        <Image
          src={news?.image}
          alt="News Image"
          width={0}
          height={0}
          sizes="100vw"
          className="w-40 h-32"
        />
      </div>
      <div className="col-span-1">
        <p className="font-medium">
          {news?.title.length > 100
            ? `${news.title.slice(0, 100)}...`
            : news.title}
        </p>
      </div>
      <div className="col-span-1">
        <p>{news.publish_date}</p>
      </div>
      <div className="col-span-1">
        {news.status === '1' ? (
          <div class="badge badge-info">Active</div>
        ) : (
          <div class="badge badge-error">Inactive</div>
        )}
      </div>
      <div className="col-span-1">
        {' '}
        <Link
          className="btn btn-sm btn-warning"
          href={`/xoomadmin/news/update/${news._id}`}
        >
          Edit <MdEditNote className="text-xl" />
        </Link>{' '}
        <button
          className="btn btn-sm btn-error"
          onClick={() => deleteNewsModalHandler(news)}
        >
          Delete <ImBin className="text-xl" />
        </button>
      </div>
    </div>
  );
}
Leave a Comment