diff --git a/app/[locale]/(protected)/admin/media-tracking/results/component/column.tsx b/app/[locale]/(protected)/admin/media-tracking/results/component/column.tsx index a75ada82..ce17ebdd 100644 --- a/app/[locale]/(protected)/admin/media-tracking/results/component/column.tsx +++ b/app/[locale]/(protected)/admin/media-tracking/results/component/column.tsx @@ -49,15 +49,47 @@ const columns: ColumnDef[] = [ header: "Jumlah Amplifikasi", cell: ({ row }) => {row.getValue("link")}, }, + // { + // accessorKey: "status", + // header: "Status", + // cell: ({ row }) => {row.getValue("status")}, + // }, { accessorKey: "status", - header: "Status", - cell: ({ row }) => {row.getValue("status")}, + header: () =>
Status
, + cell: ({ row }) => { + const raw = row.getValue("status"); + + let value: string | number = "-"; + + if (typeof raw === "string" || typeof raw === "number") { + value = raw; + } else if (raw && typeof raw === "object") { + value = JSON.stringify(raw); + } + + return
{value}
; + }, }, { - accessorKey: "date", - header: "Tanggal Penarikan", - cell: ({ row }) => {row.getValue("date")}, + accessorKey: "createdAt", + header: () =>
Tanggal Penarikan
, + cell: ({ row }) => { + const raw = row.getValue("createdAt"); + if (!raw || typeof raw !== "string") + return
-
; + + const date = new Date(raw); + if (isNaN(date.getTime())) return
-
; + + const formatted = date.toLocaleDateString("id-ID", { + day: "2-digit", + month: "short", + year: "numeric", + }); + + return
{formatted}
; + }, }, { id: "actions", @@ -78,9 +110,9 @@ const columns: ColumnDef[] = [ - + - View + View  {row.original.mediaUpload.fileType.secondaryName && row.original.mediaUpload.fileType.secondaryName.toLowerCase()} diff --git a/app/[locale]/(protected)/contributor/content/satker/audio/detail/[id]/page.tsx b/app/[locale]/(protected)/contributor/content/satker/audio/detail/[id]/page.tsx new file mode 100644 index 00000000..c3d08051 --- /dev/null +++ b/app/[locale]/(protected)/contributor/content/satker/audio/detail/[id]/page.tsx @@ -0,0 +1,16 @@ +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import FormImageDetail from "@/components/form/content/image-detail-form"; +import FormAudioDetail from "@/components/form/content/audio-detail-form"; + +const AudioDetailPage = async () => { + return ( +
+ +
+ +
+
+ ); +}; + +export default AudioDetailPage; diff --git a/app/[locale]/(protected)/contributor/content/satker/audio/update/[id]/page.tsx b/app/[locale]/(protected)/contributor/content/satker/audio/update/[id]/page.tsx new file mode 100644 index 00000000..c0690cb7 --- /dev/null +++ b/app/[locale]/(protected)/contributor/content/satker/audio/update/[id]/page.tsx @@ -0,0 +1,17 @@ +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import FormImageDetail from "@/components/form/content/image-detail-form"; +import FormImageUpdate from "@/components/form/content/image-update-form"; +import FormAudioUpdate from "@/components/form/content/audio-update-form"; + +const AudioUpdatePage = async () => { + return ( +
+ +
+ +
+
+ ); +}; + +export default AudioUpdatePage; diff --git a/app/[locale]/(protected)/contributor/content/satker/components/columns.tsx b/app/[locale]/(protected)/contributor/content/satker/components/columns.tsx index 436f8974..4a2d56da 100644 --- a/app/[locale]/(protected)/contributor/content/satker/components/columns.tsx +++ b/app/[locale]/(protected)/contributor/content/satker/components/columns.tsx @@ -83,6 +83,42 @@ const useTableColumns = () => { {row.getValue("creatorName")} ), }, + { + accessorKey: "fileTypeId", + header: "Jenis Konten", + cell: ({ row }) => { + const type = Number(row.getValue("fileTypeId")); + const name = row.original.fileTypeName; + + const label = + type === 1 + ? "Image" + : type === 2 + ? "Audio Visual" + : type === 3 + ? "Text" + : type === 4 + ? "Audio" + : name || "-"; + + const color = + type === 1 + ? "bg-blue-100 text-blue-600" + : type === 2 + ? "bg-red-100 text-red-600" + : type === 3 + ? "bg-green-100 text-green-600" + : type === 4 + ? "bg-yellow-100 text-yellow-600" + : "bg-gray-200 text-gray-600"; + + return ( + + {label} + + ); + }, + }, { accessorKey: "creatorGroupLevelName", header: t("source", { defaultValue: "Source" }), @@ -187,6 +223,32 @@ const useTableColumns = () => { const router = useRouter(); const MySwal = withReactContent(Swal); + const typeId = Number(row.original.fileTypeId); + + // mapping route detail + const detailRoute = + typeId === 1 + ? `/contributor/content/satker/image/detail/${row.original.id}` + : typeId === 2 + ? `/contributor/content/satker/video/detail/${row.original.id}` + : typeId === 3 + ? `/contributor/content/satker/text/detail/${row.original.id}` + : typeId === 4 + ? `/contributor/content/satker/audio/detail/${row.original.id}` + : `/contributor/content/satker/detail/${row.original.id}`; + + // mapping route update + const updateRoute = + typeId === 1 + ? `/contributor/content/satker/image/update/${row.original.id}` + : typeId === 2 + ? `/contributor/content/satker/video/update/${row.original.id}` + : typeId === 3 + ? `/contributor/content/satker/text/update/${row.original.id}` + : typeId === 4 + ? `/contributor/content/satker/audio/update/${row.original.id}` + : `/contributor/content/satker/update/${row.original.id}`; + async function doDelete(id: any) { const data = { id }; const response = await deleteMedia(data); @@ -257,16 +319,22 @@ const useTableColumns = () => { - View + */} + + + + View + - {canEdit && ( + {/* {canEdit && ( @@ -275,6 +343,14 @@ const useTableColumns = () => { Edit
+ )} */} + {canEdit && ( + + + + Edit + + )} { const router = useRouter(); const searchParams = useSearchParams(); const MySwal = withReactContent(Swal); - const [dataTable, setDataTable] = React.useState([]); const [totalData, setTotalData] = React.useState(1); const [totalPage, setTotalPage] = React.useState(1); - const [sorting, setSorting] = React.useState([]); const [columnFilters, setColumnFilters] = React.useState( [] @@ -60,15 +58,10 @@ const TableSatker = () => { const [columnVisibility, setColumnVisibility] = React.useState({}); const [rowSelection, setRowSelection] = React.useState({}); - const [showData, setShowData] = React.useState("10"); const [page, setPage] = React.useState(1); const [search, setSearch] = React.useState(""); - - // gunakan ref untuk debounce search const searchTimeoutRef = React.useRef(null); - - // === FILTER STATES === const [categories, setCategories] = React.useState([]); const [selectedCategories, setSelectedCategories] = React.useState( [] @@ -80,7 +73,7 @@ const TableSatker = () => { const [filterByCreator, setFilterByCreator] = React.useState(""); const [filterBySource, setFilterBySource] = React.useState(""); const [filterByCreatorGroup, setFilterByCreatorGroup] = React.useState(""); - const [typeId, setTypeId] = React.useState(""); // 1=image, 2=video, 3=text, 4=audio + const [typeId, setTypeId] = React.useState(""); const userLevelId = getCookiesDecrypt("ulie"); const roleId = getCookiesDecrypt("urie"); diff --git a/app/[locale]/(protected)/contributor/content/satker/image/detail/[id]/page.tsx b/app/[locale]/(protected)/contributor/content/satker/image/detail/[id]/page.tsx new file mode 100644 index 00000000..c4c3a5ac --- /dev/null +++ b/app/[locale]/(protected)/contributor/content/satker/image/detail/[id]/page.tsx @@ -0,0 +1,15 @@ +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import FormImageDetail from "@/components/form/content/image-detail-form"; + +const ImageDetailPage = async () => { + return ( +
+ +
+ +
+
+ ); +}; + +export default ImageDetailPage; diff --git a/app/[locale]/(protected)/contributor/content/satker/image/update/[id]/page.tsx b/app/[locale]/(protected)/contributor/content/satker/image/update/[id]/page.tsx new file mode 100644 index 00000000..1adea644 --- /dev/null +++ b/app/[locale]/(protected)/contributor/content/satker/image/update/[id]/page.tsx @@ -0,0 +1,16 @@ +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import FormImageDetail from "@/components/form/content/image-detail-form"; +import FormImageUpdate from "@/components/form/content/image-update-form"; + +const ImageUpdatePage = async () => { + return ( +
+ +
+ +
+
+ ); +}; + +export default ImageUpdatePage; diff --git a/app/[locale]/(protected)/contributor/content/satker/page.tsx b/app/[locale]/(protected)/contributor/content/satker/page.tsx index e419b0e2..9c8a3a74 100644 --- a/app/[locale]/(protected)/contributor/content/satker/page.tsx +++ b/app/[locale]/(protected)/contributor/content/satker/page.tsx @@ -59,15 +59,15 @@ const ReactTableVideoPage = () => {
- {t("video", { defaultValue: "Video" })} + Satker
- + {/* - + */} {/*