diff --git a/.gitignore b/.gitignore index 00bba9bb..e051cc24 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ yarn-error.log* # typescript *.tsbuildinfo next-env.d.ts + +#idea intellij +/.idea/ \ No newline at end of file diff --git a/app/[locale]/(protected)/communications/account-report/components/column.tsx b/app/[locale]/(protected)/communications/account-report/components/column.tsx new file mode 100644 index 00000000..ee7f653b --- /dev/null +++ b/app/[locale]/(protected)/communications/account-report/components/column.tsx @@ -0,0 +1,76 @@ + +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 { Badge } from "@/components/ui/badge"; + +const columns: ColumnDef[] = [ + { + accessorKey: "no", + header: "No", + cell: ({ row }) => {row.getValue("no")}, + }, + { + accessorKey: "question", + header: "Question", + cell: ({ row }) => {row.getValue("question")}, + }, + { + accessorKey: "answer", + header: "Answer", + cell: ({ row }) => {row.getValue("answer")}, + }, + { + id: "actions", + accessorKey: "action", + header: "Actions", + enableHiding: false, + cell: ({ row }) => { + return ( + + + + + + + + View + + + + Edit + + + + Delete + + + + ); + }, + }, +]; + +export default columns; \ No newline at end of file diff --git a/app/[locale]/(protected)/communications/account-report/components/table.tsx b/app/[locale]/(protected)/communications/account-report/components/table.tsx new file mode 100644 index 00000000..d55a7c38 --- /dev/null +++ b/app/[locale]/(protected)/communications/account-report/components/table.tsx @@ -0,0 +1,199 @@ +"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 } 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 { Badge } from "@/components/ui/badge"; +import { useRouter, useSearchParams } from "next/navigation"; +import TablePagination from "@/components/table/table-pagination"; +import { getFaqList } from "@/service/master/faq"; +import columns from "./column"; + +const FaqTable = () => { + 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 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]); + + async function fetchData() { + try { + const res = await getFaqList(); + const contentData = res.data?.data; + contentData.forEach((item: any, index: number) => { + item.no = (page - 1) * limit + index + 1; + }); + + console.log("contentData : ", contentData); + + setDataTable(contentData); + setTotalData(contentData?.totalElements || contentData?.length); + setTotalPage(contentData?.totalPages || 1); + } catch (error) { + console.error("Error fetching tasks:", error); + } + } + + return ( +
+
+
+ + + + + + +
+
+ ) => + table.getColumn("status")?.setFilterValue(event.target.value) + } + className="max-w-sm " + /> +
+
+ + + {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 FaqTable; diff --git a/app/[locale]/(protected)/communications/account-report/layout.tsx b/app/[locale]/(protected)/communications/account-report/layout.tsx index 47e2f324..5a0ee05c 100644 --- a/app/[locale]/(protected)/communications/account-report/layout.tsx +++ b/app/[locale]/(protected)/communications/account-report/layout.tsx @@ -1,7 +1,9 @@ -export const metadata = { - title: "Blog", -}; +import { Metadata } from "next"; +export const metadata: Metadata = { + title: "Dashboard Media Hub", + description: "Dashboard Media Hub.", +}; const Layout = ({ children }: { children: React.ReactNode }) => { return <>{children}; }; diff --git a/app/[locale]/(protected)/communications/account-report/page.tsx b/app/[locale]/(protected)/communications/account-report/page.tsx index f5995af4..8ba136f7 100644 --- a/app/[locale]/(protected)/communications/account-report/page.tsx +++ b/app/[locale]/(protected)/communications/account-report/page.tsx @@ -1,30 +1,35 @@ import SiteBreadcrumb from "@/components/site-breadcrumb"; -import { Card, CardContent } from "@/components/ui/card"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import FaqTable from "./components/table"; import { Button } from "@/components/ui/button"; -import { UploadIcon } from "lucide-react"; -import BlogTable from "./table/blog-table"; +import { Plus } from "lucide-react"; -const BlogPage = async () => { +const FaqPage = async () => { return (
- -
-
- Table Indeks -
-
- -
-
-
- - + + +
+
+ FAQ Data +
+
+ +
+
+
+
+ +
@@ -32,4 +37,4 @@ const BlogPage = async () => { ); }; -export default BlogPage; +export default FaqPage; diff --git a/app/[locale]/(protected)/communications/account-report/table/blog-table.tsx b/app/[locale]/(protected)/communications/account-report/table/blog-table.tsx deleted file mode 100644 index bb8974d7..00000000 --- a/app/[locale]/(protected)/communications/account-report/table/blog-table.tsx +++ /dev/null @@ -1,333 +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 { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { - Badge, - ChevronLeft, - ChevronRight, - Eye, - MoreVertical, - Search, - 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 = { - no: number; - title: string; - category: string; - createdAt: string; - tags: string; - statusName: string; -}; -import { data } from "./data"; -import { Input } from "@/components/ui/input"; -import { InputGroup, InputGroupText } from "@/components/ui/input-group"; -import { paginationBlog } from "@/service/blog/blog"; - -export const columns: ColumnDef[] = [ - { - accessorKey: "no", - header: "No", - cell: ({ row }) => ( -
-
-

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

-
-
- ), - }, - { - accessorKey: "title", - header: "Judul", - cell: ({ row }) => ( -
-
-

- {row.getValue("title")} -

-
-
- ), - }, - { - accessorKey: "categoryName", - header: "Kategori ", - cell: ({ row }) => ( - {row.getValue("categoryName")} - ), - }, - { - accessorKey: "createdAt", - header: "Tanggal Unggah ", - cell: ({ row }) => ( - {row.getValue("createdAt")} - ), - }, - { - accessorKey: "tags", - header: "Tag ", - cell: ({ row }) => ( - {row.getValue("tags")} - ), - }, - { - accessorKey: "statusName", - header: "Status", - cell: ({ row }) => { - return ( - - {row.getValue("statusName")} - - ); - }, - }, - { - id: "actions", - accessorKey: "action", - header: "Actions", - enableHiding: false, - cell: ({ row }) => { - return ( - - - - - - - - View - - - - Edit - - - - Delete - - - - ); - }, - }, -]; - -const BlogTable = () => { - const [blogTable, setBlogTable] = React.useState([]); - 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 table = useReactTable({ - data: blogTable, - 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(() => { - initState(); - }, [page, limit]); - - async function initState() { - try { - const res = await paginationBlog(limit, page); - const data = res.data.data.content.map((item: any, index: number) => ({ - no: (page - 1) * limit + index + 1, - title: item.title, - categoryName: item.categoryName, - tags: item.tags, - assignmentType: item.assignmentType?.name || "-", - createdAt: item.createdAt, - statusName: item.statusName, - })); - - setBlogTable(data); - setTotalPage(res.data.totalPages); - } catch (error) { - console.error("Error fetching tasks:", error); - } - } - - return ( -
-
-
- - - - - - -
-
- ) => - table.getColumn("status")?.setFilterValue(event.target.value) - } - className="max-w-sm " - /> -
-
- - - {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.getFilteredSelectedRowModel().rows.length} of{" "} - {table.getFilteredRowModel().rows.length} row(s) selected. -
-
- - {table.getPageOptions().map((page, pageIndex) => ( - - ))} - -
-
-
- ); -}; - -export default BlogTable; diff --git a/app/[locale]/(protected)/communications/account-report/table/data.ts b/app/[locale]/(protected)/communications/account-report/table/data.ts deleted file mode 100644 index 6bb2b47a..00000000 --- a/app/[locale]/(protected)/communications/account-report/table/data.ts +++ /dev/null @@ -1,65 +0,0 @@ -export const data = [ - { - title: "Ops Mantap Praja & Pilkada 2024", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - status: "Terkirim", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, -]; diff --git a/app/[locale]/(protected)/communications/collaboration/components/column.tsx b/app/[locale]/(protected)/communications/collaboration/components/column.tsx new file mode 100644 index 00000000..ee7f653b --- /dev/null +++ b/app/[locale]/(protected)/communications/collaboration/components/column.tsx @@ -0,0 +1,76 @@ + +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 { Badge } from "@/components/ui/badge"; + +const columns: ColumnDef[] = [ + { + accessorKey: "no", + header: "No", + cell: ({ row }) => {row.getValue("no")}, + }, + { + accessorKey: "question", + header: "Question", + cell: ({ row }) => {row.getValue("question")}, + }, + { + accessorKey: "answer", + header: "Answer", + cell: ({ row }) => {row.getValue("answer")}, + }, + { + id: "actions", + accessorKey: "action", + header: "Actions", + enableHiding: false, + cell: ({ row }) => { + return ( + + + + + + + + View + + + + Edit + + + + Delete + + + + ); + }, + }, +]; + +export default columns; \ No newline at end of file diff --git a/app/[locale]/(protected)/communications/collaboration/components/table.tsx b/app/[locale]/(protected)/communications/collaboration/components/table.tsx new file mode 100644 index 00000000..d55a7c38 --- /dev/null +++ b/app/[locale]/(protected)/communications/collaboration/components/table.tsx @@ -0,0 +1,199 @@ +"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 } 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 { Badge } from "@/components/ui/badge"; +import { useRouter, useSearchParams } from "next/navigation"; +import TablePagination from "@/components/table/table-pagination"; +import { getFaqList } from "@/service/master/faq"; +import columns from "./column"; + +const FaqTable = () => { + 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 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]); + + async function fetchData() { + try { + const res = await getFaqList(); + const contentData = res.data?.data; + contentData.forEach((item: any, index: number) => { + item.no = (page - 1) * limit + index + 1; + }); + + console.log("contentData : ", contentData); + + setDataTable(contentData); + setTotalData(contentData?.totalElements || contentData?.length); + setTotalPage(contentData?.totalPages || 1); + } catch (error) { + console.error("Error fetching tasks:", error); + } + } + + return ( +
+
+
+ + + + + + +
+
+ ) => + table.getColumn("status")?.setFilterValue(event.target.value) + } + className="max-w-sm " + /> +
+
+ + + {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 FaqTable; diff --git a/app/[locale]/(protected)/communications/collaboration/layout.tsx b/app/[locale]/(protected)/communications/collaboration/layout.tsx index 47e2f324..5a0ee05c 100644 --- a/app/[locale]/(protected)/communications/collaboration/layout.tsx +++ b/app/[locale]/(protected)/communications/collaboration/layout.tsx @@ -1,7 +1,9 @@ -export const metadata = { - title: "Blog", -}; +import { Metadata } from "next"; +export const metadata: Metadata = { + title: "Dashboard Media Hub", + description: "Dashboard Media Hub.", +}; const Layout = ({ children }: { children: React.ReactNode }) => { return <>{children}; }; diff --git a/app/[locale]/(protected)/communications/collaboration/page.tsx b/app/[locale]/(protected)/communications/collaboration/page.tsx index f5995af4..8ba136f7 100644 --- a/app/[locale]/(protected)/communications/collaboration/page.tsx +++ b/app/[locale]/(protected)/communications/collaboration/page.tsx @@ -1,30 +1,35 @@ import SiteBreadcrumb from "@/components/site-breadcrumb"; -import { Card, CardContent } from "@/components/ui/card"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import FaqTable from "./components/table"; import { Button } from "@/components/ui/button"; -import { UploadIcon } from "lucide-react"; -import BlogTable from "./table/blog-table"; +import { Plus } from "lucide-react"; -const BlogPage = async () => { +const FaqPage = async () => { return (
- -
-
- Table Indeks -
-
- -
-
-
- - + + +
+
+ FAQ Data +
+
+ +
+
+
+
+ +
@@ -32,4 +37,4 @@ const BlogPage = async () => { ); }; -export default BlogPage; +export default FaqPage; diff --git a/app/[locale]/(protected)/communications/collaboration/table/blog-table.tsx b/app/[locale]/(protected)/communications/collaboration/table/blog-table.tsx deleted file mode 100644 index bb8974d7..00000000 --- a/app/[locale]/(protected)/communications/collaboration/table/blog-table.tsx +++ /dev/null @@ -1,333 +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 { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { - Badge, - ChevronLeft, - ChevronRight, - Eye, - MoreVertical, - Search, - 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 = { - no: number; - title: string; - category: string; - createdAt: string; - tags: string; - statusName: string; -}; -import { data } from "./data"; -import { Input } from "@/components/ui/input"; -import { InputGroup, InputGroupText } from "@/components/ui/input-group"; -import { paginationBlog } from "@/service/blog/blog"; - -export const columns: ColumnDef[] = [ - { - accessorKey: "no", - header: "No", - cell: ({ row }) => ( -
-
-

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

-
-
- ), - }, - { - accessorKey: "title", - header: "Judul", - cell: ({ row }) => ( -
-
-

- {row.getValue("title")} -

-
-
- ), - }, - { - accessorKey: "categoryName", - header: "Kategori ", - cell: ({ row }) => ( - {row.getValue("categoryName")} - ), - }, - { - accessorKey: "createdAt", - header: "Tanggal Unggah ", - cell: ({ row }) => ( - {row.getValue("createdAt")} - ), - }, - { - accessorKey: "tags", - header: "Tag ", - cell: ({ row }) => ( - {row.getValue("tags")} - ), - }, - { - accessorKey: "statusName", - header: "Status", - cell: ({ row }) => { - return ( - - {row.getValue("statusName")} - - ); - }, - }, - { - id: "actions", - accessorKey: "action", - header: "Actions", - enableHiding: false, - cell: ({ row }) => { - return ( - - - - - - - - View - - - - Edit - - - - Delete - - - - ); - }, - }, -]; - -const BlogTable = () => { - const [blogTable, setBlogTable] = React.useState([]); - 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 table = useReactTable({ - data: blogTable, - 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(() => { - initState(); - }, [page, limit]); - - async function initState() { - try { - const res = await paginationBlog(limit, page); - const data = res.data.data.content.map((item: any, index: number) => ({ - no: (page - 1) * limit + index + 1, - title: item.title, - categoryName: item.categoryName, - tags: item.tags, - assignmentType: item.assignmentType?.name || "-", - createdAt: item.createdAt, - statusName: item.statusName, - })); - - setBlogTable(data); - setTotalPage(res.data.totalPages); - } catch (error) { - console.error("Error fetching tasks:", error); - } - } - - return ( -
-
-
- - - - - - -
-
- ) => - table.getColumn("status")?.setFilterValue(event.target.value) - } - className="max-w-sm " - /> -
-
- - - {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.getFilteredSelectedRowModel().rows.length} of{" "} - {table.getFilteredRowModel().rows.length} row(s) selected. -
-
- - {table.getPageOptions().map((page, pageIndex) => ( - - ))} - -
-
-
- ); -}; - -export default BlogTable; diff --git a/app/[locale]/(protected)/communications/collaboration/table/data.ts b/app/[locale]/(protected)/communications/collaboration/table/data.ts deleted file mode 100644 index 6bb2b47a..00000000 --- a/app/[locale]/(protected)/communications/collaboration/table/data.ts +++ /dev/null @@ -1,65 +0,0 @@ -export const data = [ - { - title: "Ops Mantap Praja & Pilkada 2024", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - status: "Terkirim", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, -]; diff --git a/app/[locale]/(protected)/communications/forward/components/column.tsx b/app/[locale]/(protected)/communications/forward/components/column.tsx new file mode 100644 index 00000000..ee7f653b --- /dev/null +++ b/app/[locale]/(protected)/communications/forward/components/column.tsx @@ -0,0 +1,76 @@ + +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 { Badge } from "@/components/ui/badge"; + +const columns: ColumnDef[] = [ + { + accessorKey: "no", + header: "No", + cell: ({ row }) => {row.getValue("no")}, + }, + { + accessorKey: "question", + header: "Question", + cell: ({ row }) => {row.getValue("question")}, + }, + { + accessorKey: "answer", + header: "Answer", + cell: ({ row }) => {row.getValue("answer")}, + }, + { + id: "actions", + accessorKey: "action", + header: "Actions", + enableHiding: false, + cell: ({ row }) => { + return ( + + + + + + + + View + + + + Edit + + + + Delete + + + + ); + }, + }, +]; + +export default columns; \ No newline at end of file diff --git a/app/[locale]/(protected)/communications/forward/components/table.tsx b/app/[locale]/(protected)/communications/forward/components/table.tsx new file mode 100644 index 00000000..d55a7c38 --- /dev/null +++ b/app/[locale]/(protected)/communications/forward/components/table.tsx @@ -0,0 +1,199 @@ +"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 } 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 { Badge } from "@/components/ui/badge"; +import { useRouter, useSearchParams } from "next/navigation"; +import TablePagination from "@/components/table/table-pagination"; +import { getFaqList } from "@/service/master/faq"; +import columns from "./column"; + +const FaqTable = () => { + 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 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]); + + async function fetchData() { + try { + const res = await getFaqList(); + const contentData = res.data?.data; + contentData.forEach((item: any, index: number) => { + item.no = (page - 1) * limit + index + 1; + }); + + console.log("contentData : ", contentData); + + setDataTable(contentData); + setTotalData(contentData?.totalElements || contentData?.length); + setTotalPage(contentData?.totalPages || 1); + } catch (error) { + console.error("Error fetching tasks:", error); + } + } + + return ( +
+
+
+ + + + + + +
+
+ ) => + table.getColumn("status")?.setFilterValue(event.target.value) + } + className="max-w-sm " + /> +
+
+ + + {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 FaqTable; diff --git a/app/[locale]/(protected)/communications/forward/layout.tsx b/app/[locale]/(protected)/communications/forward/layout.tsx index 47e2f324..5a0ee05c 100644 --- a/app/[locale]/(protected)/communications/forward/layout.tsx +++ b/app/[locale]/(protected)/communications/forward/layout.tsx @@ -1,7 +1,9 @@ -export const metadata = { - title: "Blog", -}; +import { Metadata } from "next"; +export const metadata: Metadata = { + title: "Dashboard Media Hub", + description: "Dashboard Media Hub.", +}; const Layout = ({ children }: { children: React.ReactNode }) => { return <>{children}; }; diff --git a/app/[locale]/(protected)/communications/forward/page.tsx b/app/[locale]/(protected)/communications/forward/page.tsx index f5995af4..8ba136f7 100644 --- a/app/[locale]/(protected)/communications/forward/page.tsx +++ b/app/[locale]/(protected)/communications/forward/page.tsx @@ -1,30 +1,35 @@ import SiteBreadcrumb from "@/components/site-breadcrumb"; -import { Card, CardContent } from "@/components/ui/card"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import FaqTable from "./components/table"; import { Button } from "@/components/ui/button"; -import { UploadIcon } from "lucide-react"; -import BlogTable from "./table/blog-table"; +import { Plus } from "lucide-react"; -const BlogPage = async () => { +const FaqPage = async () => { return (
- -
-
- Table Indeks -
-
- -
-
-
- - + + +
+
+ FAQ Data +
+
+ +
+
+
+
+ +
@@ -32,4 +37,4 @@ const BlogPage = async () => { ); }; -export default BlogPage; +export default FaqPage; diff --git a/app/[locale]/(protected)/communications/forward/table/blog-table.tsx b/app/[locale]/(protected)/communications/forward/table/blog-table.tsx deleted file mode 100644 index bb8974d7..00000000 --- a/app/[locale]/(protected)/communications/forward/table/blog-table.tsx +++ /dev/null @@ -1,333 +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 { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { - Badge, - ChevronLeft, - ChevronRight, - Eye, - MoreVertical, - Search, - 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 = { - no: number; - title: string; - category: string; - createdAt: string; - tags: string; - statusName: string; -}; -import { data } from "./data"; -import { Input } from "@/components/ui/input"; -import { InputGroup, InputGroupText } from "@/components/ui/input-group"; -import { paginationBlog } from "@/service/blog/blog"; - -export const columns: ColumnDef[] = [ - { - accessorKey: "no", - header: "No", - cell: ({ row }) => ( -
-
-

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

-
-
- ), - }, - { - accessorKey: "title", - header: "Judul", - cell: ({ row }) => ( -
-
-

- {row.getValue("title")} -

-
-
- ), - }, - { - accessorKey: "categoryName", - header: "Kategori ", - cell: ({ row }) => ( - {row.getValue("categoryName")} - ), - }, - { - accessorKey: "createdAt", - header: "Tanggal Unggah ", - cell: ({ row }) => ( - {row.getValue("createdAt")} - ), - }, - { - accessorKey: "tags", - header: "Tag ", - cell: ({ row }) => ( - {row.getValue("tags")} - ), - }, - { - accessorKey: "statusName", - header: "Status", - cell: ({ row }) => { - return ( - - {row.getValue("statusName")} - - ); - }, - }, - { - id: "actions", - accessorKey: "action", - header: "Actions", - enableHiding: false, - cell: ({ row }) => { - return ( - - - - - - - - View - - - - Edit - - - - Delete - - - - ); - }, - }, -]; - -const BlogTable = () => { - const [blogTable, setBlogTable] = React.useState([]); - 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 table = useReactTable({ - data: blogTable, - 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(() => { - initState(); - }, [page, limit]); - - async function initState() { - try { - const res = await paginationBlog(limit, page); - const data = res.data.data.content.map((item: any, index: number) => ({ - no: (page - 1) * limit + index + 1, - title: item.title, - categoryName: item.categoryName, - tags: item.tags, - assignmentType: item.assignmentType?.name || "-", - createdAt: item.createdAt, - statusName: item.statusName, - })); - - setBlogTable(data); - setTotalPage(res.data.totalPages); - } catch (error) { - console.error("Error fetching tasks:", error); - } - } - - return ( -
-
-
- - - - - - -
-
- ) => - table.getColumn("status")?.setFilterValue(event.target.value) - } - className="max-w-sm " - /> -
-
- - - {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.getFilteredSelectedRowModel().rows.length} of{" "} - {table.getFilteredRowModel().rows.length} row(s) selected. -
-
- - {table.getPageOptions().map((page, pageIndex) => ( - - ))} - -
-
-
- ); -}; - -export default BlogTable; diff --git a/app/[locale]/(protected)/communications/forward/table/data.ts b/app/[locale]/(protected)/communications/forward/table/data.ts deleted file mode 100644 index 6bb2b47a..00000000 --- a/app/[locale]/(protected)/communications/forward/table/data.ts +++ /dev/null @@ -1,65 +0,0 @@ -export const data = [ - { - title: "Ops Mantap Praja & Pilkada 2024", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - status: "Terkirim", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, -]; diff --git a/app/[locale]/(protected)/communications/internal/components/column.tsx b/app/[locale]/(protected)/communications/internal/components/column.tsx new file mode 100644 index 00000000..ee7f653b --- /dev/null +++ b/app/[locale]/(protected)/communications/internal/components/column.tsx @@ -0,0 +1,76 @@ + +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 { Badge } from "@/components/ui/badge"; + +const columns: ColumnDef[] = [ + { + accessorKey: "no", + header: "No", + cell: ({ row }) => {row.getValue("no")}, + }, + { + accessorKey: "question", + header: "Question", + cell: ({ row }) => {row.getValue("question")}, + }, + { + accessorKey: "answer", + header: "Answer", + cell: ({ row }) => {row.getValue("answer")}, + }, + { + id: "actions", + accessorKey: "action", + header: "Actions", + enableHiding: false, + cell: ({ row }) => { + return ( + + + + + + + + View + + + + Edit + + + + Delete + + + + ); + }, + }, +]; + +export default columns; \ No newline at end of file diff --git a/app/[locale]/(protected)/communications/internal/components/table.tsx b/app/[locale]/(protected)/communications/internal/components/table.tsx new file mode 100644 index 00000000..d55a7c38 --- /dev/null +++ b/app/[locale]/(protected)/communications/internal/components/table.tsx @@ -0,0 +1,199 @@ +"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 } 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 { Badge } from "@/components/ui/badge"; +import { useRouter, useSearchParams } from "next/navigation"; +import TablePagination from "@/components/table/table-pagination"; +import { getFaqList } from "@/service/master/faq"; +import columns from "./column"; + +const FaqTable = () => { + 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 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]); + + async function fetchData() { + try { + const res = await getFaqList(); + const contentData = res.data?.data; + contentData.forEach((item: any, index: number) => { + item.no = (page - 1) * limit + index + 1; + }); + + console.log("contentData : ", contentData); + + setDataTable(contentData); + setTotalData(contentData?.totalElements || contentData?.length); + setTotalPage(contentData?.totalPages || 1); + } catch (error) { + console.error("Error fetching tasks:", error); + } + } + + return ( +
+
+
+ + + + + + +
+
+ ) => + table.getColumn("status")?.setFilterValue(event.target.value) + } + className="max-w-sm " + /> +
+
+ + + {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 FaqTable; diff --git a/app/[locale]/(protected)/communications/internal/layout.tsx b/app/[locale]/(protected)/communications/internal/layout.tsx index 47e2f324..5a0ee05c 100644 --- a/app/[locale]/(protected)/communications/internal/layout.tsx +++ b/app/[locale]/(protected)/communications/internal/layout.tsx @@ -1,7 +1,9 @@ -export const metadata = { - title: "Blog", -}; +import { Metadata } from "next"; +export const metadata: Metadata = { + title: "Dashboard Media Hub", + description: "Dashboard Media Hub.", +}; const Layout = ({ children }: { children: React.ReactNode }) => { return <>{children}; }; diff --git a/app/[locale]/(protected)/communications/internal/page.tsx b/app/[locale]/(protected)/communications/internal/page.tsx index f5995af4..8ba136f7 100644 --- a/app/[locale]/(protected)/communications/internal/page.tsx +++ b/app/[locale]/(protected)/communications/internal/page.tsx @@ -1,30 +1,35 @@ import SiteBreadcrumb from "@/components/site-breadcrumb"; -import { Card, CardContent } from "@/components/ui/card"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import FaqTable from "./components/table"; import { Button } from "@/components/ui/button"; -import { UploadIcon } from "lucide-react"; -import BlogTable from "./table/blog-table"; +import { Plus } from "lucide-react"; -const BlogPage = async () => { +const FaqPage = async () => { return (
- -
-
- Table Indeks -
-
- -
-
-
- - + + +
+
+ FAQ Data +
+
+ +
+
+
+
+ +
@@ -32,4 +37,4 @@ const BlogPage = async () => { ); }; -export default BlogPage; +export default FaqPage; diff --git a/app/[locale]/(protected)/communications/internal/table/blog-table.tsx b/app/[locale]/(protected)/communications/internal/table/blog-table.tsx deleted file mode 100644 index bb8974d7..00000000 --- a/app/[locale]/(protected)/communications/internal/table/blog-table.tsx +++ /dev/null @@ -1,333 +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 { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { - Badge, - ChevronLeft, - ChevronRight, - Eye, - MoreVertical, - Search, - 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 = { - no: number; - title: string; - category: string; - createdAt: string; - tags: string; - statusName: string; -}; -import { data } from "./data"; -import { Input } from "@/components/ui/input"; -import { InputGroup, InputGroupText } from "@/components/ui/input-group"; -import { paginationBlog } from "@/service/blog/blog"; - -export const columns: ColumnDef[] = [ - { - accessorKey: "no", - header: "No", - cell: ({ row }) => ( -
-
-

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

-
-
- ), - }, - { - accessorKey: "title", - header: "Judul", - cell: ({ row }) => ( -
-
-

- {row.getValue("title")} -

-
-
- ), - }, - { - accessorKey: "categoryName", - header: "Kategori ", - cell: ({ row }) => ( - {row.getValue("categoryName")} - ), - }, - { - accessorKey: "createdAt", - header: "Tanggal Unggah ", - cell: ({ row }) => ( - {row.getValue("createdAt")} - ), - }, - { - accessorKey: "tags", - header: "Tag ", - cell: ({ row }) => ( - {row.getValue("tags")} - ), - }, - { - accessorKey: "statusName", - header: "Status", - cell: ({ row }) => { - return ( - - {row.getValue("statusName")} - - ); - }, - }, - { - id: "actions", - accessorKey: "action", - header: "Actions", - enableHiding: false, - cell: ({ row }) => { - return ( - - - - - - - - View - - - - Edit - - - - Delete - - - - ); - }, - }, -]; - -const BlogTable = () => { - const [blogTable, setBlogTable] = React.useState([]); - 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 table = useReactTable({ - data: blogTable, - 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(() => { - initState(); - }, [page, limit]); - - async function initState() { - try { - const res = await paginationBlog(limit, page); - const data = res.data.data.content.map((item: any, index: number) => ({ - no: (page - 1) * limit + index + 1, - title: item.title, - categoryName: item.categoryName, - tags: item.tags, - assignmentType: item.assignmentType?.name || "-", - createdAt: item.createdAt, - statusName: item.statusName, - })); - - setBlogTable(data); - setTotalPage(res.data.totalPages); - } catch (error) { - console.error("Error fetching tasks:", error); - } - } - - return ( -
-
-
- - - - - - -
-
- ) => - table.getColumn("status")?.setFilterValue(event.target.value) - } - className="max-w-sm " - /> -
-
- - - {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.getFilteredSelectedRowModel().rows.length} of{" "} - {table.getFilteredRowModel().rows.length} row(s) selected. -
-
- - {table.getPageOptions().map((page, pageIndex) => ( - - ))} - -
-
-
- ); -}; - -export default BlogTable; diff --git a/app/[locale]/(protected)/communications/internal/table/data.ts b/app/[locale]/(protected)/communications/internal/table/data.ts deleted file mode 100644 index 6bb2b47a..00000000 --- a/app/[locale]/(protected)/communications/internal/table/data.ts +++ /dev/null @@ -1,65 +0,0 @@ -export const data = [ - { - title: "Ops Mantap Praja & Pilkada 2024", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - status: "Terkirim", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, -]; diff --git a/app/[locale]/(protected)/communications/questions/components/column.tsx b/app/[locale]/(protected)/communications/questions/components/column.tsx new file mode 100644 index 00000000..ee7f653b --- /dev/null +++ b/app/[locale]/(protected)/communications/questions/components/column.tsx @@ -0,0 +1,76 @@ + +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 { Badge } from "@/components/ui/badge"; + +const columns: ColumnDef[] = [ + { + accessorKey: "no", + header: "No", + cell: ({ row }) => {row.getValue("no")}, + }, + { + accessorKey: "question", + header: "Question", + cell: ({ row }) => {row.getValue("question")}, + }, + { + accessorKey: "answer", + header: "Answer", + cell: ({ row }) => {row.getValue("answer")}, + }, + { + id: "actions", + accessorKey: "action", + header: "Actions", + enableHiding: false, + cell: ({ row }) => { + return ( + + + + + + + + View + + + + Edit + + + + Delete + + + + ); + }, + }, +]; + +export default columns; \ No newline at end of file diff --git a/app/[locale]/(protected)/communications/questions/components/table.tsx b/app/[locale]/(protected)/communications/questions/components/table.tsx new file mode 100644 index 00000000..d55a7c38 --- /dev/null +++ b/app/[locale]/(protected)/communications/questions/components/table.tsx @@ -0,0 +1,199 @@ +"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 } 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 { Badge } from "@/components/ui/badge"; +import { useRouter, useSearchParams } from "next/navigation"; +import TablePagination from "@/components/table/table-pagination"; +import { getFaqList } from "@/service/master/faq"; +import columns from "./column"; + +const FaqTable = () => { + 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 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]); + + async function fetchData() { + try { + const res = await getFaqList(); + const contentData = res.data?.data; + contentData.forEach((item: any, index: number) => { + item.no = (page - 1) * limit + index + 1; + }); + + console.log("contentData : ", contentData); + + setDataTable(contentData); + setTotalData(contentData?.totalElements || contentData?.length); + setTotalPage(contentData?.totalPages || 1); + } catch (error) { + console.error("Error fetching tasks:", error); + } + } + + return ( +
+
+
+ + + + + + +
+
+ ) => + table.getColumn("status")?.setFilterValue(event.target.value) + } + className="max-w-sm " + /> +
+
+ + + {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 FaqTable; diff --git a/app/[locale]/(protected)/communications/questions/layout.tsx b/app/[locale]/(protected)/communications/questions/layout.tsx index 47e2f324..5a0ee05c 100644 --- a/app/[locale]/(protected)/communications/questions/layout.tsx +++ b/app/[locale]/(protected)/communications/questions/layout.tsx @@ -1,7 +1,9 @@ -export const metadata = { - title: "Blog", -}; +import { Metadata } from "next"; +export const metadata: Metadata = { + title: "Dashboard Media Hub", + description: "Dashboard Media Hub.", +}; const Layout = ({ children }: { children: React.ReactNode }) => { return <>{children}; }; diff --git a/app/[locale]/(protected)/communications/questions/page.tsx b/app/[locale]/(protected)/communications/questions/page.tsx index f5995af4..8ba136f7 100644 --- a/app/[locale]/(protected)/communications/questions/page.tsx +++ b/app/[locale]/(protected)/communications/questions/page.tsx @@ -1,30 +1,35 @@ import SiteBreadcrumb from "@/components/site-breadcrumb"; -import { Card, CardContent } from "@/components/ui/card"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import FaqTable from "./components/table"; import { Button } from "@/components/ui/button"; -import { UploadIcon } from "lucide-react"; -import BlogTable from "./table/blog-table"; +import { Plus } from "lucide-react"; -const BlogPage = async () => { +const FaqPage = async () => { return (
- -
-
- Table Indeks -
-
- -
-
-
- - + + +
+
+ FAQ Data +
+
+ +
+
+
+
+ +
@@ -32,4 +37,4 @@ const BlogPage = async () => { ); }; -export default BlogPage; +export default FaqPage; diff --git a/app/[locale]/(protected)/communications/questions/table/blog-table.tsx b/app/[locale]/(protected)/communications/questions/table/blog-table.tsx deleted file mode 100644 index bb8974d7..00000000 --- a/app/[locale]/(protected)/communications/questions/table/blog-table.tsx +++ /dev/null @@ -1,333 +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 { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { - Badge, - ChevronLeft, - ChevronRight, - Eye, - MoreVertical, - Search, - 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 = { - no: number; - title: string; - category: string; - createdAt: string; - tags: string; - statusName: string; -}; -import { data } from "./data"; -import { Input } from "@/components/ui/input"; -import { InputGroup, InputGroupText } from "@/components/ui/input-group"; -import { paginationBlog } from "@/service/blog/blog"; - -export const columns: ColumnDef[] = [ - { - accessorKey: "no", - header: "No", - cell: ({ row }) => ( -
-
-

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

-
-
- ), - }, - { - accessorKey: "title", - header: "Judul", - cell: ({ row }) => ( -
-
-

- {row.getValue("title")} -

-
-
- ), - }, - { - accessorKey: "categoryName", - header: "Kategori ", - cell: ({ row }) => ( - {row.getValue("categoryName")} - ), - }, - { - accessorKey: "createdAt", - header: "Tanggal Unggah ", - cell: ({ row }) => ( - {row.getValue("createdAt")} - ), - }, - { - accessorKey: "tags", - header: "Tag ", - cell: ({ row }) => ( - {row.getValue("tags")} - ), - }, - { - accessorKey: "statusName", - header: "Status", - cell: ({ row }) => { - return ( - - {row.getValue("statusName")} - - ); - }, - }, - { - id: "actions", - accessorKey: "action", - header: "Actions", - enableHiding: false, - cell: ({ row }) => { - return ( - - - - - - - - View - - - - Edit - - - - Delete - - - - ); - }, - }, -]; - -const BlogTable = () => { - const [blogTable, setBlogTable] = React.useState([]); - 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 table = useReactTable({ - data: blogTable, - 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(() => { - initState(); - }, [page, limit]); - - async function initState() { - try { - const res = await paginationBlog(limit, page); - const data = res.data.data.content.map((item: any, index: number) => ({ - no: (page - 1) * limit + index + 1, - title: item.title, - categoryName: item.categoryName, - tags: item.tags, - assignmentType: item.assignmentType?.name || "-", - createdAt: item.createdAt, - statusName: item.statusName, - })); - - setBlogTable(data); - setTotalPage(res.data.totalPages); - } catch (error) { - console.error("Error fetching tasks:", error); - } - } - - return ( -
-
-
- - - - - - -
-
- ) => - table.getColumn("status")?.setFilterValue(event.target.value) - } - className="max-w-sm " - /> -
-
- - - {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.getFilteredSelectedRowModel().rows.length} of{" "} - {table.getFilteredRowModel().rows.length} row(s) selected. -
-
- - {table.getPageOptions().map((page, pageIndex) => ( - - ))} - -
-
-
- ); -}; - -export default BlogTable; diff --git a/app/[locale]/(protected)/communications/questions/table/data.ts b/app/[locale]/(protected)/communications/questions/table/data.ts deleted file mode 100644 index 6bb2b47a..00000000 --- a/app/[locale]/(protected)/communications/questions/table/data.ts +++ /dev/null @@ -1,65 +0,0 @@ -export const data = [ - { - title: "Ops Mantap Praja & Pilkada 2024", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - status: "Terkirim", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, -]; diff --git a/app/[locale]/(protected)/frequently-asked-question/components/column.tsx b/app/[locale]/(protected)/frequently-asked-question/components/column.tsx new file mode 100644 index 00000000..ee7f653b --- /dev/null +++ b/app/[locale]/(protected)/frequently-asked-question/components/column.tsx @@ -0,0 +1,76 @@ + +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 { Badge } from "@/components/ui/badge"; + +const columns: ColumnDef[] = [ + { + accessorKey: "no", + header: "No", + cell: ({ row }) => {row.getValue("no")}, + }, + { + accessorKey: "question", + header: "Question", + cell: ({ row }) => {row.getValue("question")}, + }, + { + accessorKey: "answer", + header: "Answer", + cell: ({ row }) => {row.getValue("answer")}, + }, + { + id: "actions", + accessorKey: "action", + header: "Actions", + enableHiding: false, + cell: ({ row }) => { + return ( + + + + + + + + View + + + + Edit + + + + Delete + + + + ); + }, + }, +]; + +export default columns; \ No newline at end of file diff --git a/app/[locale]/(protected)/frequently-asked-question/components/table.tsx b/app/[locale]/(protected)/frequently-asked-question/components/table.tsx index e69de29b..d55a7c38 100644 --- a/app/[locale]/(protected)/frequently-asked-question/components/table.tsx +++ b/app/[locale]/(protected)/frequently-asked-question/components/table.tsx @@ -0,0 +1,199 @@ +"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 } 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 { Badge } from "@/components/ui/badge"; +import { useRouter, useSearchParams } from "next/navigation"; +import TablePagination from "@/components/table/table-pagination"; +import { getFaqList } from "@/service/master/faq"; +import columns from "./column"; + +const FaqTable = () => { + 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 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]); + + async function fetchData() { + try { + const res = await getFaqList(); + const contentData = res.data?.data; + contentData.forEach((item: any, index: number) => { + item.no = (page - 1) * limit + index + 1; + }); + + console.log("contentData : ", contentData); + + setDataTable(contentData); + setTotalData(contentData?.totalElements || contentData?.length); + setTotalPage(contentData?.totalPages || 1); + } catch (error) { + console.error("Error fetching tasks:", error); + } + } + + return ( +
+
+
+ + + + + + +
+
+ ) => + table.getColumn("status")?.setFilterValue(event.target.value) + } + className="max-w-sm " + /> +
+
+ + + {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 FaqTable; diff --git a/app/[locale]/(protected)/frequently-asked-question/layout.tsx b/app/[locale]/(protected)/frequently-asked-question/layout.tsx index 47e2f324..5a0ee05c 100644 --- a/app/[locale]/(protected)/frequently-asked-question/layout.tsx +++ b/app/[locale]/(protected)/frequently-asked-question/layout.tsx @@ -1,7 +1,9 @@ -export const metadata = { - title: "Blog", -}; +import { Metadata } from "next"; +export const metadata: Metadata = { + title: "Dashboard Media Hub", + description: "Dashboard Media Hub.", +}; const Layout = ({ children }: { children: React.ReactNode }) => { return <>{children}; }; diff --git a/app/[locale]/(protected)/frequently-asked-question/page.tsx b/app/[locale]/(protected)/frequently-asked-question/page.tsx index f5995af4..8ba136f7 100644 --- a/app/[locale]/(protected)/frequently-asked-question/page.tsx +++ b/app/[locale]/(protected)/frequently-asked-question/page.tsx @@ -1,30 +1,35 @@ import SiteBreadcrumb from "@/components/site-breadcrumb"; -import { Card, CardContent } from "@/components/ui/card"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import FaqTable from "./components/table"; import { Button } from "@/components/ui/button"; -import { UploadIcon } from "lucide-react"; -import BlogTable from "./table/blog-table"; +import { Plus } from "lucide-react"; -const BlogPage = async () => { +const FaqPage = async () => { return (
- -
-
- Table Indeks -
-
- -
-
-
- - + + +
+
+ FAQ Data +
+
+ +
+
+
+
+ +
@@ -32,4 +37,4 @@ const BlogPage = async () => { ); }; -export default BlogPage; +export default FaqPage; diff --git a/app/[locale]/(protected)/knowledge-base/layout.tsx b/app/[locale]/(protected)/knowledge-base/layout.tsx index 47e2f324..5a0ee05c 100644 --- a/app/[locale]/(protected)/knowledge-base/layout.tsx +++ b/app/[locale]/(protected)/knowledge-base/layout.tsx @@ -1,7 +1,9 @@ -export const metadata = { - title: "Blog", -}; +import { Metadata } from "next"; +export const metadata: Metadata = { + title: "Dashboard Media Hub", + description: "Dashboard Media Hub.", +}; const Layout = ({ children }: { children: React.ReactNode }) => { return <>{children}; }; diff --git a/app/[locale]/(protected)/knowledge-base/page.tsx b/app/[locale]/(protected)/knowledge-base/page.tsx index f5995af4..55edf433 100644 --- a/app/[locale]/(protected)/knowledge-base/page.tsx +++ b/app/[locale]/(protected)/knowledge-base/page.tsx @@ -1,35 +1,122 @@ -import SiteBreadcrumb from "@/components/site-breadcrumb"; -import { Card, CardContent } from "@/components/ui/card"; -import { Button } from "@/components/ui/button"; -import { UploadIcon } from "lucide-react"; -import BlogTable from "./table/blog-table"; +'use client' + +import { + Accordion, + AccordionContent, + AccordionItem, + AccordionTrigger, +} from "@/components/ui/accordion"; +import {Card, CardContent} from "@/components/ui/card"; +import {Tabs, TabsContent, TabsList, TabsTrigger} from "@/components/ui/tabs"; +import SiteBreadcrumb from "@/components/site-breadcrumb"; +import {getKnowledgeBaseCategoryList, getKnowledgeBaseList} from "@/service/master/knowledge-base"; +import React from "react"; +import {Plus} from "lucide-react"; +import {Button} from "@/components/ui/button"; + +const KnowledgeBase = () => { + const [categories, setCategories] = React.useState([]); + const [questions, setQuestions] = React.useState([]); + + React.useEffect(() => { + fetchCategoryList(); + }, []); + + async function fetchCategoryList() { + const response = await getKnowledgeBaseCategoryList(); + const data = response.data?.data; + if (data) { + setCategories(data); + fetchQuestions(data[0]?.id) + } + } + + const fetchQuestions = async (id: number) => { + const response = await getKnowledgeBaseList(id); + const data = response.data?.data; + if (data) { + setQuestions(data); + } + } -const BlogPage = async () => { return ( -
- -
- -
-
- Table Indeks -
-
- +
+ + +
+ + + + + {categories?.map((category: any, index: number) => ( + { + fetchQuestions(category?.id); + }} + className="data-[state=active]:bg-secondary data-[state=active]:text-default rounded-md px-6 py-3 w-full justify-start" + > + {category?.name} + + ))} + + + +
+ {categories?.map((cateogry: any, index: number) => ( + + + {questions?.map((question: any) => ( + + + {question.question} + + + {question.answer} + + + )) + } + + {questions?.length > 0 && +
+ + +
+ } +
+ ))}
- - - - - - +
-
); }; -export default BlogPage; +export default KnowledgeBase; diff --git a/app/[locale]/(protected)/knowledge-base/table/blog-table.tsx b/app/[locale]/(protected)/knowledge-base/table/blog-table.tsx deleted file mode 100644 index bb8974d7..00000000 --- a/app/[locale]/(protected)/knowledge-base/table/blog-table.tsx +++ /dev/null @@ -1,333 +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 { - Table, - TableBody, - TableCell, - TableHead, - TableHeader, - TableRow, -} from "@/components/ui/table"; -import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; -import { - Badge, - ChevronLeft, - ChevronRight, - Eye, - MoreVertical, - Search, - 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 = { - no: number; - title: string; - category: string; - createdAt: string; - tags: string; - statusName: string; -}; -import { data } from "./data"; -import { Input } from "@/components/ui/input"; -import { InputGroup, InputGroupText } from "@/components/ui/input-group"; -import { paginationBlog } from "@/service/blog/blog"; - -export const columns: ColumnDef[] = [ - { - accessorKey: "no", - header: "No", - cell: ({ row }) => ( -
-
-

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

-
-
- ), - }, - { - accessorKey: "title", - header: "Judul", - cell: ({ row }) => ( -
-
-

- {row.getValue("title")} -

-
-
- ), - }, - { - accessorKey: "categoryName", - header: "Kategori ", - cell: ({ row }) => ( - {row.getValue("categoryName")} - ), - }, - { - accessorKey: "createdAt", - header: "Tanggal Unggah ", - cell: ({ row }) => ( - {row.getValue("createdAt")} - ), - }, - { - accessorKey: "tags", - header: "Tag ", - cell: ({ row }) => ( - {row.getValue("tags")} - ), - }, - { - accessorKey: "statusName", - header: "Status", - cell: ({ row }) => { - return ( - - {row.getValue("statusName")} - - ); - }, - }, - { - id: "actions", - accessorKey: "action", - header: "Actions", - enableHiding: false, - cell: ({ row }) => { - return ( - - - - - - - - View - - - - Edit - - - - Delete - - - - ); - }, - }, -]; - -const BlogTable = () => { - const [blogTable, setBlogTable] = React.useState([]); - 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 table = useReactTable({ - data: blogTable, - 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(() => { - initState(); - }, [page, limit]); - - async function initState() { - try { - const res = await paginationBlog(limit, page); - const data = res.data.data.content.map((item: any, index: number) => ({ - no: (page - 1) * limit + index + 1, - title: item.title, - categoryName: item.categoryName, - tags: item.tags, - assignmentType: item.assignmentType?.name || "-", - createdAt: item.createdAt, - statusName: item.statusName, - })); - - setBlogTable(data); - setTotalPage(res.data.totalPages); - } catch (error) { - console.error("Error fetching tasks:", error); - } - } - - return ( -
-
-
- - - - - - -
-
- ) => - table.getColumn("status")?.setFilterValue(event.target.value) - } - className="max-w-sm " - /> -
-
- - - {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.getFilteredSelectedRowModel().rows.length} of{" "} - {table.getFilteredRowModel().rows.length} row(s) selected. -
-
- - {table.getPageOptions().map((page, pageIndex) => ( - - ))} - -
-
-
- ); -}; - -export default BlogTable; diff --git a/app/[locale]/(protected)/knowledge-base/table/data.ts b/app/[locale]/(protected)/knowledge-base/table/data.ts deleted file mode 100644 index 6bb2b47a..00000000 --- a/app/[locale]/(protected)/knowledge-base/table/data.ts +++ /dev/null @@ -1,65 +0,0 @@ -export const data = [ - { - title: "Ops Mantap Praja & Pilkada 2024", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - status: "Terkirim", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, -]; diff --git a/app/[locale]/(protected)/layout.tsx b/app/[locale]/(protected)/layout.tsx index e76aca90..32ba9850 100644 --- a/app/[locale]/(protected)/layout.tsx +++ b/app/[locale]/(protected)/layout.tsx @@ -15,10 +15,10 @@ const layout = async ({ children }: { children: React.ReactNode }) => { return ( - {/* */} + {children} - {/* */} + ); }; diff --git a/app/[locale]/(protected)/ticketing/components/columns.tsx b/app/[locale]/(protected)/ticketing/components/columns.tsx new file mode 100644 index 00000000..220ac21d --- /dev/null +++ b/app/[locale]/(protected)/ticketing/components/columns.tsx @@ -0,0 +1,125 @@ + +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 { Badge } from "@/components/ui/badge"; + +const columns: ColumnDef[] = [ + { + accessorKey: "no", + header: "No", + cell: ({ row }) => {row.getValue("no")}, + }, + { + accessorKey: "referenceNumber", + header: "Ticket Number", + cell: ({ row }) => {row.getValue("referenceNumber")}, + }, + { + accessorKey: "title", + header: "Title", + cell: ({ row }) => {row.getValue("title")}, + }, + { + accessorKey: "commentFromUserName", + header: "Sender", + cell: ({ row }) => {row.getValue("commentFromUserName")}, + }, + { + accessorKey: "type", + header: "Channel", + cell: ({ row }) => { + const type = row.getValue("type") as { name: string }; + return {type?.name}; + }, + }, + { + accessorKey: "createdBy", + header: "Operator", + cell: ({ row }) => { + const createdBy = row.getValue("createdBy") as { fullname: string }; + return {createdBy?.fullname}; + }, + }, + { + accessorKey: "createdAt", + header: "Tanggal Unggah ", + cell: ({ row }) => ( + {row.getValue("createdAt")} + ), + }, + { + accessorKey: "status", + header: "Status", + cell: ({ row }) => { + const statusColors: Record = { + open: "bg-primary/20 text-primary", + close: "bg-success/20 text-success", + }; + const status = row.getValue("status") as { id: number, name: string };; + const statusName = status?.name?.toLocaleLowerCase(); + console.log(statusName); + const statusStyles = statusColors[statusName] || "default"; + if (statusName) { + return ( + {statusName} + ); + } + } + }, + { + id: "actions", + accessorKey: "action", + header: "Actions", + enableHiding: false, + cell: ({ row }) => { + return ( + + + + + + + + View + + + + Edit + + + + Delete + + + + ); + }, + }, +]; + +export default columns; \ No newline at end of file diff --git a/app/[locale]/(protected)/ticketing/table/ticketing-table.tsx b/app/[locale]/(protected)/ticketing/components/table.tsx similarity index 61% rename from app/[locale]/(protected)/ticketing/table/ticketing-table.tsx rename to app/[locale]/(protected)/ticketing/components/table.tsx index f91aa5e2..dd7d93eb 100644 --- a/app/[locale]/(protected)/ticketing/table/ticketing-table.tsx +++ b/app/[locale]/(protected)/ticketing/components/table.tsx @@ -43,122 +43,20 @@ import { DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu"; - -import { data } from "./data"; 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 TablePagination from "../../blog/table/table-pagination"; import { useRouter, useSearchParams } from "next/navigation"; - -export const columns: ColumnDef[] = [ - { - accessorKey: "no", - header: "No", - cell: ({ row }) => {row.getValue("no")}, - }, - { - accessorKey: "referenceNumber", - header: "Ticket Number", - cell: ({ row }) => {row.getValue("referenceNumber")}, - }, - { - accessorKey: "title", - header: "Title", - cell: ({ row }) => {row.getValue("title")}, - }, - { - accessorKey: "commentFromUserName", - header: "Sender", - cell: ({ row }) => {row.getValue("commentFromUserName")}, - }, - { - accessorKey: "type", - header: "Channel", - cell: ({ row }) => { - const type = row.getValue("type") as { name: string }; - return {type?.name}; - }, - }, - { - accessorKey: "createdBy", - header: "Operator", - cell: ({ row }) => { - const createdBy = row.getValue("createdBy") as { fullname: string }; - return {createdBy?.fullname}; - }, - }, - { - accessorKey: "createdAt", - header: "Tanggal Unggah ", - cell: ({ row }) => ( - {row.getValue("createdAt")} - ), - }, - { - accessorKey: "status", - header: "Status", - cell: ({ row }) => { - const statusColors: Record = { - open: "bg-primary/20 text-primary", - close: "bg-success/20 text-success", - }; - const status = row.getValue("status") as { id: number, name: string };; - const statusName = status?.name?.toLocaleLowerCase(); - console.log(statusName); - const statusStyles = statusColors[statusName] || "default"; - if (statusName) { - return ( - {statusName} - ); - } - } - }, - { - id: "actions", - accessorKey: "action", - header: "Actions", - enableHiding: false, - cell: ({ row }) => { - return ( - - - - - - - - View - - - - Edit - - - - Delete - - - - ); - }, - }, -]; +import TablePagination from "@/components/table/table-pagination"; +import columns from "./columns"; const TicketingTable = () => { const router = useRouter(); const searchParams = useSearchParams(); - const [ticketData, setTicketData] = React.useState([]); + + const [dataTable, setDataTable] = React.useState([]); const [totalData, setTotalData] = React.useState(1); const [sorting, setSorting] = React.useState([]); const [columnFilters, setColumnFilters] = React.useState( @@ -176,7 +74,7 @@ const TicketingTable = () => { const [limit, setLimit] = React.useState(10); const table = useReactTable({ - data: ticketData, + data: dataTable, columns, onSortingChange: setSorting, onColumnFiltersChange: setColumnFilters, @@ -218,7 +116,7 @@ const TicketingTable = () => { console.log("contentData : ", contentData); - setTicketData(contentData); + setDataTable(contentData); setTotalData(data?.totalElements); setTotalPage(data?.totalPages); } catch (error) { @@ -228,7 +126,7 @@ const TicketingTable = () => { return (
-
+
@@ -254,7 +152,7 @@ const TicketingTable = () => { />
- +
{table.getHeaderGroups().map((headerGroup) => ( @@ -295,7 +193,7 @@ const TicketingTable = () => { )}
- +
); }; diff --git a/app/[locale]/(protected)/ticketing/page.tsx b/app/[locale]/(protected)/ticketing/page.tsx index 84568e2f..2347aa21 100644 --- a/app/[locale]/(protected)/ticketing/page.tsx +++ b/app/[locale]/(protected)/ticketing/page.tsx @@ -1,24 +1,35 @@ import SiteBreadcrumb from "@/components/site-breadcrumb"; -import { Card, CardContent } from "@/components/ui/card"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { UploadIcon } from "lucide-react"; -import TicketingTable from "./table/ticketing-table"; +import TicketingTable from "./components/table"; const TicketingPage = async () => { return (
- -
-
- Ticketing Table -
-
-
- - + + +
+
+ Ticket Data +
+
+ {/* */} +
+
+
+
+ +
diff --git a/app/[locale]/(protected)/ticketing/table/data.ts b/app/[locale]/(protected)/ticketing/table/data.ts deleted file mode 100644 index 6bb2b47a..00000000 --- a/app/[locale]/(protected)/ticketing/table/data.ts +++ /dev/null @@ -1,65 +0,0 @@ -export const data = [ - { - title: "Ops Mantap Praja & Pilkada 2024", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - status: "Terkirim", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Ops Mantap Praja & Pilkada 2024", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, - { - title: "Seputar Prestasi", - status: "Terkirim", - category: "Giat Pimpinan", - date: "15/10/2024 9:11", - tag: "percobaan", - }, -]; diff --git a/components/partials/header/index.tsx b/components/partials/header/index.tsx index 2d48037a..8f6314a6 100644 --- a/components/partials/header/index.tsx +++ b/components/partials/header/index.tsx @@ -27,7 +27,7 @@ const DashCodeHeader = async () => { - {/* */} +
diff --git a/components/site-breadcrumb.tsx b/components/site-breadcrumb.tsx index e0dc4a36..b5b6fa04 100644 --- a/components/site-breadcrumb.tsx +++ b/components/site-breadcrumb.tsx @@ -27,7 +27,7 @@ const SiteBreadcrumb = ({ children }: { children?: ReactNode }) => { - + @@ -43,9 +43,9 @@ const SiteBreadcrumb = ({ children }: { children?: ReactNode }) => { {isLast ? ( - itemLink + itemLink?.replaceAll("-", " ") ) : ( - {itemLink} + {itemLink?.replaceAll("-", "")} )} {locations.length !== index + 1 && } diff --git a/components/table/table-pagination.tsx b/components/table/table-pagination.tsx index e69de29b..8a62e034 100644 --- a/components/table/table-pagination.tsx +++ b/components/table/table-pagination.tsx @@ -0,0 +1,121 @@ +import { Button } from '@/components/ui/button'; +import { useMediaQuery } from '@/hooks/use-media-query'; +import { Table } from '@tanstack/react-table'; +import { ChevronLeft, ChevronRight, ChevronsLeft, ChevronsRight } from 'lucide-react'; +import { useSearchParams, useRouter } from 'next/navigation'; +import React, { useEffect, useState } from 'react'; + +interface DataTablePaginationProps { + table: Table; + totalPage: number; // Total jumlah halaman + totalData: number; // Total jumlah data + visiblePageCount?: number; // Jumlah halaman yang ditampilkan (default 5) +} + +const TablePagination = ({ + table, + totalPage, + totalData, + visiblePageCount = 5, +}: DataTablePaginationProps) => { + const router = useRouter(); + const searchParams = useSearchParams(); + + const [currentPageIndex, setCurrentPageIndex] = useState(1); + + + const isMobile = useMediaQuery("(min-width: 768px)"); + if (!isMobile) { + visiblePageCount = 3; + } + + useEffect(() => { + const pageFromUrl = searchParams?.get('page'); + if (pageFromUrl) { + const pageIndex = Math.min(Math.max(1, Number(pageFromUrl)), totalPage); + setCurrentPageIndex(pageIndex); + table.setPageIndex(pageIndex - 1); // Sinkronisasi tabel dengan URL + } + }, [searchParams, totalPage, table]); + + const handlePageChange = (pageIndex: number) => { + const clampedPageIndex = Math.min(Math.max(1, pageIndex), totalPage); + const searchParams = new URLSearchParams(window.location.search); + searchParams.set('page', clampedPageIndex.toString()); + + router.push(`${window.location.pathname}?${searchParams.toString()}`); + setCurrentPageIndex(clampedPageIndex); + table.setPageIndex(clampedPageIndex - 1); // Perbarui tabel dengan index berbasis 0 + }; + + const generatePageNumbers = () => { + const halfVisible = Math.floor(visiblePageCount / 2); + let startPage = Math.max(1, currentPageIndex - halfVisible); + let endPage = Math.min(totalPage, startPage + visiblePageCount - 1); + + if (endPage - startPage + 1 < visiblePageCount) { + startPage = Math.max(1, endPage - visiblePageCount + 1); + } + + return Array.from({ length: endPage - startPage + 1 }, (_, i) => startPage + i); + }; + + return ( +
+
+ {table.getFilteredSelectedRowModel().rows.length} of {totalData} row(s) selected. +
+
+ + + {generatePageNumbers().map((pageIndex) => ( + + ))} + + +
+
+ ); +}; + +export default TablePagination; \ No newline at end of file diff --git a/components/ui/tabs.tsx b/components/ui/tabs.tsx index 7319bcf9..d7fb7f46 100644 --- a/components/ui/tabs.tsx +++ b/components/ui/tabs.tsx @@ -24,14 +24,19 @@ TabsList.displayName = TabsPrimitive.List.displayName const TabsTrigger = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( + React.ComponentPropsWithoutRef & { onClick?: () => void } +>(({ className, onClick, ...props }, ref) => ( { + if (onClick) { + onClick() + } + }} {...props} /> )) diff --git a/lib/menus.ts b/lib/menus.ts index 23634a99..39827bc7 100644 --- a/lib/menus.ts +++ b/lib/menus.ts @@ -1445,43 +1445,43 @@ export function getMenuList(pathname: string, t: any): Group[] { menus: [ { id: "communication", - href: "/communication", + href: "/communications", label: t("communication"), - active: pathname.includes("/communication"), + active: pathname.includes("/communications"), icon: "icon-park-outline:communication", submenus: [ { - href: "/communication/questions", + href: "/communications/questions", label: t("questions"), - active: pathname.includes("/communication/questions"), + active: pathname.includes("/communications/questions"), icon: "solar:inbox-line-outline", children: [], }, { - href: "/communication/internal", + href: "/communications/internal", label: t("internal"), - active: pathname.includes("/communication/internal"), + active: pathname.includes("/communications/internal"), icon: "ri:chat-private-line", children: [], }, { - href: "/communication/forward", + href: "/communications/forward", label: t("forward"), - active: pathname.includes("/communication/forward"), + active: pathname.includes("/communications/forward"), icon: "ri:share-forward-2-fill", children: [], }, { - href: "/communication/collaboration", + href: "/communications/collaboration", label: t("collaboration"), - active: pathname.includes("/communication/collaboration"), + active: pathname.includes("/communications/collaboration"), icon: "clarity:employee-group-line", children: [], }, { - href: "/communication/account-report", + href: "/communications/account-report", label: t("account-report"), - active: pathname.includes("/communication/account-report"), + active: pathname.includes("/communications/account-report"), icon: "uiw:user-delete", children: [], }, diff --git a/service/master/faq.ts b/service/master/faq.ts new file mode 100644 index 00000000..66fa4856 --- /dev/null +++ b/service/master/faq.ts @@ -0,0 +1,8 @@ +import { + httpGetInterceptor, +} from "../http-config/http-interceptor-service"; + +export async function getFaqList() { + const url = `master/faq/list`; + return httpGetInterceptor(url); +} \ No newline at end of file diff --git a/service/master/knowledge-base.ts b/service/master/knowledge-base.ts index 5af98fd1..5f9b5ec8 100644 --- a/service/master/knowledge-base.ts +++ b/service/master/knowledge-base.ts @@ -1,15 +1,13 @@ import { httpGetInterceptor, - httpPostInterceptor, } from "../http-config/http-interceptor-service"; -export async function listContest(size: number, page: number) { - return await httpGetInterceptor( - `contest/pagination?enablePage=1&size=${size}&page=${page}` - ); +export async function getKnowledgeBaseCategoryList() { + const url = `knowledge-base/category/list`; + return httpGetInterceptor(url); } -export async function createTask(data: any) { - const url = "assignment"; - return httpPostInterceptor(url, data); +export async function getKnowledgeBaseList(id: number) { + const url = `knowledge-base?categoryId=${id}`; + return httpGetInterceptor(url); }