From bd40ceab56436b9af0e50d6c660681a2754e67c3 Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Wed, 28 May 2025 13:56:41 +0700 Subject: [PATCH] fix:time stamp --- app/(admin)/admin/master-category/page.tsx | 3 +- .../form/article/create-article-form.tsx | 18 +++-- components/form/article/edit-article-form.tsx | 8 +- components/form/form-master-user-edit.tsx | 4 +- components/form/form-master-user-role.tsx | 2 +- components/form/login.tsx | 5 +- components/landing/HeaderNews.tsx | 4 +- components/landing/footer-new.tsx | 9 +++ .../main/dashboard/chart/column-chart.tsx | 5 +- .../chart/suggestions-line-chart.tsx | 6 +- .../main/dashboard/dashboard-container.tsx | 8 +- .../table/advertise/advertise-table.tsx | 6 +- components/table/article-table.tsx | 8 +- components/table/comment/comment-table.tsx | 4 +- components/table/magazine/magazine-table.tsx | 9 +-- .../master-categories/categories-table.tsx | 5 +- components/table/master-role-table.tsx | 50 ++---------- components/table/master-user-table.tsx | 2 + .../master-user-level-table.tsx | 3 + components/table/static-page-table.tsx | 4 +- .../table/suggestions/suggestions-table.tsx | 9 ++- services/advertisement.ts | 27 +++++-- services/article.ts | 79 +++++++++++++------ services/comment.ts | 7 +- services/feedbacks.ts | 5 +- services/magazine.tsx | 16 ++-- services/master-user-role.ts | 8 +- services/master-user.ts | 4 +- services/static-page-service.ts | 8 +- services/user-levels/user-levels-service.ts | 8 +- types/globals.tsx | 1 + 31 files changed, 196 insertions(+), 139 deletions(-) diff --git a/app/(admin)/admin/master-category/page.tsx b/app/(admin)/admin/master-category/page.tsx index 73aae91..aca1b96 100644 --- a/app/(admin)/admin/master-category/page.tsx +++ b/app/(admin)/admin/master-category/page.tsx @@ -34,6 +34,7 @@ import { import Swal from "sweetalert2"; import withReactContent from "sweetalert2-react-content"; import Image from "next/image"; +import { getUnixTimestamp } from "@/utils/global"; const categorySchema = z.object({ id: z.number(), @@ -104,7 +105,7 @@ export default function MasterCategoryTable() { }, []); const fetchCategory = async () => { - const res = await getArticleByCategory(); + const res = await getArticleByCategory(getUnixTimestamp()); if (res?.data?.data) { setupCategory(res?.data?.data); } diff --git a/components/form/article/create-article-form.tsx b/components/form/article/create-article-form.tsx index dab56f9..cf7a65f 100644 --- a/components/form/article/create-article-form.tsx +++ b/components/form/article/create-article-form.tsx @@ -47,7 +47,11 @@ import { useDisclosure, } from "@heroui/react"; import GenerateSingleArticleForm from "./generate-ai-single-form"; -import { convertDateFormatNoTime, htmlToString } from "@/utils/global"; +import { + convertDateFormatNoTime, + getUnixTimestamp, + htmlToString, +} from "@/utils/global"; import { close, error, loading, successToast } from "@/config/swal"; import { useRouter } from "next/navigation"; import Link from "next/link"; @@ -104,9 +108,9 @@ const createArticleSchema = z.object({ description: z.string().min(2, { message: "Deskripsi harus diisi", }), - // category: z.array(categorySchema).nonempty({ - // message: "Kategori harus memiliki setidaknya satu item", - // }), + category: z.array(categorySchema).nonempty({ + message: "Kategori harus memiliki setidaknya satu item", + }), tags: z.array(z.string()).nonempty({ message: "Minimal 1 tag", }), @@ -174,7 +178,7 @@ export default function CreateArticleForm() { }, []); const fetchCategory = async () => { - const res = await getArticleByCategory(); + const res = await getArticleByCategory(getUnixTimestamp()); if (res?.data?.data) { setupCategory(res?.data?.data); } @@ -701,7 +705,7 @@ export default function CreateArticleForm() { )} - {/*

Kategori

+

Kategori

{errors.category?.message}

- )} */} + )}

Tags

{ - const res = await getArticleByCategory(); + const res = await getArticleByCategory(getUnixTimestamp()); if (res?.data?.data) { setupCategory(res?.data?.data); } diff --git a/components/form/form-master-user-edit.tsx b/components/form/form-master-user-edit.tsx index 1bf54b2..5f36cf6 100644 --- a/components/form/form-master-user-edit.tsx +++ b/components/form/form-master-user-edit.tsx @@ -31,6 +31,7 @@ import ReactSelect from "react-select"; import makeAnimated from "react-select/animated"; import { getAllUserLevels } from "@/services/user-levels/user-levels-service"; import { listUserRole } from "@/services/master-user-role"; +import { getUnixTimestamp } from "@/utils/global"; const userSchema = z.object({ id: z.number(), @@ -153,7 +154,7 @@ export default function FormMasterUserEdit() { }; const fetchUserLevel = async () => { - const res = await getAllUserLevels(); + const res = await getAllUserLevels({ timeStamp: getUnixTimestamp() }); if (res?.data?.data) { return setupParent(res?.data?.data, "level"); } @@ -162,6 +163,7 @@ export default function FormMasterUserEdit() { const request = { limit: 100, page: 1, + timeStamp: getUnixTimestamp(), }; const res = await listUserRole(request); if (res?.data?.data) { diff --git a/components/form/form-master-user-role.tsx b/components/form/form-master-user-role.tsx index 99912bb..ad1ba83 100644 --- a/components/form/form-master-user-role.tsx +++ b/components/form/form-master-user-role.tsx @@ -231,7 +231,7 @@ export default function FormMasterUserRole() {

Menus

{fields.map((field, index) => (
-

{field.menuTitle}

+ {/*

{field.menuTitle}

*/}
{/* Option */} { + setHasMounted(true); + }, []); + + // Render + if (!hasMounted) return null; + return (
{ const splitDate = date.split(" "); - const res = await getStatisticMonthly(splitDate[1]); + const res = await getStatisticMonthly(splitDate[1], getUnixTimestamp()); const data = res?.data?.data; const getDatas = data?.find( (a: any) => @@ -122,8 +123,6 @@ const ApexChartColumn = (props: { }, ]; - console.log("temp", temp); - setSeries(temp); }, [view, seriesShare, seriesView, seriesComment]); diff --git a/components/main/dashboard/chart/suggestions-line-chart.tsx b/components/main/dashboard/chart/suggestions-line-chart.tsx index 81db66f..fdb4f24 100644 --- a/components/main/dashboard/chart/suggestions-line-chart.tsx +++ b/components/main/dashboard/chart/suggestions-line-chart.tsx @@ -6,6 +6,7 @@ import { getStatisticMonthly, getStatisticMonthlyFeedback, } from "@/services/article"; +import { getUnixTimestamp } from "@/utils/global"; type WeekData = { week: number; @@ -91,7 +92,10 @@ const SuggestionsChart = (props: { const initFetch = async () => { const splitDate = date.split(" "); - const res = await getStatisticMonthlyFeedback(splitDate[1]); + const res = await getStatisticMonthlyFeedback( + splitDate[1], + getUnixTimestamp() + ); const data = res?.data?.data; // const data = dummyData.data; if (type === "monthly") { diff --git a/components/main/dashboard/dashboard-container.tsx b/components/main/dashboard/dashboard-container.tsx index f3a6561..ec432d3 100644 --- a/components/main/dashboard/dashboard-container.tsx +++ b/components/main/dashboard/dashboard-container.tsx @@ -40,6 +40,7 @@ import { convertDateFormat, convertDateFormatNoTime, convertDateFormatNoTimeV2, + getUnixTimestamp, textEllipsis, } from "@/utils/global"; import { parseDate, getLocalTimeZone } from "@internationalized/date"; @@ -109,6 +110,7 @@ export default function DashboardContainer() { page: page, search: "", sort: "desc", + timeStamp: getUnixTimestamp(), }; const res = await getListArticleAdminPage(req); setArticle(res.data?.data); @@ -116,7 +118,7 @@ export default function DashboardContainer() { } async function fetchSummary() { - const res = await getStatisticSummary(); + const res = await getStatisticSummary(getUnixTimestamp()); setSummary(res?.data?.data); } @@ -131,6 +133,7 @@ export default function DashboardContainer() { search: "", sort: "desc", isPublish: true, + timeStamp: getUnixTimestamp(), }; const res = await getTopArticles(req); setTopPages(getTableNumber(10, res.data?.data)); @@ -148,7 +151,8 @@ export default function DashboardContainer() { }; const res = await getUserLevelDataStat( getDate(postContentDate.startDate), - getDate(postContentDate.endDate) + getDate(postContentDate.endDate), + getUnixTimestamp() ); setPostCount(getTableNumber(10, res?.data?.data)); } diff --git a/components/table/advertise/advertise-table.tsx b/components/table/advertise/advertise-table.tsx index 272db62..f576b47 100644 --- a/components/table/advertise/advertise-table.tsx +++ b/components/table/advertise/advertise-table.tsx @@ -16,7 +16,7 @@ import { getListArticle, } from "@/services/article"; import { Article } from "@/types/globals"; -import { convertDateFormat } from "@/utils/global"; +import { convertDateFormat, getUnixTimestamp } from "@/utils/global"; import { Button } from "@heroui/button"; import { Chip, @@ -64,6 +64,7 @@ import { editAdvertise, editAdvertiseIsActive, getAdvertise, + getAdvertiseAdmin, } from "@/services/advertisement"; const columns = [ @@ -150,8 +151,9 @@ export default function AdvertiseTable(props: { triggerRefresh: boolean }) { sort: "desc", sortBy: "created_at", + timeStamp: getUnixTimestamp(), }; - const res = await getAdvertise(req); + const res = await getAdvertiseAdmin(req); getTableNumber(parseInt(showData), res.data?.data); setTotalPage(res?.data?.meta?.totalPage); } diff --git a/components/table/article-table.tsx b/components/table/article-table.tsx index 478f653..cbcf3bd 100644 --- a/components/table/article-table.tsx +++ b/components/table/article-table.tsx @@ -21,6 +21,7 @@ import { convertDateFormat, convertDateFormatNoTime, convertDateFormatNoTimeV2, + getUnixTimestamp, } from "@/utils/global"; import { Button } from "@heroui/button"; import { @@ -159,7 +160,11 @@ export default function ArticleTable() { }; async function getUsers() { - const res = await listMasterUsers({ page: page, limit: -1 }); + const res = await listMasterUsers({ + page: page, + limit: -1, + timeStamp: getUnixTimestamp(), + }); setupList(res?.data?.data, "users"); } @@ -209,6 +214,7 @@ export default function ArticleTable() { createdByIds: getIds(selectedUsers), sort: "desc", sortBy: "created_at", + timeStamp: getUnixTimestamp(), }; const res = await getListArticleAdminPage(req); await getTableNumber(parseInt(showData), res.data?.data); diff --git a/components/table/comment/comment-table.tsx b/components/table/comment/comment-table.tsx index d839d55..ae12d5a 100644 --- a/components/table/comment/comment-table.tsx +++ b/components/table/comment/comment-table.tsx @@ -17,7 +17,7 @@ import { getListArticle, } from "@/services/article"; import { Article } from "@/types/globals"; -import { convertDateFormat } from "@/utils/global"; +import { convertDateFormat, getUnixTimestamp } from "@/utils/global"; import { Button } from "@heroui/button"; import { Chip, @@ -55,7 +55,6 @@ import { Controller, useForm } from "react-hook-form"; import Swal from "sweetalert2"; import withReactContent from "sweetalert2-react-content"; import { useDropzone } from "react-dropzone"; -import Image from "next/image"; import { useRouter } from "next/navigation"; import { getComments } from "@/services/comment"; @@ -92,6 +91,7 @@ export default function CommentTable() { limit: showData, page: page, search: search, + timeStamp: getUnixTimestamp(), }; const res = await getComments(req); getTableNumber(parseInt(showData), res.data?.data); diff --git a/components/table/magazine/magazine-table.tsx b/components/table/magazine/magazine-table.tsx index 03a08ea..91d3fdb 100644 --- a/components/table/magazine/magazine-table.tsx +++ b/components/table/magazine/magazine-table.tsx @@ -14,7 +14,7 @@ import { } from "@/services/article"; import { deleteMagazine, getListMagazine } from "@/services/magazine"; import { Article } from "@/types/globals"; -import { convertDateFormat } from "@/utils/global"; +import { convertDateFormat, getUnixTimestamp } from "@/utils/global"; import { Button } from "@heroui/button"; import { Chip, @@ -35,6 +35,7 @@ import { TableHeader, TableRow, } from "@heroui/react"; +import { timeStamp } from "console"; import Link from "next/link"; import { Key, useCallback, useEffect, useState } from "react"; import Datepicker from "react-tailwindcss-datepicker"; @@ -79,9 +80,8 @@ export default function MagazineTable() { }, []); async function getCategories() { - const res = await getArticleByCategory(); + const res = await getArticleByCategory(getUnixTimestamp()); const data = res?.data?.data; - console.log("datass", res?.data?.data); setCategoies(data); } @@ -93,10 +93,10 @@ export default function MagazineTable() { startDate: startDateValue.startDate === null ? "" : startDateValue.startDate, endDate: startDateValue.endDate === null ? "" : startDateValue.endDate, + timeStamp: getUnixTimestamp(), }; const res = await getListMagazine(req); getTableNumber(parseInt(showData), res.data?.data); - console.log("res.data?.data magz", res.data); setTotalPage(res?.data?.meta?.totalPage); } @@ -109,7 +109,6 @@ export default function MagazineTable() { value.no = startIndex + iterate; return value; }); - console.log("daata", data); setArticle(newData); } else { setArticle([]); diff --git a/components/table/master-categories/categories-table.tsx b/components/table/master-categories/categories-table.tsx index ab3bbc1..5977258 100644 --- a/components/table/master-categories/categories-table.tsx +++ b/components/table/master-categories/categories-table.tsx @@ -21,7 +21,7 @@ import { uploadCategoryThumbnail, } from "@/services/master-categories"; import { Article } from "@/types/globals"; -import { convertDateFormat } from "@/utils/global"; +import { convertDateFormat, getUnixTimestamp } from "@/utils/global"; import { Button } from "@heroui/button"; import { Chip, @@ -156,6 +156,7 @@ export default function CategoriesTable(props: { triggerRefresh: boolean }) { limit: showData, page: page, search: search, + timeStamp: getUnixTimestamp(), }; const res = await getCategoryPagination(req); getTableNumber(parseInt(showData), res.data?.data); @@ -210,7 +211,7 @@ export default function CategoriesTable(props: { triggerRefresh: boolean }) { }, []); const fetchCategory = async () => { - const res = await getArticleByCategory(); + const res = await getArticleByCategory(getUnixTimestamp()); if (res?.data?.data) { setupCategory(res?.data?.data); } diff --git a/components/table/master-role-table.tsx b/components/table/master-role-table.tsx index a9093ad..c2a7c50 100644 --- a/components/table/master-role-table.tsx +++ b/components/table/master-role-table.tsx @@ -12,6 +12,7 @@ import { listUserRole, } from "@/services/master-user-role"; import { MasterUser, MasterUserRole } from "@/types/globals"; +import { getUnixTimestamp } from "@/utils/global"; import { Button } from "@heroui/button"; import { Chip, @@ -59,7 +60,11 @@ export default function MasterRoleTable() { }, [page]); async function initState() { - const res = await listUserRole({ page: page, limit: 10 }); + const res = await listUserRole({ + page: page, + limit: 10, + timeStamp: getUnixTimestamp(), + }); getTableNumber(10, res?.data?.data); setTotalPage(res?.data?.meta?.totalPage); } @@ -132,49 +137,6 @@ export default function MasterRoleTable() { // { name: "Vacation", uid: "vacation" }, // ]; - const usersTable = [ - { - id: 1, - user: "Olivia Rhya", - status: "active", - projectName: "Xtreme admin", - avatar: - "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSa8Luglga9J2R3Bxt_PsWZISUHQWODD6_ZTAJ5mIQgxYCAE-YbkY81faTqp-hSA_jVPTs&usqp=CAU", - }, - { - id: 2, - user: "Barbara Steele", - status: "cancel", - projectName: "Adminpro admin", - avatar: - "https://cdn.icon-icons.com/icons2/2859/PNG/512/avatar_face_man_boy_male_profile_smiley_happy_people_icon_181661.png", - }, - { - id: 3, - user: "Leonardo Gordon", - status: "pending", - projectName: "Monster admin", - avatar: - "https://cdn.icon-icons.com/icons2/2859/PNG/512/avatar_face_man_boy_male_profile_smiley_happy_people_icon_181657.png", - }, - { - id: 4, - user: "Evelyn Pope", - status: "cancel", - projectName: "Materialpro admin", - avatar: - "https://cdn.icon-icons.com/icons2/3708/PNG/512/man_person_people_avatar_icon_230017.png", - }, - { - id: 5, - user: "Tommy Garza", - status: "cancel", - projectName: "Elegant admin", - avatar: - "https://cdn.icon-icons.com/icons2/1736/PNG/512/4043275-avatar-man-person-punk_113271.png", - }, - ]; - const renderCell = useCallback((role: MasterUserRole, columnKey: Key) => { const cellValue = role[columnKey as keyof MasterUserRole]; const statusColorMap: Record = { diff --git a/components/table/master-user-table.tsx b/components/table/master-user-table.tsx index 797bc18..672c67e 100644 --- a/components/table/master-user-table.tsx +++ b/components/table/master-user-table.tsx @@ -10,6 +10,7 @@ import { error, success } from "@/config/swal"; import { deleteArticle, getListArticle } from "@/services/article"; import { deleteMasterUser, listMasterUsers } from "@/services/master-user"; import { Article, MasterUser } from "@/types/globals"; +import { getUnixTimestamp } from "@/utils/global"; import { Button } from "@heroui/button"; import { Input } from "@heroui/input"; import { @@ -67,6 +68,7 @@ export default function MasterUserTable() { fullname: searchType === "fullname" ? search : "", username: searchType === "username" ? search : "", email: searchType === "email" ? search : "", + timeStamp: getUnixTimestamp(), }); getTableNumber(10, res?.data?.data); setTotalPage(res?.data?.meta?.totalPage); diff --git a/components/table/master/master-user-level/master-user-level-table.tsx b/components/table/master/master-user-level/master-user-level-table.tsx index 6ca8be8..a508d17 100644 --- a/components/table/master/master-user-level/master-user-level-table.tsx +++ b/components/table/master/master-user-level/master-user-level-table.tsx @@ -38,6 +38,7 @@ import { } from "@/services/user-levels/user-levels-service"; import { close, error, loading } from "@/config/swal"; import { stringify } from "querystring"; +import { getUnixTimestamp } from "@/utils/global"; type UserObject = { id: number; @@ -99,6 +100,7 @@ export default function MasterUserLevelTable() { page: page, limit: 10, search: search, + timeStamp: getUnixTimestamp(), }; const res = await getAllUserLevels(request); const data = res?.data?.data; @@ -112,6 +114,7 @@ export default function MasterUserLevelTable() { page: 1, limit: -1, search: "", + timeStamp: getUnixTimestamp(), }; const res = await getAllUserLevels(request); const data = res?.data?.data; diff --git a/components/table/static-page-table.tsx b/components/table/static-page-table.tsx index daaa7cc..52ab16e 100644 --- a/components/table/static-page-table.tsx +++ b/components/table/static-page-table.tsx @@ -10,7 +10,7 @@ import { error, success } from "@/config/swal"; import { deleteArticle, getListArticle } from "@/services/article"; import { getCustomStaticPage } from "@/services/static-page-service"; import { Article } from "@/types/globals"; -import { convertDateFormat } from "@/utils/global"; +import { convertDateFormat, getUnixTimestamp } from "@/utils/global"; import { Button } from "@heroui/button"; import { Chip, @@ -71,10 +71,10 @@ export default function StaticPageTable() { limit: showData, page: page, search: search, + timeStamp: getUnixTimestamp(), }; const res = await getCustomStaticPage(req); getTableNumber(parseInt(showData), res.data?.data); - console.log("res.data?.data", res.data); setTotalPage(res?.data?.meta?.totalPage); } diff --git a/components/table/suggestions/suggestions-table.tsx b/components/table/suggestions/suggestions-table.tsx index 2578e5c..4964f15 100644 --- a/components/table/suggestions/suggestions-table.tsx +++ b/components/table/suggestions/suggestions-table.tsx @@ -21,6 +21,7 @@ import { convertDateFormat, convertDateFormatNoTime, convertDateFormatNoTimeV2, + getUnixTimestamp, } from "@/utils/global"; import { Button } from "@heroui/button"; import { @@ -82,6 +83,7 @@ import { TextRun, WidthType, } from "docx"; +import { timeStamp } from "console"; interface ExportData { no: string; @@ -166,6 +168,7 @@ export default function SuggestionsTable() { search: search, startDate: getDate(feedbackDate.startDate), endDate: getDate(feedbackDate.endDate), + timeStamp: getUnixTimestamp(), }); getTableNumber(parseInt(showData), res.data?.data); setTotalPage(res?.data?.meta?.totalPage); @@ -357,7 +360,11 @@ export default function SuggestionsTable() { const [typeDate, setTypeDate] = useState("monthly"); const doExport = async () => { - const res = await getFeedbacks({ limit: showData, search: search }); + const res = await getFeedbacks({ + limit: showData, + search: search, + timeStamp: getUnixTimestamp(), + }); if (res?.data?.data) { exportRecap(res?.data?.data); } diff --git a/services/advertisement.ts b/services/advertisement.ts index fe5fa69..c96c7b4 100644 --- a/services/advertisement.ts +++ b/services/advertisement.ts @@ -1,10 +1,9 @@ +import { httpGet, httpPost, httpPut } from "./http-config/axios-base-service"; +import Cookies from "js-cookie"; import { httpDeleteInterceptor, - httpGet, - httpPost, - httpPut, -} from "./http-config/axios-base-service"; -import Cookies from "js-cookie"; + httpGetInterceptor, +} from "./http-config/http-interceptor-services"; const token = Cookies.get("access_token"); @@ -30,10 +29,24 @@ export async function getAdvertise(data: any) { }; const pathUrl = `/advertisement?page=${data?.page || 1}&limit=${ data?.limit || "" - }&placement=${data?.placement || ""}&isPublish=${data.isPublish || ""}`; + }&placement=${data?.placement || ""}&isPublish=${ + data.isPublish || "" + }&timeStamp=${data.timeStamp || ""}`; return await httpGet(pathUrl, headers); } +export async function getAdvertiseAdmin(data: any) { + const headers = { + "content-type": "application/json", + }; + const pathUrl = `/advertisement?page=${data?.page || 1}&limit=${ + data?.limit || "" + }&placement=${data?.placement || ""}&isPublish=${ + data.isPublish || "" + }&timeStamp=${data.timeStamp || ""}`; + return await httpGetInterceptor(pathUrl); +} + export async function createAdvertiseById(id: number) { const headers = { "content-type": "application/json", @@ -64,5 +77,5 @@ export async function deleteAdvertise(id: number) { "content-type": "application/json", }; const pathUrl = `/advertisement/${id}`; - return await httpDeleteInterceptor(pathUrl, headers); + return await httpDeleteInterceptor(pathUrl); } diff --git a/services/article.ts b/services/article.ts index 1e1cf99..6127724 100644 --- a/services/article.ts +++ b/services/article.ts @@ -24,6 +24,7 @@ export async function getListArticle(props: PaginationRequest) { isBanner, categoryIds, createdByIds, + timeStamp, } = props; const headers = { "content-type": "application/json", @@ -37,7 +38,7 @@ export async function getListArticle(props: PaginationRequest) { sort || "asc" }&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${ categoryIds || "" - }&createdByIds=${createdByIds || ""}`, + }&createdByIds=${createdByIds || ""}&timeStamp=${timeStamp || ""}`, headers ); } @@ -57,6 +58,7 @@ export async function getListArticleAdminPage(props: PaginationRequest) { isBanner, categoryIds, createdByIds, + timeStamp, } = props; return await httpGetInterceptor( `/articles?sort=desc&sortBy=created_at&limit=${limit}&page=${page}&isPublish=${ @@ -67,19 +69,29 @@ export async function getListArticleAdminPage(props: PaginationRequest) { sort || "asc" }&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${ categoryIds || "" - }&createdByIds=${createdByIds || ""}` + }&createdByIds=${createdByIds || ""}&timeStamp=${timeStamp || ""}` ); } export async function getTopArticles(props: PaginationRequest) { - const { page, limit, search, startDate, endDate, isPublish, category } = - props; + const { + page, + limit, + search, + startDate, + endDate, + isPublish, + category, + timeStamp, + } = props; return await httpGetInterceptor( `/articles?limit=${limit}&page=${page}&isPublish=${ isPublish === undefined ? "" : isPublish }&title=${search}&startDate=${startDate || ""}&endDate=${ endDate || "" - }&category=${category || ""}&sortBy=view_count&sort=desc` + }&category=${category || ""}&sortBy=view_count&sort=desc&timeStamp=${ + timeStamp || "" + }` ); } @@ -124,12 +136,14 @@ export async function deleteArticle(id: string) { return await httpDeleteInterceptor(`articles/${id}`); } -export async function getArticleByCategory() { +export async function getArticleByCategory(timeStamp: number) { const headers = { "content-type": "application/json", Authorization: `Bearer ${token}`, }; - return await httpGet(`/article-categories?limit=1000`, headers); + return await httpGetInterceptor( + `/article-categories?limit=1000&timeStamp=${timeStamp}` + ); } export async function getCategoryPagination(data: any) { const headers = { @@ -138,7 +152,7 @@ export async function getCategoryPagination(data: any) { }; return await httpGetInterceptor( - `/article-categories?limit=${data?.limit}&page=${data?.page}&title=${data?.search}` + `/article-categories?limit=${data?.limit}&page=${data?.page}&title=${data?.search}&timeStamp=${data.timeStamp}` ); } @@ -162,36 +176,49 @@ export async function deleteArticleFiles(id: number) { return await httpDeleteInterceptor(`article-files/${id}`); } -export async function getUserLevelDataStat(startDate: string, endDate: string) { +export async function getUserLevelDataStat( + startDate: string, + endDate: string, + timeStamp: number +) { + const headers = { + "content-type": "application/json", + Authorization: `Bearer ${token}`, + }; + return await httpGetInterceptor( + `/articles/statistic/user-levels?startDate=${startDate}&endDate=${endDate}&timeStamp=${timeStamp}` + ); +} +export async function getStatisticMonthly(year: string, timeStamp: number) { + const headers = { + "content-type": "application/json", + Authorization: `Bearer ${token}`, + }; + return await httpGetInterceptor( + `/articles/statistic/monthly?year=${year}&timeStamp=${timeStamp}` + ); +} +export async function getStatisticMonthlyFeedback( + year: string, + timeStamp: number +) { const headers = { "content-type": "application/json", Authorization: `Bearer ${token}`, }; return await httpGet( - `/articles/statistic/user-levels?startDate=${startDate}&endDate=${endDate}`, + `/feedbacks/statistic/monthly?year=${year}&timeStamp=${timeStamp}`, headers ); } -export async function getStatisticMonthly(year: string) { +export async function getStatisticSummary(timeStamp: number) { const headers = { "content-type": "application/json", Authorization: `Bearer ${token}`, }; - return await httpGet(`/articles/statistic/monthly?year=${year}`, headers); -} -export async function getStatisticMonthlyFeedback(year: string) { - const headers = { - "content-type": "application/json", - Authorization: `Bearer ${token}`, - }; - return await httpGet(`/feedbacks/statistic/monthly?year=${year}`, headers); -} -export async function getStatisticSummary() { - const headers = { - "content-type": "application/json", - Authorization: `Bearer ${token}`, - }; - return await httpGetInterceptor(`/articles/statistic/summary`); + return await httpGetInterceptor( + `/articles/statistic/summary?timeStamp=${timeStamp}` + ); } export async function submitApproval(data: { diff --git a/services/comment.ts b/services/comment.ts index 7ac40ff..42f1b3b 100644 --- a/services/comment.ts +++ b/services/comment.ts @@ -5,6 +5,7 @@ import { httpPut, } from "./http-config/axios-base-service"; import Cookies from "js-cookie"; +import { httpGetInterceptor } from "./http-config/http-interceptor-services"; const token = Cookies.get("access_token"); @@ -14,8 +15,10 @@ export async function getComments(data: any) { }; const pathUrl = `/article-comments?page=${data?.page || 1}&limit=${ data?.limit || "" - }&message=${data?.search || ""}&parentId=0`; - return await httpGet(pathUrl, headers); + }&message=${data?.search || ""}&parentId=0&timeStamp=${ + data?.timeStamp || "" + }`; + return await httpGetInterceptor(pathUrl); } export async function deleteComment(id: number) { diff --git a/services/feedbacks.ts b/services/feedbacks.ts index 96d8f65..221516c 100644 --- a/services/feedbacks.ts +++ b/services/feedbacks.ts @@ -5,6 +5,7 @@ import { httpPut, } from "./http-config/axios-base-service"; import Cookies from "js-cookie"; +import { httpGetInterceptor } from "./http-config/http-interceptor-services"; const token = Cookies.get("access_token"); @@ -24,8 +25,8 @@ export async function getFeedbacks(data: any) { data?.limit || "" }&message=${data?.search || ""}&startDate=${data.startDate || ""}&endDate=${ data.endDate || "" - }`; - return await httpGet(pathUrl, headers); + }&timeStamp=${data.timeStamp}`; + return await httpGetInterceptor(pathUrl); } export async function getFeedbacksById(id: number) { diff --git a/services/magazine.tsx b/services/magazine.tsx index 9c76d36..ef56ba5 100644 --- a/services/magazine.tsx +++ b/services/magazine.tsx @@ -1,11 +1,7 @@ import { PaginationRequest } from "@/types/globals"; -import { - httpDeleteInterceptor, - httpGet, - httpPost, - httpPut, -} from "./http-config/axios-base-service"; +import { httpGet, httpPost, httpPut } from "./http-config/axios-base-service"; import Cookies from "js-cookie"; +import { httpDeleteInterceptor } from "./http-config/http-interceptor-services"; const token = Cookies.get("access_token"); @@ -19,14 +15,14 @@ export async function createMagazine(data: any) { } export async function getListMagazine(props: PaginationRequest) { - const { page, limit, search, startDate, endDate } = props; + const { page, limit, search, startDate, endDate, timeStamp } = props; const headers = { "content-type": "application/json", }; return await httpGet( `/magazines?limit=${limit}&page=${page}&title=${search}&startDate=${ startDate || "" - }&endDate=${endDate || ""}`, + }&endDate=${endDate || ""}&timeStamp=${timeStamp || ""}`, headers ); } @@ -50,7 +46,7 @@ export async function deleteMagazine(id: string) { const headers = { "content-type": "application/json", }; - return await httpDeleteInterceptor(`magazines/${id}`, headers); + return await httpDeleteInterceptor(`magazines/${id}`); } export async function uploadMagazineFile(id: string, data: any) { @@ -71,5 +67,5 @@ export async function deleteMagazineFiles(id: number) { const headers = { "content-type": "multipart/form-data", }; - return await httpDeleteInterceptor(`magazine-files/${id}`, headers); + return await httpDeleteInterceptor(`magazine-files/${id}`); } diff --git a/services/master-user-role.ts b/services/master-user-role.ts index eda2837..cdda492 100644 --- a/services/master-user-role.ts +++ b/services/master-user-role.ts @@ -5,6 +5,7 @@ import { } from "./http-config/axios-base-service"; import Cookies from "js-cookie"; +import { httpGetInterceptor } from "./http-config/http-interceptor-services"; const token = Cookies.get("access_token"); @@ -12,9 +13,10 @@ export async function listUserRole(data: any) { const headers = { "content-type": "application/json", }; - return await httpGet( - `/user-roles?limit=${data.limit}&page=${data.page}`, - headers + return await httpGetInterceptor( + `/user-roles?limit=${data.limit}&page=${data.page}&timeStamp=${ + data.timeStamp || "" + }` ); } diff --git a/services/master-user.ts b/services/master-user.ts index 5825bbb..c865dd5 100644 --- a/services/master-user.ts +++ b/services/master-user.ts @@ -18,7 +18,9 @@ export async function listMasterUsers(data: any) { return await httpGet( `/users?page=${data.page}&limit=${data.limit}&username=${ data.username || "" - }&fullname=${data.fullname || ""}&email=${data.email || ""}`, + }&fullname=${data.fullname || ""}&email=${data.email || ""}&timeStamp=${ + data.timeStamp || "" + }`, headers ); } diff --git a/services/static-page-service.ts b/services/static-page-service.ts index ad2a87d..08ece2e 100644 --- a/services/static-page-service.ts +++ b/services/static-page-service.ts @@ -5,6 +5,7 @@ import { httpPost, httpPut, } from "./http-config/axios-base-service"; +import { httpGetInterceptor } from "./http-config/http-interceptor-services"; export async function createCustomStaticPage(data: any) { const headers = { @@ -23,13 +24,12 @@ export async function editCustomStaticPage(data: any) { } export async function getCustomStaticPage(props: PaginationRequest) { - const { page, limit, search } = props; + const { page, limit, search, timeStamp } = props; const headers = { "content-type": "application/json", }; - return await httpGet( - `/custom-static-pages?limit=${limit}&page=${page}&title=${search}`, - headers + return await httpGetInterceptor( + `/custom-static-pages?limit=${limit}&page=${page}&title=${search}&timeStamp=${timeStamp}` ); } export async function getCustomStaticDetail(id: string) { diff --git a/services/user-levels/user-levels-service.ts b/services/user-levels/user-levels-service.ts index e9b1fc6..9a1c44c 100644 --- a/services/user-levels/user-levels-service.ts +++ b/services/user-levels/user-levels-service.ts @@ -6,6 +6,7 @@ import { } from "@/services/http-config/axios-base-service"; import Cookies from "js-cookie"; +import { httpGetInterceptor } from "../http-config/http-interceptor-services"; const token = Cookies.get("access_token"); @@ -13,11 +14,12 @@ export async function getAllUserLevels(data?: any) { const headers = { "content-type": "application/json", }; - return await httpGet( + return await httpGetInterceptor( `user-levels?limit=${data?.limit || ""}&levelNumber=${ data?.levelNumber || "" - }&name=${data?.search || ""}&page=${data?.page || "1"}`, - headers + }&name=${data?.search || ""}&page=${data?.page || "1"}&timeStamp=${ + data.timeStamp || "" + }` ); } export async function getUserLevels(id: string) { diff --git a/types/globals.tsx b/types/globals.tsx index c7e8eb4..2a315df 100644 --- a/types/globals.tsx +++ b/types/globals.tsx @@ -69,4 +69,5 @@ export type PaginationRequest = { isBanner?: boolean; categoryIds?: string; createdByIds?: string; + timeStamp?: number; };