feat:landing stats
This commit is contained in:
parent
427b2243bc
commit
8ecf1e7146
|
|
@ -11,8 +11,38 @@ import {
|
|||
import { ChevronDownIcon, LandingAnalyticIcon, UserIcon } from "../icons";
|
||||
import { MasterUsersIcon } from "../icons/sidebar-icon";
|
||||
import Image from "next/image";
|
||||
import { useEffect, useState } from "react";
|
||||
import { getActivity } from "@/service/activity-log";
|
||||
|
||||
interface Activity {
|
||||
totalVisitorAllTime: number;
|
||||
totalVisitorToday: number;
|
||||
totalViewAllTime: number;
|
||||
}
|
||||
|
||||
export default function AnalyticDrawer() {
|
||||
const { isOpen, onOpen, onOpenChange } = useDisclosure();
|
||||
const [activity, setActivity] = useState<Activity>({
|
||||
totalVisitorAllTime: 0,
|
||||
totalVisitorToday: 0,
|
||||
totalViewAllTime: 0,
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
initFetch();
|
||||
}, []);
|
||||
|
||||
const initFetch = async () => {
|
||||
const res = await getActivity();
|
||||
if (res?.error) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setActivity(res?.data?.data);
|
||||
console.log("ress", res);
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
|
|
@ -82,11 +112,11 @@ export default function AnalyticDrawer() {
|
|||
/>
|
||||
</div>
|
||||
<p className="text-5xl font-semibold leading-0 tracking-wide">
|
||||
199.295
|
||||
{activity.totalVisitorAllTime}
|
||||
</p>
|
||||
<div className="flex flex-row gap-3 bg-[#BE0106] py-1 px-2 rounded-md items-center w-fit text-sm font-light">
|
||||
<div className="w-2 h-2 bg-success-600 rounded-full"></div>
|
||||
<p>9 Online</p>
|
||||
<p>{activity.totalVisitorToday} Online</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-col gap-3 pl-10 pr-4 pt-4 pb-10 bg-[#671B1D] rounded-lg">
|
||||
|
|
@ -106,7 +136,7 @@ export default function AnalyticDrawer() {
|
|||
/>
|
||||
</div>
|
||||
<p className="text-5xl font-semibold leading-0 tracking-wide">
|
||||
1.199.295
|
||||
{activity.totalViewAllTime}
|
||||
</p>
|
||||
</div>
|
||||
</DrawerBody>
|
||||
|
|
|
|||
|
|
@ -13,3 +13,9 @@ export async function saveActivity(data: any, token?: string) {
|
|||
const pathUrl = `/activity-logs`;
|
||||
return await httpPost(pathUrl, headers, data);
|
||||
}
|
||||
|
||||
export async function getActivity() {
|
||||
const headers = { "content-type": "application/json" };
|
||||
const pathUrl = `/activity-logs/statistics`;
|
||||
return await httpGet(pathUrl, headers);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue