From 5216bcd8a5214b2d9aa64ec662393555ff67f65d Mon Sep 17 00:00:00 2001 From: Anang Yusman Date: Thu, 24 Jul 2025 16:36:05 +0800 Subject: [PATCH] update filter status admin, fix button delete --- .../content/image/components/columns.tsx | 62 ++++---- .../routine-task/components/content-table.tsx | 132 +++++++++++++----- components/form/content/audio-update-form.tsx | 41 ++++-- components/form/content/image-update-form.tsx | 1 + components/form/content/teks-update-form.tsx | 57 +++++--- components/form/content/video-update-form.tsx | 1 + 6 files changed, 193 insertions(+), 101 deletions(-) diff --git a/app/[locale]/(protected)/contributor/content/image/components/columns.tsx b/app/[locale]/(protected)/contributor/content/image/components/columns.tsx index 18b9837b..296424d7 100644 --- a/app/[locale]/(protected)/contributor/content/image/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/image/components/columns.tsx @@ -132,29 +132,36 @@ const useTableColumns = () => { accessorKey: "statusName", header: "Status", cell: ({ row }) => { - const statusColors: Record = { - diterima: "bg-green-100 text-green-600", - "menunggu review": "bg-orange-100 text-orange-600", + const statusId = Number(row.original?.statusId); + const reviewedAtLevel = row.original?.reviewedAtLevel || ""; + const creatorGroupLevelId = Number(row.original?.creatorGroupLevelId); + const needApprovalFromLevel = Number( + row.original?.needApprovalFromLevel + ); + + const userHasReviewed = reviewedAtLevel.includes(`:${userLevelId}:`); + const isCreator = creatorGroupLevelId === Number(userLevelId); + + const isWaitingForReview = + statusId === 2 && !userHasReviewed && !isCreator; + + const isApprovalNeeded = + statusId === 1 && needApprovalFromLevel === Number(userLevelId); + + const label = + isWaitingForReview || isApprovalNeeded + ? "Menunggu Review" + : statusId === 2 + ? "Diterima" + : row.original?.statusName; + + const colors: Record = { + "Menunggu Review": "bg-orange-100 text-orange-600", + Diterima: "bg-green-100 text-green-600", + default: "bg-red-200 text-red-600", }; - const colors = [ - "bg-orange-100 text-orange-600", - "bg-orange-100 text-orange-600", - "bg-green-100 text-green-600", - "bg-blue-100 text-blue-600", - "bg-red-200 text-red-600", - ]; - - const status = - Number(row.original?.statusId) == 2 && - row.original?.reviewedAtLevel !== null && - !row.original?.reviewedAtLevel?.includes(`:${userLevelId}:`) && - Number(row.original?.creatorGroupLevelId) != Number(userLevelId) - ? "1" - : row.original?.statusId; - const statusStyles = - colors[Number(status)] || "bg-red-200 text-red-600"; - // const statusStyles = statusColors[status] || "bg-red-200 text-red-600"; + const statusStyles = colors[label] || colors.default; return ( { statusStyles )} > - {(Number(row.original?.statusId) == 2 && - !row.original?.reviewedAtLevel !== null && - !row.original?.reviewedAtLevel?.includes( - `:${Number(userLevelId)}:` - ) && - Number(row.original?.creatorGroupLevelId) != - Number(userLevelId)) || - (Number(row.original?.statusId) == 1 && - Number(row.original?.needApprovalFromLevel) == - Number(userLevelId)) - ? "Menunggu Review" - : row.original?.statusName}{" "} + {label} ); }, diff --git a/app/[locale]/(protected)/dashboard/routine-task/components/content-table.tsx b/app/[locale]/(protected)/dashboard/routine-task/components/content-table.tsx index 52d893b7..7b871582 100644 --- a/app/[locale]/(protected)/dashboard/routine-task/components/content-table.tsx +++ b/app/[locale]/(protected)/dashboard/routine-task/components/content-table.tsx @@ -24,6 +24,7 @@ import { } from "@/components/ui/table"; import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { + ChevronDown, ChevronLeft, ChevronRight, Eye, @@ -61,6 +62,7 @@ import { SelectValue, } from "@/components/ui/select"; import { useTranslations } from "next-intl"; +import { Label } from "@/components/ui/label"; type StatusFilter = string[]; @@ -87,7 +89,8 @@ const ContentTable = () => { const userLevelId = getCookiesDecrypt("ulie"); const [categories, setCategories] = React.useState(); const [categoryFilter, setCategoryFilter] = React.useState([]); - const [statusFilter, setStatusFilter] = React.useState([]); + // const [statusFilter, setStatusFilter] = React.useState([]); + const [statusFilter, setStatusFilter] = React.useState([]); const [startDateString, setStartDateString] = React.useState(""); const [endDateString, setEndDateString] = React.useState(""); const [filterByCreator, setFilterByCreator] = React.useState(""); @@ -168,6 +171,14 @@ const ContentTable = () => { table.getColumn("judul")?.setFilterValue(e.target.value); }; + function handleStatusCheckboxChange(value: any) { + setStatusFilter((prev: any) => + prev.includes(value) + ? prev.filter((status: any) => status !== value) + : [...prev, value] + ); + } + return (
@@ -185,43 +196,88 @@ const ContentTable = () => { />
-
- {/* */} - +
+
+ +
+ + + + + + +
+ handleStatusCheckboxChange(1)} + /> + +
+
+ handleStatusCheckboxChange(2)} + /> + +
+
+ handleStatusCheckboxChange(3)} + /> + +
+
+ handleStatusCheckboxChange(4)} + /> + +
+
+
diff --git a/components/form/content/audio-update-form.tsx b/components/form/content/audio-update-form.tsx index e5db2adf..79b7836a 100644 --- a/components/form/content/audio-update-form.tsx +++ b/components/form/content/audio-update-form.tsx @@ -570,6 +570,7 @@ export default function FormAudioUpdate() {