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

View File

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