This commit is contained in:
Sabda Yagra 2025-07-31 12:36:17 +07:00
parent a6683014c2
commit 895cef6c75
3 changed files with 51 additions and 11 deletions

View File

@ -8,6 +8,7 @@ import {
Trash2,
} from "lucide-react";
import { Button } from "@/components/ui/button";
import { Checkbox } from "@/components/ui/checkbox";
import {
DropdownMenu,
DropdownMenuContent,
@ -21,9 +22,33 @@ import withReactContent from "sweetalert2-react-content";
import Swal from "sweetalert2";
const useTableColumns = () => {
const t = useTranslations("Table"); // Panggil di dalam hook
const t = useTranslations("Table");
const MySwal = withReactContent(Swal);
const columns: ColumnDef<any>[] = [
{
id: "select",
header: ({ table }) => (
<Checkbox
checked={
table.getIsAllPageRowsSelected() ||
(table.getIsSomePageRowsSelected() && "indeterminate")
}
onCheckedChange={(val) => table.toggleAllPageRowsSelected(!!val)}
aria-label="Pilih semua pada halaman ini"
/>
),
cell: ({ row }) => (
<Checkbox
checked={row.getIsSelected()}
onCheckedChange={(val) => row.toggleSelected(!!val)}
aria-label="Pilih baris"
/>
),
enableSorting: false,
enableHiding: false,
},
{
accessorKey: "no",
header: t("no", { defaultValue: "No" }),
@ -56,7 +81,6 @@ const useTableColumns = () => {
<span className="whitespace-nowrap">{row.getValue("contentTag")}</span>
),
},
{
accessorKey: "contentType",
header: t("type-content", { defaultValue: "Type Content" }),
@ -73,7 +97,6 @@ const useTableColumns = () => {
</span>
),
},
{
accessorKey: "isPublish",
header: "Status",
@ -95,7 +118,6 @@ const useTableColumns = () => {
);
},
},
{
accessorKey: "contentCreatedDate",
header: t("upload-date", { defaultValue: "Upload Date" }),
@ -104,7 +126,6 @@ const useTableColumns = () => {
| string
| number
| undefined;
const formattedDate =
createdAt && !isNaN(new Date(createdAt).getTime())
? format(new Date(createdAt), "dd-MM-yyyy HH:mm:ss")
@ -118,8 +139,7 @@ const useTableColumns = () => {
header: "Actions",
enableHiding: false,
cell: ({ row }) => {
const isDisabled = row.original.isPublish; // Check the isPublish value
const isDisabled = row.original.isPublish;
return (
<DropdownMenu>
<DropdownMenuTrigger asChild disabled={isDisabled}>
@ -128,7 +148,7 @@ const useTableColumns = () => {
className={`bg-transparent ring-offset-transparent hover:bg-transparent hover:ring-0 hover:ring-transparent ${
isDisabled ? "cursor-not-allowed opacity-50" : ""
}`}
disabled={isDisabled} // Disable button if isPublish is true
disabled={isDisabled}
>
<span className="sr-only">Open menu</span>
<MoreVertical className="h-4 w-4 text-default-800" />
@ -142,7 +162,7 @@ const useTableColumns = () => {
className={`p-2 border-b text-default-700 group focus:bg-default focus:text-primary-foreground rounded-none ${
isDisabled ? "cursor-not-allowed opacity-50" : ""
}`}
disabled={isDisabled} // Disable dropdown item if isPublish is true
disabled={isDisabled}
>
<MoveDownRight className="w-4 h-4 me-1.5" />
Pindah Ke Mediahub

View File

@ -823,7 +823,7 @@ const FilterPage = () => {
<Link href={`/image/detail/${image?.slug}`}>
{/* <img src={image?.thumbnailLink} className="h-60 object-cover items-center justify-center cursor-pointer rounded-lg" /> */}
<div className="img-container h-60 bg-[#e9e9e9] cursor-pointer rounded-lg">
<ImageBlurry
{/* <ImageBlurry
src={
image?.smallThumbnailLink ||
image?.thumbnailLink
@ -834,6 +834,16 @@ const FilterPage = () => {
width: "100%",
height: "100%",
}}
/> */}
<Image
width={2560}
height={1440}
src={
image?.smallThumbnailLink ||
image?.thumbnailLink
}
alt={image?.title}
className="w-full h-full object-cover rounded-t-lg"
/>
</div>
<div className="flex flex-row items-center gap-2 text-[10px] mx-1 mt-2">

View File

@ -833,7 +833,7 @@ const FilterPage = () => {
<Link href={`/video/detail/${video?.slug}`}>
{/* <img src={video?.thumbnailLink} className="h-60 object-cover items-center justify-center cursor-pointer rounded-lg place-self-center" /> */}
<div className="img-container h-60 bg-[#e9e9e9] cursor-pointer rounded-lg">
<ImageBlurry
{/* <ImageBlurry
src={
video?.smallThumbnailLink ||
video?.thumbnailLink
@ -844,6 +844,16 @@ const FilterPage = () => {
width: "100%",
height: "100%",
}}
/> */}
<Image
width={2560}
height={1440}
src={
video?.smallThumbnailLink ||
video?.thumbnailLink
}
alt={video?.title}
className="w-full h-full object-cover rounded-t-lg"
/>
</div>
<div className="flex flex-row items-center gap-2 text-[10px] mx-2">