diff --git a/app/[locale]/(protected)/agenda-setting/calender-view.tsx b/app/[locale]/(protected)/agenda-setting/calender-view.tsx index 2f078cd3..5157cefb 100644 --- a/app/[locale]/(protected)/agenda-setting/calender-view.tsx +++ b/app/[locale]/(protected)/agenda-setting/calender-view.tsx @@ -12,24 +12,60 @@ import { Calendar } from "@/components/ui/calendar"; import { Card, CardContent, CardHeader } from "@/components/ui/card"; import { Plus } from "lucide-react"; import { Checkbox } from "@/components/ui/checkbox"; -import { CalendarEvent, CalendarCategory } from "./data"; +import { CalendarCategory } from "./data"; import { EventContentArg } from "@fullcalendar/core"; import EventModal from "./event-modal"; import { useTranslations } from "next-intl"; +import { getAgendaSettingsList } from "@/service/agenda-setting/agenda-setting"; const wait = () => new Promise((resolve) => setTimeout(resolve, 1000)); interface CalendarViewProps { events: CalendarEvent[]; categories: CalendarCategory[]; } +export interface CalendarEvent { + id: string; + title: string; + start: Date; + end: Date; + allDay: boolean; + extendedProps: { + calendar: string; + description?: string; + }; +} + +export interface AgendaSettingsAPIResponse { + id: number; + title: string; + description: string; + agendaType: string; + startDate: string; // API mengembalikan tanggal dalam bentuk string + endDate: string; + isActive: boolean; + createdAt: string; + updatedAt: string; + createdById: number | null; + createdByName: string | null; +} + +interface APIResponse { + error: boolean; + message: any; + data: AgendaSettingsAPIResponse[] | null; // `data` bisa berupa array atau null +} + const CalendarView = ({ events, categories }: CalendarViewProps) => { const [selectedCategory, setSelectedCategory] = useState( null ); const [selectedEventDate, setSelectedEventDate] = useState(null); - const [selectedEvent, setSelectedEvent] = useState( - null - ); + // const [selectedEvent, setSelectedEvent] = useState( + // null + // ); + + const [apiEvents, setApiEvents] = useState([]); + const [loading, setLoading] = useState(false); const [draggableInitialized, setDraggableInitialized] = useState(false); const t = useTranslations("CalendarApp"); @@ -48,6 +84,73 @@ const CalendarView = ({ events, categories }: CalendarViewProps) => { setSelectedCategory(categories?.map((c) => c.value)); }, [events, categories]); + useEffect(() => { + console.log("Fetched events from API:", apiEvents); + }, [apiEvents]); + + const filteredEvents = apiEvents?.filter((event) => + selectedCategory?.includes(event.extendedProps.calendar) + ); + + const displayedEvents = + filteredEvents?.length > 0 ? filteredEvents : apiEvents; + + useEffect(() => { + console.log("Filtered events based on category:", displayedEvents); + }, [filteredEvents, apiEvents]); + + useEffect(() => { + setSelectedCategory(categories?.map((c) => c.value)); + }, [categories]); + + useEffect(() => { + console.log("Selected categories:", selectedCategory); + }, [selectedCategory]); + + useEffect(() => { + const fetchAgendaEvents = async () => { + setLoading(true); + try { + const selectedMonth = new Date(); // Replace with your logic for selected month + const year = selectedMonth.getFullYear().toString(); + const month = (selectedMonth.getMonth() + 1).toString(); + const typeFilter = ""; // Replace with your type filter logic if needed + + const response: APIResponse = await getAgendaSettingsList( + year, + month, + typeFilter + ); + + if (response.data && Array.isArray(response.data)) { + // Transform API data to match CalendarEvent type + const eventsFromAPI: CalendarEvent[] = response.data.map((item) => ({ + id: item.id.toString(), + title: item.title, + start: new Date(item.startDate), + end: new Date(item.endDate), + allDay: true, // Sesuaikan jika memang ada event sepanjang hari + extendedProps: { + calendar: item.agendaType, + description: item.description, + }, + })); + setApiEvents(eventsFromAPI); + } else { + console.warn("No events found in API response."); + setApiEvents([]); + } + } catch (error) { + console.error("Failed to fetch agenda settings:", error); + setApiEvents([]); + } finally { + setLoading(false); + } + }; + + fetchAgendaEvents(); + }, []); + useEffect(() => { const draggableEl = document.getElementById("external-events"); @@ -80,23 +183,24 @@ const CalendarView = ({ events, categories }: CalendarViewProps) => { draggableEl?.removeEventListener("mousedown", initDraggable); }; }, [dragEvents]); + // event click const handleEventClick = (arg: any) => { setSelectedEventDate(null); setSheetOpen(true); - setSelectedEvent(arg); + setApiEvents(arg); wait().then(() => (document.body.style.pointerEvents = "auto")); }; // handle close modal const handleCloseModal = () => { setSheetOpen(false); - setSelectedEvent(null); + setApiEvents([]); setSelectedEventDate(null); }; const handleDateClick = (arg: any) => { setSheetOpen(true); setSelectedEventDate(arg); - setSelectedEvent(null); + setApiEvents([]); wait().then(() => (document.body.style.pointerEvents = "auto")); }; @@ -109,7 +213,7 @@ const CalendarView = ({ events, categories }: CalendarViewProps) => { }; const handleClassName = (arg: EventContentArg) => { - if (arg.event.extendedProps.calendar === "national") { + if (arg.event.extendedProps.calendar === "mabes") { return "primary"; } else if (arg.event.extendedProps.calendar === "polda") { return "success"; @@ -122,10 +226,6 @@ const CalendarView = ({ events, categories }: CalendarViewProps) => { } }; - const filteredEvents = events?.filter((event) => - selectedCategory?.includes(event.extendedProps.calendar) - ); - return ( <>
@@ -205,7 +305,7 @@ const CalendarView = ({ events, categories }: CalendarViewProps) => { center: "title", right: "dayGridMonth,timeGridWeek,timeGridDay,listWeek", }} - events={filteredEvents} + events={displayedEvents} // Use apiEvents here editable={true} rerenderDelay={10} eventDurationEditable={false} @@ -226,7 +326,7 @@ const CalendarView = ({ events, categories }: CalendarViewProps) => { open={sheetOpen} onClose={handleCloseModal} categories={categories} - event={selectedEvent} + event={apiEvents} selectedDate={selectedEventDate} /> diff --git a/app/[locale]/(protected)/dashboard/page.tsx b/app/[locale]/(protected)/dashboard/page.tsx index e79e55ae..a5707215 100644 --- a/app/[locale]/(protected)/dashboard/page.tsx +++ b/app/[locale]/(protected)/dashboard/page.tsx @@ -5,11 +5,12 @@ import { useTranslations } from "next-intl"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Button } from "@/components/ui/button"; import { UploadIcon } from "lucide-react"; -import RecentActivity from "./routine-task/recent-activity"; -import CompanyTable from "./routine-task/routine-task-table"; +import RecentActivity from "./routine-task/components/recent-activity"; +import CompanyTable from "./routine-task/components/content-table"; import TaskTable from "../task/components/task-table"; import PressConferenceTable from "../schedule/press-release/components/pressrilis-table"; import BlogTable from "../blog/components/blog-table"; +import ContentTable from "./routine-task/components/content-table"; const DashboardPage = () => { const t = useTranslations("AnalyticsDashboard"); @@ -94,7 +95,7 @@ const DashboardPage = () => { - +
diff --git a/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx b/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx new file mode 100644 index 00000000..3e16b258 --- /dev/null +++ b/app/[locale]/(protected)/dashboard/routine-task/components/columns.tsx @@ -0,0 +1,174 @@ +import * as React from "react"; +import { ColumnDef } from "@tanstack/react-table"; + +import { Eye, MoreVertical, SquarePen, Trash2 } from "lucide-react"; +import { cn } from "@/lib/utils"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuTrigger, + DropdownMenuItem, +} from "@/components/ui/dropdown-menu"; +import { Button } from "@/components/ui/button"; +import { format } from "date-fns"; + +const columns: ColumnDef[] = [ + { + accessorKey: "no", + header: "No", + cell: ({ row }) => ( +
+
+

+ {row.getValue("no")} +

+
+
+ ), + }, + { + accessorKey: "title", + header: "Title", + cell: ({ row }: { row: { getValue: (key: string) => string } }) => { + const title: string = row.getValue("title"); + return ( + + {title.length > 50 ? `${title.slice(0, 10)}...` : title} + + ); + }, + }, + { + accessorKey: "createdAt", + header: "Upload Date", + cell: ({ row }) => { + const createdAt = row.getValue("createdAt") as + | string + | number + | undefined; + + const formattedDate = + createdAt && !isNaN(new Date(createdAt).getTime()) + ? format(new Date(createdAt), "dd-MM-yyyy HH:mm:ss") + : "-"; + return {formattedDate}; + }, + }, + { + accessorKey: "fileTypeName", + header: "Type Content", + cell: ({ row }: { row: { getValue: (key: string) => string } }) => { + const title: string = row.getValue("fileTypeName"); + return ( + + {title.length > 50 ? `${title.slice(0, 30)}...` : title} + + ); + }, + }, + // { + // accessorKey: "creatorGroup", + // header: "Creator Group", + // cell: ({ row }) => ( + // {row.getValue("creatorGroup")} + // ), + // }, + // { + // accessorKey: "creatorName", + // header: "Sumber", + // cell: ({ row }) => ( + // {row.getValue("creatorName")} + // ), + // }, + // { + // accessorKey: "publishedOn", + // header: "Published", + // cell: ({ row }) => { + // const isPublish = row.original.isPublish; + // const isPublishOnPolda = row.original.isPublishOnPolda; + + // let displayText = "-"; + // if (isPublish && !isPublishOnPolda) { + // displayText = "Mabes"; + // } else if (isPublish && isPublishOnPolda) { + // displayText = "Mabes & Polda"; + // } else if (!isPublish && isPublishOnPolda) { + // displayText = "Polda"; + // } + + // return ( + //
+ // {displayText} + //
+ // ); + // }, + // }, + + { + accessorKey: "statusName", + header: "Status", + cell: ({ row }) => { + // Mendapatkan nilai statusName + const statusName = row.getValue("statusName"); + + // Mapping warna berdasarkan statusName + const colorMapping: Record = { + "Menunggu Review": "text-orange-500 border-orange-500", + Diterima: "text-green-500 border-green-500", + "Minta Update": "text-blue-500 border-blue-500", + Ditolak: "text-red-500 border-red-500", + }; + + // Mendapatkan kelas warna dari mapping, default ke abu-abu jika tidak ditemukan + const buttonClass = + colorMapping[statusName] || "text-gray-500 border-gray-500"; + + return ( +
+ +
+ ); + }, + }, + { + id: "actions", + accessorKey: "action", + header: "Actions", + enableHiding: false, + cell: ({ row }) => { + return ( + + + + + + + + + View + + + + + Delete + + + + ); + }, + }, +]; + +export default columns; diff --git a/app/[locale]/(protected)/dashboard/routine-task/components/content-table.tsx b/app/[locale]/(protected)/dashboard/routine-task/components/content-table.tsx new file mode 100644 index 00000000..283edb8a --- /dev/null +++ b/app/[locale]/(protected)/dashboard/routine-task/components/content-table.tsx @@ -0,0 +1,271 @@ +"use client"; +import * as React from "react"; +import { + ColumnDef, + ColumnFiltersState, + PaginationState, + SortingState, + VisibilityState, + flexRender, + getCoreRowModel, + getFilteredRowModel, + getPaginationRowModel, + getSortedRowModel, + useReactTable, +} from "@tanstack/react-table"; +import { Button } from "@/components/ui/button"; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from "@/components/ui/table"; +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; +import { + ChevronLeft, + ChevronRight, + Eye, + MoreVertical, + Search, + SquarePen, + Trash2, + TrendingDown, + TrendingUp, +} from "lucide-react"; +import { cn, getCookiesDecrypt } from "@/lib/utils"; +import { + DropdownMenu, + DropdownMenuContent, + DropdownMenuItem, + DropdownMenuTrigger, +} from "@/components/ui/dropdown-menu"; +import { Input } from "@/components/ui/input"; +import { InputGroup, InputGroupText } from "@/components/ui/input-group"; +import { paginationBlog } from "@/service/blog/blog"; +import { ticketingPagination } from "@/service/ticketing/ticketing"; +import { Badge } from "@/components/ui/badge"; +import { useRouter, useSearchParams } from "next/navigation"; +import TablePagination from "@/components/table/table-pagination"; +import columns from "./columns"; +import { listDataAll, listDataImage } from "@/service/content/content"; +import { Icon } from "@iconify/react/dist/iconify.js"; +import { + Select, + SelectContent, + SelectGroup, + SelectItem, + SelectLabel, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; + +type StatusFilter = string[]; + +const ContentTable = () => { + const router = useRouter(); + const searchParams = useSearchParams(); + + const [dataTable, setDataTable] = React.useState([]); + const [totalData, setTotalData] = React.useState(1); + const [sorting, setSorting] = React.useState([]); + const [columnFilters, setColumnFilters] = React.useState( + [] + ); + const [columnVisibility, setColumnVisibility] = + React.useState({}); + const [rowSelection, setRowSelection] = React.useState({}); + const [pagination, setPagination] = React.useState({ + pageIndex: 0, + pageSize: 10, + }); + const [page, setPage] = React.useState(1); + const [totalPage, setTotalPage] = React.useState(1); + const [limit, setLimit] = React.useState(10); + const [search, setSearch] = React.useState(""); + const userId = getCookiesDecrypt("uie"); + const userLevelId = getCookiesDecrypt("ulie"); + + const [categories, setCategories] = React.useState(); + const [categoryFilter, setCategoryFilter] = React.useState([]); + const [statusFilter, setStatusFilter] = React.useState([]); + const [startDateString, setStartDateString] = React.useState(""); + const [endDateString, setEndDateString] = React.useState(""); + const [filterByCreator, setFilterByCreator] = React.useState(""); + const [fileTypeFilter, setFileTypeFilter] = React.useState([]); + const [filterBySource, setFilterBySource] = React.useState(""); + + const roleId = getCookiesDecrypt("urie"); + + const table = useReactTable({ + data: dataTable, + columns, + onSortingChange: setSorting, + onColumnFiltersChange: setColumnFilters, + getCoreRowModel: getCoreRowModel(), + getPaginationRowModel: getPaginationRowModel(), + getSortedRowModel: getSortedRowModel(), + getFilteredRowModel: getFilteredRowModel(), + onColumnVisibilityChange: setColumnVisibility, + onRowSelectionChange: setRowSelection, + onPaginationChange: setPagination, + state: { + sorting, + columnFilters, + columnVisibility, + rowSelection, + pagination, + }, + }); + + React.useEffect(() => { + const pageFromUrl = searchParams?.get("page"); + if (pageFromUrl) { + setPage(Number(pageFromUrl)); + } + }, [searchParams]); + + React.useEffect(() => { + fetchData(); + }, [page, limit, fileTypeFilter, statusFilter]); + + async function fetchData() { + try { + const isForSelf = Number(roleId) === 4; + const res = await listDataAll( + isForSelf, + !isForSelf, + page - 1, + limit, + search, + fileTypeFilter.sort().join(","), + categoryFilter.sort().join(","), + statusFilter.sort().join(","), + statusFilter.sort().join(",").includes("1") ? userLevelId : "", + filterByCreator, + filterBySource, + startDateString, + endDateString + ); + const data = res.data?.data; + const contentData = data?.content; + contentData.forEach((item: any, index: number) => { + item.no = (page - 1) * limit + index + 1; + }); + + console.log("contentData : ", contentData); + + setDataTable(contentData); + setTotalData(data?.totalElements); + setTotalPage(data?.totalPages); + } catch (error) { + console.error("Error fetching tasks:", error); + } + } + + return ( +
+
+
+ + + + + + +
+
+ {/* */} + +
+
+ + + {table.getHeaderGroups().map((headerGroup) => ( + + {headerGroup.headers.map((header) => ( + + {header.isPlaceholder + ? null + : flexRender( + header.column.columnDef.header, + header.getContext() + )} + + ))} + + ))} + + + {table.getRowModel().rows?.length ? ( + table.getRowModel().rows.map((row) => ( + + {row.getVisibleCells().map((cell) => ( + + {flexRender(cell.column.columnDef.cell, cell.getContext())} + + ))} + + )) + ) : ( + + + No results. + + + )} + +
+ +
+ ); +}; + +export default ContentTable; diff --git a/app/[locale]/(protected)/dashboard/routine-task/data.ts b/app/[locale]/(protected)/dashboard/routine-task/components/data.ts similarity index 100% rename from app/[locale]/(protected)/dashboard/routine-task/data.ts rename to app/[locale]/(protected)/dashboard/routine-task/components/data.ts diff --git a/app/[locale]/(protected)/dashboard/routine-task/most-sales.tsx b/app/[locale]/(protected)/dashboard/routine-task/components/most-sales.tsx similarity index 100% rename from app/[locale]/(protected)/dashboard/routine-task/most-sales.tsx rename to app/[locale]/(protected)/dashboard/routine-task/components/most-sales.tsx diff --git a/app/[locale]/(protected)/dashboard/routine-task/overview-chart.tsx b/app/[locale]/(protected)/dashboard/routine-task/components/overview-chart.tsx similarity index 100% rename from app/[locale]/(protected)/dashboard/routine-task/overview-chart.tsx rename to app/[locale]/(protected)/dashboard/routine-task/components/overview-chart.tsx diff --git a/app/[locale]/(protected)/dashboard/routine-task/overview-radial.tsx b/app/[locale]/(protected)/dashboard/routine-task/components/overview-radial.tsx similarity index 100% rename from app/[locale]/(protected)/dashboard/routine-task/overview-radial.tsx rename to app/[locale]/(protected)/dashboard/routine-task/components/overview-radial.tsx diff --git a/app/[locale]/(protected)/dashboard/routine-task/components/recent-activity.tsx b/app/[locale]/(protected)/dashboard/routine-task/components/recent-activity.tsx new file mode 100644 index 00000000..3b01f6ca --- /dev/null +++ b/app/[locale]/(protected)/dashboard/routine-task/components/recent-activity.tsx @@ -0,0 +1,136 @@ +"use client"; + +import { getCookiesDecrypt } from "@/lib/utils"; +import { listDataAll } from "@/service/content/content"; +import { + ColumnFiltersState, + PaginationState, + SortingState, + VisibilityState, +} from "@tanstack/react-table"; +import { DockIcon, ImageIcon, MicIcon, YoutubeIcon } from "lucide-react"; +import { useRouter, useSearchParams } from "next/navigation"; +import React from "react"; +import search from "../../../app/chat/components/search"; + +type StatusFilter = string[]; + +interface Counts { + images: number; + audiovisual: number; + text: number; + audio: number; +} + +const RecentActivity: React.FC = () => { + const router = useRouter(); + const searchParams = useSearchParams(); + + const [dataTable, setDataTable] = React.useState([]); + const [totalData, setTotalData] = React.useState(1); + const [sorting, setSorting] = React.useState([]); + const [columnFilters, setColumnFilters] = React.useState( + [] + ); + const [columnVisibility, setColumnVisibility] = + React.useState({}); + const [rowSelection, setRowSelection] = React.useState({}); + const [pagination, setPagination] = React.useState({ + pageIndex: 0, + pageSize: 10, + }); + const [page, setPage] = React.useState(1); + const [totalPage, setTotalPage] = React.useState(1); + const [limit, setLimit] = React.useState(10); + const [search, setSearch] = React.useState(""); + const userId = getCookiesDecrypt("uie"); + const userLevelId = getCookiesDecrypt("ulie"); + + const [categories, setCategories] = React.useState(); + const [categoryFilter, setCategoryFilter] = React.useState([]); + const [statusFilter, setStatusFilter] = React.useState([]); + const [startDateString, setStartDateString] = React.useState(""); + const [endDateString, setEndDateString] = React.useState(""); + const [filterByCreator, setFilterByCreator] = React.useState(""); + const [fileTypeFilter, setFileTypeFilter] = React.useState([]); + const [filterBySource, setFilterBySource] = React.useState(""); + + const [counts, setCounts] = React.useState({ + images: 0, + audiovisual: 0, + text: 0, + audio: 0, + }); + + const roleId = getCookiesDecrypt("urie"); + + React.useEffect(() => { + const pageFromUrl = searchParams?.get("page"); + if (pageFromUrl) { + setPage(Number(pageFromUrl)); + } + }, [searchParams]); + + React.useEffect(() => { + fetchData(); + }, [page, limit]); + + async function fetchData() { + try { + const isForSelf = Number(roleId) === 4; + const res = await listDataAll( + isForSelf, + !isForSelf, + page - 1, + limit, + search, + fileTypeFilter.sort().join(","), + categoryFilter.sort().join(","), + statusFilter.sort().join(","), + statusFilter.sort().join(",").includes("1") ? userLevelId : "", + filterByCreator, + filterBySource, + startDateString, + endDateString + ); + const data = res.data?.data; + const { content } = data || []; + + // Calculate counts for each typeId + const newCounts: Counts = { + images: content.filter((item: any) => item.typeId === 1).length, + audiovisual: content.filter((item: any) => item.typeId === 2).length, + text: content.filter((item: any) => item.typeId === 3).length, + audio: content.filter((item: any) => item.typeId === 4).length, + }; + + setDataTable(content); + setCounts(newCounts); + } catch (error) { + console.error("Error fetching tasks:", error); + } + } + + return ( +
+
+ +

{counts.images} FOTO

+
+
+ +

{counts.audiovisual} AUDIO VISUAL

+
+
+ +

{counts.text} TEXT

+
+
+ +

{counts.audio} AUDIO

+
+
+ ); +}; + +export default RecentActivity; diff --git a/app/[locale]/(protected)/dashboard/routine-task/recent-activity.tsx b/app/[locale]/(protected)/dashboard/routine-task/recent-activity.tsx deleted file mode 100644 index f684ed29..00000000 --- a/app/[locale]/(protected)/dashboard/routine-task/recent-activity.tsx +++ /dev/null @@ -1,36 +0,0 @@ -"use client"; - -import { - DockIcon, - ImageIcon, - MicIcon, - PaperclipIcon, - TextIcon, - VideoIcon, - YoutubeIcon, -} from "lucide-react"; - -const RecentActivity = () => { - return ( -
-
- -

0 FOTO

-
-
- -

0 AUDIO VISUAL

-
-
- -

0 TEXT

-
-
- -

0 AUDIO

-
-
- ); -}; - -export default RecentActivity; diff --git a/app/[locale]/(protected)/dashboard/routine-task/routine-task-table.tsx b/app/[locale]/(protected)/dashboard/routine-task/routine-task-table.tsx deleted file mode 100644 index 4d271bc0..00000000 --- a/app/[locale]/(protected)/dashboard/routine-task/routine-task-table.tsx +++ /dev/null @@ -1,272 +0,0 @@ -"use client"; - -import * as React from "react"; -import { - ColumnDef, - ColumnFiltersState, - PaginationState, - SortingState, - VisibilityState, - flexRender, - getCoreRowModel, - getFilteredRowModel, - getPaginationRowModel, - getSortedRowModel, - useReactTable, -} from "@tanstack/react-table"; -import { Button } from "@/components/ui/button"; -import { data } from "./data"; -import { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { - Badge, - ChevronLeft, - ChevronRight, - Eye, - MoreVertical, - SquarePen, - Trash2, - TrendingDown, - TrendingUp, -} from "lucide-react"; -import { cn } from "@/lib/utils"; -import { - DropdownMenu, - DropdownMenuContent, - DropdownMenuItem, - DropdownMenuTrigger, -} from "@/components/ui/dropdown-menu"; - -export type CompanyData = { - company: string; - category: string; - revenue: string; - sales: number; - status: string; - up: boolean; -}; - -export const columns: ColumnDef[] = [ - { - accessorKey: "company", - header: "Judul", - cell: ({ row }) => ( -
-
-
- - - SC - -
-
-
-

- Biffco Enterprises Ltd. -

-
- Biffco@example.com -
-
-
- ), - }, - { - accessorKey: "category", - header: "Tanggal Unggah", - cell: ({ row }) => ( - {row.getValue("category")} - ), - }, - { - accessorKey: "sales", - header: "Tipe Konten", - cell: ({ row }) => ( -
- {row.getValue("sales")} - {row?.original.up ? ( - - ) : ( - - )} -
- ), - }, - { - accessorKey: "status", - header: "Status", - cell: ({ row }) => { - const statusColors: Record = { - paid: "bg-success/20 text-success", - due: "bg-warning/20 text-warning", - canceled: "bg-destructive/20 text-destructive", - }; - const status = row.getValue("status"); - return ( - - {status} - - ); - }, - }, - { - id: "actions", - accessorKey: "action", - header: "Actions", - enableHiding: false, - cell: ({ row }) => { - return ( - - - - - - - - View - - - - Edit - - - - Delete - - - - ); - }, - }, -]; - -const CompanyTable = () => { - const [sorting, setSorting] = React.useState([]); - const [columnFilters, setColumnFilters] = React.useState( - [] - ); - const [columnVisibility, setColumnVisibility] = - React.useState({}); - const [rowSelection, setRowSelection] = React.useState({}); - const [pagination, setPagination] = React.useState({ - pageIndex: 0, - pageSize: 6, - }); - - const table = useReactTable({ - data, - columns, - onSortingChange: setSorting, - onColumnFiltersChange: setColumnFilters, - getCoreRowModel: getCoreRowModel(), - getPaginationRowModel: getPaginationRowModel(), - getSortedRowModel: getSortedRowModel(), - getFilteredRowModel: getFilteredRowModel(), - onColumnVisibilityChange: setColumnVisibility, - onRowSelectionChange: setRowSelection, - onPaginationChange: setPagination, - state: { - sorting, - columnFilters, - columnVisibility, - rowSelection, - pagination, - }, - }); - - return ( -
- - - {table.getHeaderGroups().map((headerGroup) => ( - - {headerGroup.headers.map((header) => ( - - {header.isPlaceholder - ? null - : flexRender( - header.column.columnDef.header, - header.getContext() - )} - - ))} - - ))} - - - {table.getRowModel().rows?.length ? ( - table.getRowModel().rows.map((row) => ( - - {row.getVisibleCells().map((cell) => ( - - {flexRender(cell.column.columnDef.cell, cell.getContext())} - - ))} - - )) - ) : ( - - - No results. - - - )} - -
-
- - {table.getPageOptions().map((page, pageIndex) => ( - - ))} - -
-
- ); -}; - -export default CompanyTable; diff --git a/service/content/content.ts b/service/content/content.ts index c7f4dbb7..b6a37715 100644 --- a/service/content/content.ts +++ b/service/content/content.ts @@ -1,6 +1,47 @@ import { getAPIInterceptor, postAPIInterceptor } from "@/config/api"; import { httpGetInterceptor } from "../http-config/http-interceptor-service"; +// export async function listDataAll( +// isForSelf, +// isApproval, +// page, +// limit, +// search, +// fileTypeFilter, +// statusFilter, +// startDate, +// endDate, +// needApprovalFromLevel +// ) { +// const name = search || ""; +// const url = `media/list?title=${name}&enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&isForSelf=${isForSelf}&isApproval=${isApproval}&typeId=${fileTypeFilter}&statusId=${statusFilter}&startDate=${ +// startDate == undefined ? "" : startDate +// }&endDate=${ +// endDate == undefined ? "" : endDate +// }&needApprovalFromLevel=${needApprovalFromLevel}`; +// return getAPIInterceptor({ url }); +// } + +export async function listDataAll( + isForSelf: any, + isApproval: any, + page: any, + limit: any, + search: any, + fileTypeFilter: any, + statusFilter: any, + needApprovalFromLevel: any, + creator: any, + source: any, + startDate: any, + endDate: any, + title: string = search || "" +) { + return await getAPIInterceptor( + `media/list?enablePage=1&sortBy=createdAt&sort=desc&size=${limit}&page=${page}&isForSelf=${isForSelf}&isApproval=${isApproval}&typeId=${fileTypeFilter}&statusId=${statusFilter}&needApprovalFromLevel=${needApprovalFromLevel}&title=${title}` + ); +} + export async function listDataImage( limit: any, page: any,