fix:time stamp

This commit is contained in:
Rama Priyanto 2025-05-28 13:56:41 +07:00
parent 2c94754de2
commit bd40ceab56
31 changed files with 196 additions and 139 deletions

View File

@ -34,6 +34,7 @@ import {
import Swal from "sweetalert2"; import Swal from "sweetalert2";
import withReactContent from "sweetalert2-react-content"; import withReactContent from "sweetalert2-react-content";
import Image from "next/image"; import Image from "next/image";
import { getUnixTimestamp } from "@/utils/global";
const categorySchema = z.object({ const categorySchema = z.object({
id: z.number(), id: z.number(),
@ -104,7 +105,7 @@ export default function MasterCategoryTable() {
}, []); }, []);
const fetchCategory = async () => { const fetchCategory = async () => {
const res = await getArticleByCategory(); const res = await getArticleByCategory(getUnixTimestamp());
if (res?.data?.data) { if (res?.data?.data) {
setupCategory(res?.data?.data); setupCategory(res?.data?.data);
} }

View File

@ -47,7 +47,11 @@ import {
useDisclosure, useDisclosure,
} from "@heroui/react"; } from "@heroui/react";
import GenerateSingleArticleForm from "./generate-ai-single-form"; 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 { close, error, loading, successToast } from "@/config/swal";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import Link from "next/link"; import Link from "next/link";
@ -104,9 +108,9 @@ const createArticleSchema = z.object({
description: z.string().min(2, { description: z.string().min(2, {
message: "Deskripsi harus diisi", message: "Deskripsi harus diisi",
}), }),
// category: z.array(categorySchema).nonempty({ category: z.array(categorySchema).nonempty({
// message: "Kategori harus memiliki setidaknya satu item", message: "Kategori harus memiliki setidaknya satu item",
// }), }),
tags: z.array(z.string()).nonempty({ tags: z.array(z.string()).nonempty({
message: "Minimal 1 tag", message: "Minimal 1 tag",
}), }),
@ -174,7 +178,7 @@ export default function CreateArticleForm() {
}, []); }, []);
const fetchCategory = async () => { const fetchCategory = async () => {
const res = await getArticleByCategory(); const res = await getArticleByCategory(getUnixTimestamp());
if (res?.data?.data) { if (res?.data?.data) {
setupCategory(res?.data?.data); setupCategory(res?.data?.data);
} }
@ -701,7 +705,7 @@ export default function CreateArticleForm() {
</> </>
)} )}
{/* <p className="text-sm mt-3">Kategori</p> <p className="text-sm mt-3">Kategori</p>
<Controller <Controller
control={control} control={control}
name="category" name="category"
@ -729,7 +733,7 @@ export default function CreateArticleForm() {
<p className="text-red-400 text-sm mb-3"> <p className="text-red-400 text-sm mb-3">
{errors.category?.message} {errors.category?.message}
</p> </p>
)} */} )}
<p className="text-sm">Tags</p> <p className="text-sm">Tags</p>
<Controller <Controller

View File

@ -39,7 +39,11 @@ import {
useDisclosure, useDisclosure,
} from "@heroui/react"; } from "@heroui/react";
import GenerateSingleArticleForm from "./generate-ai-single-form"; import GenerateSingleArticleForm from "./generate-ai-single-form";
import { convertDateFormatNoTime, htmlToString } from "@/utils/global"; import {
convertDateFormatNoTime,
getUnixTimestamp,
htmlToString,
} from "@/utils/global";
import { close, error, loading } from "@/config/swal"; import { close, error, loading } from "@/config/swal";
import { useParams, useRouter } from "next/navigation"; import { useParams, useRouter } from "next/navigation";
import { fromJSON, list } from "postcss"; import { fromJSON, list } from "postcss";
@ -202,7 +206,7 @@ export default function EditArticleForm(props: { isDetail: boolean }) {
}, []); }, []);
const fetchCategory = async () => { const fetchCategory = async () => {
const res = await getArticleByCategory(); const res = await getArticleByCategory(getUnixTimestamp());
if (res?.data?.data) { if (res?.data?.data) {
setupCategory(res?.data?.data); setupCategory(res?.data?.data);
} }

View File

@ -31,6 +31,7 @@ import ReactSelect from "react-select";
import makeAnimated from "react-select/animated"; import makeAnimated from "react-select/animated";
import { getAllUserLevels } from "@/services/user-levels/user-levels-service"; import { getAllUserLevels } from "@/services/user-levels/user-levels-service";
import { listUserRole } from "@/services/master-user-role"; import { listUserRole } from "@/services/master-user-role";
import { getUnixTimestamp } from "@/utils/global";
const userSchema = z.object({ const userSchema = z.object({
id: z.number(), id: z.number(),
@ -153,7 +154,7 @@ export default function FormMasterUserEdit() {
}; };
const fetchUserLevel = async () => { const fetchUserLevel = async () => {
const res = await getAllUserLevels(); const res = await getAllUserLevels({ timeStamp: getUnixTimestamp() });
if (res?.data?.data) { if (res?.data?.data) {
return setupParent(res?.data?.data, "level"); return setupParent(res?.data?.data, "level");
} }
@ -162,6 +163,7 @@ export default function FormMasterUserEdit() {
const request = { const request = {
limit: 100, limit: 100,
page: 1, page: 1,
timeStamp: getUnixTimestamp(),
}; };
const res = await listUserRole(request); const res = await listUserRole(request);
if (res?.data?.data) { if (res?.data?.data) {

View File

@ -231,7 +231,7 @@ export default function FormMasterUserRole() {
<p>Menus</p> <p>Menus</p>
{fields.map((field, index) => ( {fields.map((field, index) => (
<div key={field.menuId} className="flex flex-row gap-10"> <div key={field.menuId} className="flex flex-row gap-10">
<p>{field.menuTitle}</p> {/* <p>{field.menuTitle}</p> */}
<div className="grid grid-cols-6 gap-3"> <div className="grid grid-cols-6 gap-3">
{/* <Checkbox>Option</Checkbox> */} {/* <Checkbox>Option</Checkbox> */}
<Controller <Controller

View File

@ -24,6 +24,7 @@ import withReactContent from "sweetalert2-react-content";
import { saveActivity } from "@/services/activity-log"; import { saveActivity } from "@/services/activity-log";
import PasswordChecklist from "react-password-checklist"; import PasswordChecklist from "react-password-checklist";
import { Image, InputOtp } from "@heroui/react"; import { Image, InputOtp } from "@heroui/react";
import { getUnixTimestamp } from "@/utils/global";
export default function Login() { export default function Login() {
const accessToken = Cookies.get("access_token"); const accessToken = Cookies.get("access_token");
@ -148,7 +149,7 @@ export default function Login() {
// Cookies.set("email", profile?.data?.data?.email, { // Cookies.set("email", profile?.data?.data?.email, {
// expires: 1, // expires: 1,
// }); // });
// router.push("/admin/dashboard"); // router.push(`/admin/dashboard?timestamp=${getUnixTimestamp()}`);
// Cookies.set("status", "login", { // Cookies.set("status", "login", {
// expires: 1, // expires: 1,
// }); // });
@ -266,7 +267,7 @@ export default function Login() {
Cookies.set("email", profile?.email, { Cookies.set("email", profile?.email, {
expires: 1, expires: 1,
}); });
router.push("/admin/dashboard"); router.push(`/admin/dashboard?timestamp=${getUnixTimestamp()}`);
Cookies.set("status", "login", { Cookies.set("status", "login", {
expires: 1, expires: 1,
}); });

View File

@ -85,7 +85,7 @@ export default function HeaderNews() {
<Swiper <Swiper
centeredSlides={true} centeredSlides={true}
autoplay={{ autoplay={{
delay: 5000, delay: 7000,
disableOnInteraction: false, disableOnInteraction: false,
}} }}
navigation={true} navigation={true}
@ -217,7 +217,7 @@ export default function HeaderNews() {
<Swiper <Swiper
centeredSlides={true} centeredSlides={true}
autoplay={{ autoplay={{
delay: 5000, delay: 7000,
disableOnInteraction: false, disableOnInteraction: false,
}} }}
navigation={true} navigation={true}

View File

@ -42,6 +42,15 @@ export default function FooterNew(props: { margin?: boolean }) {
success("Sukses"); success("Sukses");
}; };
const [hasMounted, setHasMounted] = useState(false);
useEffect(() => {
setHasMounted(true);
}, []);
// Render
if (!hasMounted) return null;
return ( return (
<div <div
className={`${ className={`${

View File

@ -3,6 +3,7 @@ import React, { Component, useEffect, useState } from "react";
import ReactApexChart from "react-apexcharts"; import ReactApexChart from "react-apexcharts";
import dummyData from "../../../../const/dummy.json"; import dummyData from "../../../../const/dummy.json";
import { getStatisticMonthly } from "@/services/article"; import { getStatisticMonthly } from "@/services/article";
import { getUnixTimestamp } from "@/utils/global";
type WeekData = { type WeekData = {
week: number; week: number;
@ -62,7 +63,7 @@ const ApexChartColumn = (props: {
const initFetch = async () => { const initFetch = async () => {
const splitDate = date.split(" "); const splitDate = date.split(" ");
const res = await getStatisticMonthly(splitDate[1]); const res = await getStatisticMonthly(splitDate[1], getUnixTimestamp());
const data = res?.data?.data; const data = res?.data?.data;
const getDatas = data?.find( const getDatas = data?.find(
(a: any) => (a: any) =>
@ -122,8 +123,6 @@ const ApexChartColumn = (props: {
}, },
]; ];
console.log("temp", temp);
setSeries(temp); setSeries(temp);
}, [view, seriesShare, seriesView, seriesComment]); }, [view, seriesShare, seriesView, seriesComment]);

View File

@ -6,6 +6,7 @@ import {
getStatisticMonthly, getStatisticMonthly,
getStatisticMonthlyFeedback, getStatisticMonthlyFeedback,
} from "@/services/article"; } from "@/services/article";
import { getUnixTimestamp } from "@/utils/global";
type WeekData = { type WeekData = {
week: number; week: number;
@ -91,7 +92,10 @@ const SuggestionsChart = (props: {
const initFetch = async () => { const initFetch = async () => {
const splitDate = date.split(" "); const splitDate = date.split(" ");
const res = await getStatisticMonthlyFeedback(splitDate[1]); const res = await getStatisticMonthlyFeedback(
splitDate[1],
getUnixTimestamp()
);
const data = res?.data?.data; const data = res?.data?.data;
// const data = dummyData.data; // const data = dummyData.data;
if (type === "monthly") { if (type === "monthly") {

View File

@ -40,6 +40,7 @@ import {
convertDateFormat, convertDateFormat,
convertDateFormatNoTime, convertDateFormatNoTime,
convertDateFormatNoTimeV2, convertDateFormatNoTimeV2,
getUnixTimestamp,
textEllipsis, textEllipsis,
} from "@/utils/global"; } from "@/utils/global";
import { parseDate, getLocalTimeZone } from "@internationalized/date"; import { parseDate, getLocalTimeZone } from "@internationalized/date";
@ -109,6 +110,7 @@ export default function DashboardContainer() {
page: page, page: page,
search: "", search: "",
sort: "desc", sort: "desc",
timeStamp: getUnixTimestamp(),
}; };
const res = await getListArticleAdminPage(req); const res = await getListArticleAdminPage(req);
setArticle(res.data?.data); setArticle(res.data?.data);
@ -116,7 +118,7 @@ export default function DashboardContainer() {
} }
async function fetchSummary() { async function fetchSummary() {
const res = await getStatisticSummary(); const res = await getStatisticSummary(getUnixTimestamp());
setSummary(res?.data?.data); setSummary(res?.data?.data);
} }
@ -131,6 +133,7 @@ export default function DashboardContainer() {
search: "", search: "",
sort: "desc", sort: "desc",
isPublish: true, isPublish: true,
timeStamp: getUnixTimestamp(),
}; };
const res = await getTopArticles(req); const res = await getTopArticles(req);
setTopPages(getTableNumber(10, res.data?.data)); setTopPages(getTableNumber(10, res.data?.data));
@ -148,7 +151,8 @@ export default function DashboardContainer() {
}; };
const res = await getUserLevelDataStat( const res = await getUserLevelDataStat(
getDate(postContentDate.startDate), getDate(postContentDate.startDate),
getDate(postContentDate.endDate) getDate(postContentDate.endDate),
getUnixTimestamp()
); );
setPostCount(getTableNumber(10, res?.data?.data)); setPostCount(getTableNumber(10, res?.data?.data));
} }

View File

@ -16,7 +16,7 @@ import {
getListArticle, getListArticle,
} from "@/services/article"; } from "@/services/article";
import { Article } from "@/types/globals"; import { Article } from "@/types/globals";
import { convertDateFormat } from "@/utils/global"; import { convertDateFormat, getUnixTimestamp } from "@/utils/global";
import { Button } from "@heroui/button"; import { Button } from "@heroui/button";
import { import {
Chip, Chip,
@ -64,6 +64,7 @@ import {
editAdvertise, editAdvertise,
editAdvertiseIsActive, editAdvertiseIsActive,
getAdvertise, getAdvertise,
getAdvertiseAdmin,
} from "@/services/advertisement"; } from "@/services/advertisement";
const columns = [ const columns = [
@ -150,8 +151,9 @@ export default function AdvertiseTable(props: { triggerRefresh: boolean }) {
sort: "desc", sort: "desc",
sortBy: "created_at", sortBy: "created_at",
timeStamp: getUnixTimestamp(),
}; };
const res = await getAdvertise(req); const res = await getAdvertiseAdmin(req);
getTableNumber(parseInt(showData), res.data?.data); getTableNumber(parseInt(showData), res.data?.data);
setTotalPage(res?.data?.meta?.totalPage); setTotalPage(res?.data?.meta?.totalPage);
} }

View File

@ -21,6 +21,7 @@ import {
convertDateFormat, convertDateFormat,
convertDateFormatNoTime, convertDateFormatNoTime,
convertDateFormatNoTimeV2, convertDateFormatNoTimeV2,
getUnixTimestamp,
} from "@/utils/global"; } from "@/utils/global";
import { Button } from "@heroui/button"; import { Button } from "@heroui/button";
import { import {
@ -159,7 +160,11 @@ export default function ArticleTable() {
}; };
async function getUsers() { 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"); setupList(res?.data?.data, "users");
} }
@ -209,6 +214,7 @@ export default function ArticleTable() {
createdByIds: getIds(selectedUsers), createdByIds: getIds(selectedUsers),
sort: "desc", sort: "desc",
sortBy: "created_at", sortBy: "created_at",
timeStamp: getUnixTimestamp(),
}; };
const res = await getListArticleAdminPage(req); const res = await getListArticleAdminPage(req);
await getTableNumber(parseInt(showData), res.data?.data); await getTableNumber(parseInt(showData), res.data?.data);

View File

@ -17,7 +17,7 @@ import {
getListArticle, getListArticle,
} from "@/services/article"; } from "@/services/article";
import { Article } from "@/types/globals"; import { Article } from "@/types/globals";
import { convertDateFormat } from "@/utils/global"; import { convertDateFormat, getUnixTimestamp } from "@/utils/global";
import { Button } from "@heroui/button"; import { Button } from "@heroui/button";
import { import {
Chip, Chip,
@ -55,7 +55,6 @@ import { Controller, useForm } from "react-hook-form";
import Swal from "sweetalert2"; import Swal from "sweetalert2";
import withReactContent from "sweetalert2-react-content"; import withReactContent from "sweetalert2-react-content";
import { useDropzone } from "react-dropzone"; import { useDropzone } from "react-dropzone";
import Image from "next/image";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { getComments } from "@/services/comment"; import { getComments } from "@/services/comment";
@ -92,6 +91,7 @@ export default function CommentTable() {
limit: showData, limit: showData,
page: page, page: page,
search: search, search: search,
timeStamp: getUnixTimestamp(),
}; };
const res = await getComments(req); const res = await getComments(req);
getTableNumber(parseInt(showData), res.data?.data); getTableNumber(parseInt(showData), res.data?.data);

View File

@ -14,7 +14,7 @@ import {
} from "@/services/article"; } from "@/services/article";
import { deleteMagazine, getListMagazine } from "@/services/magazine"; import { deleteMagazine, getListMagazine } from "@/services/magazine";
import { Article } from "@/types/globals"; import { Article } from "@/types/globals";
import { convertDateFormat } from "@/utils/global"; import { convertDateFormat, getUnixTimestamp } from "@/utils/global";
import { Button } from "@heroui/button"; import { Button } from "@heroui/button";
import { import {
Chip, Chip,
@ -35,6 +35,7 @@ import {
TableHeader, TableHeader,
TableRow, TableRow,
} from "@heroui/react"; } from "@heroui/react";
import { timeStamp } from "console";
import Link from "next/link"; import Link from "next/link";
import { Key, useCallback, useEffect, useState } from "react"; import { Key, useCallback, useEffect, useState } from "react";
import Datepicker from "react-tailwindcss-datepicker"; import Datepicker from "react-tailwindcss-datepicker";
@ -79,9 +80,8 @@ export default function MagazineTable() {
}, []); }, []);
async function getCategories() { async function getCategories() {
const res = await getArticleByCategory(); const res = await getArticleByCategory(getUnixTimestamp());
const data = res?.data?.data; const data = res?.data?.data;
console.log("datass", res?.data?.data);
setCategoies(data); setCategoies(data);
} }
@ -93,10 +93,10 @@ export default function MagazineTable() {
startDate: startDate:
startDateValue.startDate === null ? "" : startDateValue.startDate, startDateValue.startDate === null ? "" : startDateValue.startDate,
endDate: startDateValue.endDate === null ? "" : startDateValue.endDate, endDate: startDateValue.endDate === null ? "" : startDateValue.endDate,
timeStamp: getUnixTimestamp(),
}; };
const res = await getListMagazine(req); const res = await getListMagazine(req);
getTableNumber(parseInt(showData), res.data?.data); getTableNumber(parseInt(showData), res.data?.data);
console.log("res.data?.data magz", res.data);
setTotalPage(res?.data?.meta?.totalPage); setTotalPage(res?.data?.meta?.totalPage);
} }
@ -109,7 +109,6 @@ export default function MagazineTable() {
value.no = startIndex + iterate; value.no = startIndex + iterate;
return value; return value;
}); });
console.log("daata", data);
setArticle(newData); setArticle(newData);
} else { } else {
setArticle([]); setArticle([]);

View File

@ -21,7 +21,7 @@ import {
uploadCategoryThumbnail, uploadCategoryThumbnail,
} from "@/services/master-categories"; } from "@/services/master-categories";
import { Article } from "@/types/globals"; import { Article } from "@/types/globals";
import { convertDateFormat } from "@/utils/global"; import { convertDateFormat, getUnixTimestamp } from "@/utils/global";
import { Button } from "@heroui/button"; import { Button } from "@heroui/button";
import { import {
Chip, Chip,
@ -156,6 +156,7 @@ export default function CategoriesTable(props: { triggerRefresh: boolean }) {
limit: showData, limit: showData,
page: page, page: page,
search: search, search: search,
timeStamp: getUnixTimestamp(),
}; };
const res = await getCategoryPagination(req); const res = await getCategoryPagination(req);
getTableNumber(parseInt(showData), res.data?.data); getTableNumber(parseInt(showData), res.data?.data);
@ -210,7 +211,7 @@ export default function CategoriesTable(props: { triggerRefresh: boolean }) {
}, []); }, []);
const fetchCategory = async () => { const fetchCategory = async () => {
const res = await getArticleByCategory(); const res = await getArticleByCategory(getUnixTimestamp());
if (res?.data?.data) { if (res?.data?.data) {
setupCategory(res?.data?.data); setupCategory(res?.data?.data);
} }

View File

@ -12,6 +12,7 @@ import {
listUserRole, listUserRole,
} from "@/services/master-user-role"; } from "@/services/master-user-role";
import { MasterUser, MasterUserRole } from "@/types/globals"; import { MasterUser, MasterUserRole } from "@/types/globals";
import { getUnixTimestamp } from "@/utils/global";
import { Button } from "@heroui/button"; import { Button } from "@heroui/button";
import { import {
Chip, Chip,
@ -59,7 +60,11 @@ export default function MasterRoleTable() {
}, [page]); }, [page]);
async function initState() { 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); getTableNumber(10, res?.data?.data);
setTotalPage(res?.data?.meta?.totalPage); setTotalPage(res?.data?.meta?.totalPage);
} }
@ -132,49 +137,6 @@ export default function MasterRoleTable() {
// { name: "Vacation", uid: "vacation" }, // { 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 renderCell = useCallback((role: MasterUserRole, columnKey: Key) => {
const cellValue = role[columnKey as keyof MasterUserRole]; const cellValue = role[columnKey as keyof MasterUserRole];
const statusColorMap: Record<string, ChipProps["color"]> = { const statusColorMap: Record<string, ChipProps["color"]> = {

View File

@ -10,6 +10,7 @@ import { error, success } from "@/config/swal";
import { deleteArticle, getListArticle } from "@/services/article"; import { deleteArticle, getListArticle } from "@/services/article";
import { deleteMasterUser, listMasterUsers } from "@/services/master-user"; import { deleteMasterUser, listMasterUsers } from "@/services/master-user";
import { Article, MasterUser } from "@/types/globals"; import { Article, MasterUser } from "@/types/globals";
import { getUnixTimestamp } from "@/utils/global";
import { Button } from "@heroui/button"; import { Button } from "@heroui/button";
import { Input } from "@heroui/input"; import { Input } from "@heroui/input";
import { import {
@ -67,6 +68,7 @@ export default function MasterUserTable() {
fullname: searchType === "fullname" ? search : "", fullname: searchType === "fullname" ? search : "",
username: searchType === "username" ? search : "", username: searchType === "username" ? search : "",
email: searchType === "email" ? search : "", email: searchType === "email" ? search : "",
timeStamp: getUnixTimestamp(),
}); });
getTableNumber(10, res?.data?.data); getTableNumber(10, res?.data?.data);
setTotalPage(res?.data?.meta?.totalPage); setTotalPage(res?.data?.meta?.totalPage);

View File

@ -38,6 +38,7 @@ import {
} from "@/services/user-levels/user-levels-service"; } from "@/services/user-levels/user-levels-service";
import { close, error, loading } from "@/config/swal"; import { close, error, loading } from "@/config/swal";
import { stringify } from "querystring"; import { stringify } from "querystring";
import { getUnixTimestamp } from "@/utils/global";
type UserObject = { type UserObject = {
id: number; id: number;
@ -99,6 +100,7 @@ export default function MasterUserLevelTable() {
page: page, page: page,
limit: 10, limit: 10,
search: search, search: search,
timeStamp: getUnixTimestamp(),
}; };
const res = await getAllUserLevels(request); const res = await getAllUserLevels(request);
const data = res?.data?.data; const data = res?.data?.data;
@ -112,6 +114,7 @@ export default function MasterUserLevelTable() {
page: 1, page: 1,
limit: -1, limit: -1,
search: "", search: "",
timeStamp: getUnixTimestamp(),
}; };
const res = await getAllUserLevels(request); const res = await getAllUserLevels(request);
const data = res?.data?.data; const data = res?.data?.data;

View File

@ -10,7 +10,7 @@ import { error, success } from "@/config/swal";
import { deleteArticle, getListArticle } from "@/services/article"; import { deleteArticle, getListArticle } from "@/services/article";
import { getCustomStaticPage } from "@/services/static-page-service"; import { getCustomStaticPage } from "@/services/static-page-service";
import { Article } from "@/types/globals"; import { Article } from "@/types/globals";
import { convertDateFormat } from "@/utils/global"; import { convertDateFormat, getUnixTimestamp } from "@/utils/global";
import { Button } from "@heroui/button"; import { Button } from "@heroui/button";
import { import {
Chip, Chip,
@ -71,10 +71,10 @@ export default function StaticPageTable() {
limit: showData, limit: showData,
page: page, page: page,
search: search, search: search,
timeStamp: getUnixTimestamp(),
}; };
const res = await getCustomStaticPage(req); const res = await getCustomStaticPage(req);
getTableNumber(parseInt(showData), res.data?.data); getTableNumber(parseInt(showData), res.data?.data);
console.log("res.data?.data", res.data);
setTotalPage(res?.data?.meta?.totalPage); setTotalPage(res?.data?.meta?.totalPage);
} }

View File

@ -21,6 +21,7 @@ import {
convertDateFormat, convertDateFormat,
convertDateFormatNoTime, convertDateFormatNoTime,
convertDateFormatNoTimeV2, convertDateFormatNoTimeV2,
getUnixTimestamp,
} from "@/utils/global"; } from "@/utils/global";
import { Button } from "@heroui/button"; import { Button } from "@heroui/button";
import { import {
@ -82,6 +83,7 @@ import {
TextRun, TextRun,
WidthType, WidthType,
} from "docx"; } from "docx";
import { timeStamp } from "console";
interface ExportData { interface ExportData {
no: string; no: string;
@ -166,6 +168,7 @@ export default function SuggestionsTable() {
search: search, search: search,
startDate: getDate(feedbackDate.startDate), startDate: getDate(feedbackDate.startDate),
endDate: getDate(feedbackDate.endDate), endDate: getDate(feedbackDate.endDate),
timeStamp: getUnixTimestamp(),
}); });
getTableNumber(parseInt(showData), res.data?.data); getTableNumber(parseInt(showData), res.data?.data);
setTotalPage(res?.data?.meta?.totalPage); setTotalPage(res?.data?.meta?.totalPage);
@ -357,7 +360,11 @@ export default function SuggestionsTable() {
const [typeDate, setTypeDate] = useState("monthly"); const [typeDate, setTypeDate] = useState("monthly");
const doExport = async () => { 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) { if (res?.data?.data) {
exportRecap(res?.data?.data); exportRecap(res?.data?.data);
} }

View File

@ -1,10 +1,9 @@
import { httpGet, httpPost, httpPut } from "./http-config/axios-base-service";
import Cookies from "js-cookie";
import { import {
httpDeleteInterceptor, httpDeleteInterceptor,
httpGet, httpGetInterceptor,
httpPost, } from "./http-config/http-interceptor-services";
httpPut,
} from "./http-config/axios-base-service";
import Cookies from "js-cookie";
const token = Cookies.get("access_token"); const token = Cookies.get("access_token");
@ -30,10 +29,24 @@ export async function getAdvertise(data: any) {
}; };
const pathUrl = `/advertisement?page=${data?.page || 1}&limit=${ const pathUrl = `/advertisement?page=${data?.page || 1}&limit=${
data?.limit || "" data?.limit || ""
}&placement=${data?.placement || ""}&isPublish=${data.isPublish || ""}`; }&placement=${data?.placement || ""}&isPublish=${
data.isPublish || ""
}&timeStamp=${data.timeStamp || ""}`;
return await httpGet(pathUrl, headers); 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) { export async function createAdvertiseById(id: number) {
const headers = { const headers = {
"content-type": "application/json", "content-type": "application/json",
@ -64,5 +77,5 @@ export async function deleteAdvertise(id: number) {
"content-type": "application/json", "content-type": "application/json",
}; };
const pathUrl = `/advertisement/${id}`; const pathUrl = `/advertisement/${id}`;
return await httpDeleteInterceptor(pathUrl, headers); return await httpDeleteInterceptor(pathUrl);
} }

View File

@ -24,6 +24,7 @@ export async function getListArticle(props: PaginationRequest) {
isBanner, isBanner,
categoryIds, categoryIds,
createdByIds, createdByIds,
timeStamp,
} = props; } = props;
const headers = { const headers = {
"content-type": "application/json", "content-type": "application/json",
@ -37,7 +38,7 @@ export async function getListArticle(props: PaginationRequest) {
sort || "asc" sort || "asc"
}&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${ }&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${
categoryIds || "" categoryIds || ""
}&createdByIds=${createdByIds || ""}`, }&createdByIds=${createdByIds || ""}&timeStamp=${timeStamp || ""}`,
headers headers
); );
} }
@ -57,6 +58,7 @@ export async function getListArticleAdminPage(props: PaginationRequest) {
isBanner, isBanner,
categoryIds, categoryIds,
createdByIds, createdByIds,
timeStamp,
} = props; } = props;
return await httpGetInterceptor( return await httpGetInterceptor(
`/articles?sort=desc&sortBy=created_at&limit=${limit}&page=${page}&isPublish=${ `/articles?sort=desc&sortBy=created_at&limit=${limit}&page=${page}&isPublish=${
@ -67,19 +69,29 @@ export async function getListArticleAdminPage(props: PaginationRequest) {
sort || "asc" sort || "asc"
}&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${ }&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${
categoryIds || "" categoryIds || ""
}&createdByIds=${createdByIds || ""}` }&createdByIds=${createdByIds || ""}&timeStamp=${timeStamp || ""}`
); );
} }
export async function getTopArticles(props: PaginationRequest) { export async function getTopArticles(props: PaginationRequest) {
const { page, limit, search, startDate, endDate, isPublish, category } = const {
props; page,
limit,
search,
startDate,
endDate,
isPublish,
category,
timeStamp,
} = props;
return await httpGetInterceptor( return await httpGetInterceptor(
`/articles?limit=${limit}&page=${page}&isPublish=${ `/articles?limit=${limit}&page=${page}&isPublish=${
isPublish === undefined ? "" : isPublish isPublish === undefined ? "" : isPublish
}&title=${search}&startDate=${startDate || ""}&endDate=${ }&title=${search}&startDate=${startDate || ""}&endDate=${
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}`); return await httpDeleteInterceptor(`articles/${id}`);
} }
export async function getArticleByCategory() { export async function getArticleByCategory(timeStamp: number) {
const headers = { const headers = {
"content-type": "application/json", "content-type": "application/json",
Authorization: `Bearer ${token}`, 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) { export async function getCategoryPagination(data: any) {
const headers = { const headers = {
@ -138,7 +152,7 @@ export async function getCategoryPagination(data: any) {
}; };
return await httpGetInterceptor( 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}`); 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 = { const headers = {
"content-type": "application/json", "content-type": "application/json",
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
}; };
return await httpGet( return await httpGet(
`/articles/statistic/user-levels?startDate=${startDate}&endDate=${endDate}`, `/feedbacks/statistic/monthly?year=${year}&timeStamp=${timeStamp}`,
headers headers
); );
} }
export async function getStatisticMonthly(year: string) { export async function getStatisticSummary(timeStamp: number) {
const headers = { const headers = {
"content-type": "application/json", "content-type": "application/json",
Authorization: `Bearer ${token}`, Authorization: `Bearer ${token}`,
}; };
return await httpGet(`/articles/statistic/monthly?year=${year}`, headers); return await httpGetInterceptor(
} `/articles/statistic/summary?timeStamp=${timeStamp}`
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`);
} }
export async function submitApproval(data: { export async function submitApproval(data: {

View File

@ -5,6 +5,7 @@ import {
httpPut, httpPut,
} from "./http-config/axios-base-service"; } from "./http-config/axios-base-service";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { httpGetInterceptor } from "./http-config/http-interceptor-services";
const token = Cookies.get("access_token"); 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=${ const pathUrl = `/article-comments?page=${data?.page || 1}&limit=${
data?.limit || "" data?.limit || ""
}&message=${data?.search || ""}&parentId=0`; }&message=${data?.search || ""}&parentId=0&timeStamp=${
return await httpGet(pathUrl, headers); data?.timeStamp || ""
}`;
return await httpGetInterceptor(pathUrl);
} }
export async function deleteComment(id: number) { export async function deleteComment(id: number) {

View File

@ -5,6 +5,7 @@ import {
httpPut, httpPut,
} from "./http-config/axios-base-service"; } from "./http-config/axios-base-service";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { httpGetInterceptor } from "./http-config/http-interceptor-services";
const token = Cookies.get("access_token"); const token = Cookies.get("access_token");
@ -24,8 +25,8 @@ export async function getFeedbacks(data: any) {
data?.limit || "" data?.limit || ""
}&message=${data?.search || ""}&startDate=${data.startDate || ""}&endDate=${ }&message=${data?.search || ""}&startDate=${data.startDate || ""}&endDate=${
data.endDate || "" data.endDate || ""
}`; }&timeStamp=${data.timeStamp}`;
return await httpGet(pathUrl, headers); return await httpGetInterceptor(pathUrl);
} }
export async function getFeedbacksById(id: number) { export async function getFeedbacksById(id: number) {

View File

@ -1,11 +1,7 @@
import { PaginationRequest } from "@/types/globals"; import { PaginationRequest } from "@/types/globals";
import { import { httpGet, httpPost, httpPut } from "./http-config/axios-base-service";
httpDeleteInterceptor,
httpGet,
httpPost,
httpPut,
} from "./http-config/axios-base-service";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { httpDeleteInterceptor } from "./http-config/http-interceptor-services";
const token = Cookies.get("access_token"); const token = Cookies.get("access_token");
@ -19,14 +15,14 @@ export async function createMagazine(data: any) {
} }
export async function getListMagazine(props: PaginationRequest) { export async function getListMagazine(props: PaginationRequest) {
const { page, limit, search, startDate, endDate } = props; const { page, limit, search, startDate, endDate, timeStamp } = props;
const headers = { const headers = {
"content-type": "application/json", "content-type": "application/json",
}; };
return await httpGet( return await httpGet(
`/magazines?limit=${limit}&page=${page}&title=${search}&startDate=${ `/magazines?limit=${limit}&page=${page}&title=${search}&startDate=${
startDate || "" startDate || ""
}&endDate=${endDate || ""}`, }&endDate=${endDate || ""}&timeStamp=${timeStamp || ""}`,
headers headers
); );
} }
@ -50,7 +46,7 @@ export async function deleteMagazine(id: string) {
const headers = { const headers = {
"content-type": "application/json", "content-type": "application/json",
}; };
return await httpDeleteInterceptor(`magazines/${id}`, headers); return await httpDeleteInterceptor(`magazines/${id}`);
} }
export async function uploadMagazineFile(id: string, data: any) { export async function uploadMagazineFile(id: string, data: any) {
@ -71,5 +67,5 @@ export async function deleteMagazineFiles(id: number) {
const headers = { const headers = {
"content-type": "multipart/form-data", "content-type": "multipart/form-data",
}; };
return await httpDeleteInterceptor(`magazine-files/${id}`, headers); return await httpDeleteInterceptor(`magazine-files/${id}`);
} }

View File

@ -5,6 +5,7 @@ import {
} from "./http-config/axios-base-service"; } from "./http-config/axios-base-service";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { httpGetInterceptor } from "./http-config/http-interceptor-services";
const token = Cookies.get("access_token"); const token = Cookies.get("access_token");
@ -12,9 +13,10 @@ export async function listUserRole(data: any) {
const headers = { const headers = {
"content-type": "application/json", "content-type": "application/json",
}; };
return await httpGet( return await httpGetInterceptor(
`/user-roles?limit=${data.limit}&page=${data.page}`, `/user-roles?limit=${data.limit}&page=${data.page}&timeStamp=${
headers data.timeStamp || ""
}`
); );
} }

View File

@ -18,7 +18,9 @@ export async function listMasterUsers(data: any) {
return await httpGet( return await httpGet(
`/users?page=${data.page}&limit=${data.limit}&username=${ `/users?page=${data.page}&limit=${data.limit}&username=${
data.username || "" data.username || ""
}&fullname=${data.fullname || ""}&email=${data.email || ""}`, }&fullname=${data.fullname || ""}&email=${data.email || ""}&timeStamp=${
data.timeStamp || ""
}`,
headers headers
); );
} }

View File

@ -5,6 +5,7 @@ import {
httpPost, httpPost,
httpPut, httpPut,
} from "./http-config/axios-base-service"; } from "./http-config/axios-base-service";
import { httpGetInterceptor } from "./http-config/http-interceptor-services";
export async function createCustomStaticPage(data: any) { export async function createCustomStaticPage(data: any) {
const headers = { const headers = {
@ -23,13 +24,12 @@ export async function editCustomStaticPage(data: any) {
} }
export async function getCustomStaticPage(props: PaginationRequest) { export async function getCustomStaticPage(props: PaginationRequest) {
const { page, limit, search } = props; const { page, limit, search, timeStamp } = props;
const headers = { const headers = {
"content-type": "application/json", "content-type": "application/json",
}; };
return await httpGet( return await httpGetInterceptor(
`/custom-static-pages?limit=${limit}&page=${page}&title=${search}`, `/custom-static-pages?limit=${limit}&page=${page}&title=${search}&timeStamp=${timeStamp}`
headers
); );
} }
export async function getCustomStaticDetail(id: string) { export async function getCustomStaticDetail(id: string) {

View File

@ -6,6 +6,7 @@ import {
} from "@/services/http-config/axios-base-service"; } from "@/services/http-config/axios-base-service";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { httpGetInterceptor } from "../http-config/http-interceptor-services";
const token = Cookies.get("access_token"); const token = Cookies.get("access_token");
@ -13,11 +14,12 @@ export async function getAllUserLevels(data?: any) {
const headers = { const headers = {
"content-type": "application/json", "content-type": "application/json",
}; };
return await httpGet( return await httpGetInterceptor(
`user-levels?limit=${data?.limit || ""}&levelNumber=${ `user-levels?limit=${data?.limit || ""}&levelNumber=${
data?.levelNumber || "" data?.levelNumber || ""
}&name=${data?.search || ""}&page=${data?.page || "1"}`, }&name=${data?.search || ""}&page=${data?.page || "1"}&timeStamp=${
headers data.timeStamp || ""
}`
); );
} }
export async function getUserLevels(id: string) { export async function getUserLevels(id: string) {

View File

@ -69,4 +69,5 @@ export type PaginationRequest = {
isBanner?: boolean; isBanner?: boolean;
categoryIds?: string; categoryIds?: string;
createdByIds?: string; createdByIds?: string;
timeStamp?: number;
}; };