diff --git a/app/[locale]/(protected)/admin/add-experts/component/column.tsx b/app/[locale]/(protected)/admin/add-experts/component/column.tsx index 528d9436..37b97cab 100644 --- a/app/[locale]/(protected)/admin/add-experts/component/column.tsx +++ b/app/[locale]/(protected)/admin/add-experts/component/column.tsx @@ -40,19 +40,19 @@ const columns: ColumnDef[] = [ }, { - accessorKey: "name", + accessorKey: "fullname", header: "Nama", - cell: ({ row }) => {row.getValue("name")}, + cell: ({ row }) => {row.getValue("fullname")}, }, { - accessorKey: "region", + accessorKey: "address", header: "Wilayah", - cell: ({ row }) => {row.getValue("region")}, + cell: ({ row }) => {row.getValue("address")}, }, { - accessorKey: "skills", + accessorKey: "role.name", header: "Bidang Keahlian", - cell: ({ row }) => {row.getValue("skills")}, + cell: ({ row }) => {row.original.role?.name ?? "-"}, }, { diff --git a/app/[locale]/(protected)/admin/add-experts/component/table.tsx b/app/[locale]/(protected)/admin/add-experts/component/table.tsx index 90f87f87..d3f08916 100644 --- a/app/[locale]/(protected)/admin/add-experts/component/table.tsx +++ b/app/[locale]/(protected)/admin/add-experts/component/table.tsx @@ -53,6 +53,7 @@ import { listEnableCategory } from "@/service/content/content"; import { Checkbox } from "@/components/ui/checkbox"; import { close, loading } from "@/config/swal"; import { Link } from "@/i18n/routing"; +import { listDataExperts } from "@/service/experts/experts"; const dummyData = [ { @@ -93,6 +94,7 @@ const AddExpertTable = () => { const [statusFilter, setStatusFilter] = React.useState([]); const [page, setPage] = React.useState(1); const [totalPage, setTotalPage] = React.useState(1); + const [limit, setLimit] = React.useState(10); const table = useReactTable({ data: dataTable, columns, @@ -145,19 +147,44 @@ const AddExpertTable = () => { }); }, [page, showData]); - async function fetchData() { - try { - loading(); + // async function fetchData() { + // try { + // loading(); - const contentData = dummyData; + // const contentData = dummyData; + // contentData.forEach((item: any, index: number) => { + // item.no = (page - 1) * Number(showData) + index + 1; + // }); + + // setDataTable(contentData); + // setTotalData(contentData?.length); + // setTotalPage(1); + // close(); + // } catch (error) { + // console.error("Error fetching tasks:", error); + // } + // } + + async function fetchData() { + // const formattedStartDate = startDate + // ? format(new Date(startDate), "yyyy-MM-dd") + // : ""; + // const formattedEndDate = endDate + // ? format(new Date(endDate), "yyyy-MM-dd") + // : ""; + try { + // const isForSelf = Number(roleId) === 4; + const res = await listDataExperts(limit, page - 1); + + const data = res?.data?.data; + const contentData = data?.content; contentData.forEach((item: any, index: number) => { - item.no = (page - 1) * Number(showData) + index + 1; + item.no = (page - 1) * limit + index + 1; }); setDataTable(contentData); - setTotalData(contentData?.length); - setTotalPage(1); - close(); + setTotalData(data?.totalElements); + setTotalPage(data?.totalPages); } catch (error) { console.error("Error fetching tasks:", error); } diff --git a/service/experts/experts.ts b/service/experts/experts.ts new file mode 100644 index 00000000..6dba24b5 --- /dev/null +++ b/service/experts/experts.ts @@ -0,0 +1,21 @@ +import { + httpDeleteInterceptor, + httpGetInterceptor, + httpPostInterceptor, +} from "../http-config/http-interceptor-service"; + +export async function listDataExperts(size: number, page: number) { + return await httpGetInterceptor( + `users/pagination/internal?enablePage=1&size=${size}&page=${page}&roleId=19&levelId=1` + ); +} + +export async function postBlog(data: any) { + const url = "blog"; + return httpPostInterceptor(url, data); +} + +export async function getBlog(id: any) { + const url = `blog/${id}`; + return httpGetInterceptor(url); +}