Tambahan
This commit is contained in:
@@ -5,37 +5,122 @@ import { useRouter } from "next/navigation";
|
||||
import ComponentAdminGlobal_HeaderTamplate from "../../_admin_global/header_tamplate";
|
||||
import { IconAlertTriangle, IconMessage2, IconUpload } from "@tabler/icons-react";
|
||||
import { AccentColor, AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { useState } from "react";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { apiGetAdminCollaborationStatusCountDashboard } from "../lib/api_fetch_admin_collaboration";
|
||||
import global_limit from "@/app/lib/limit";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export default function AdminColab_Dashboard({
|
||||
countPublish,
|
||||
countRoom,
|
||||
countReject,
|
||||
}: {
|
||||
countPublish: number;
|
||||
countRoom: number;
|
||||
countReject: number;
|
||||
}) {
|
||||
export default function AdminColab_Dashboard() {
|
||||
const [countPublish, setCountPublish] = useState<number | null>(null);
|
||||
const [countRoom, setCountRoom] = useState<number | null>(null);
|
||||
const [countReject, setCountReject] = useState<number | null>(null);
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
|
||||
useShallowEffect(() => {
|
||||
handlerLoadData()
|
||||
}, []);
|
||||
|
||||
async function handlerLoadData() {
|
||||
try {
|
||||
const listLoadData = [
|
||||
global_limit(() => onLoadCountPublish()),
|
||||
global_limit(() => onLoadCountRoom()),
|
||||
global_limit(() => onLoadCountReject()),
|
||||
]
|
||||
const result = await Promise.all(listLoadData);
|
||||
} catch (error) {
|
||||
clientLogger.error("Error handler load data", error)
|
||||
}
|
||||
}
|
||||
async function onLoadCountPublish() {
|
||||
try {
|
||||
const response = await apiGetAdminCollaborationStatusCountDashboard({
|
||||
name: "Publish",
|
||||
})
|
||||
if (response) {
|
||||
setCountPublish(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get count publish", error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function onLoadCountRoom() {
|
||||
try {
|
||||
const response = await apiGetAdminCollaborationStatusCountDashboard(
|
||||
{
|
||||
name: "Room",
|
||||
}
|
||||
)
|
||||
if (response) {
|
||||
setCountRoom(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get count room", error);
|
||||
}
|
||||
}
|
||||
|
||||
async function onLoadCountReject() {
|
||||
try {
|
||||
const response = await apiGetAdminCollaborationStatusCountDashboard({
|
||||
name: "Reject",
|
||||
})
|
||||
if (response) {
|
||||
setCountReject(response.data);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get count reject", error);
|
||||
}
|
||||
}
|
||||
|
||||
const listStatus = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Publish",
|
||||
jumlah: countPublish,
|
||||
jumlah: countPublish
|
||||
== null ? (
|
||||
<CustomSkeleton height={40} width={40} />
|
||||
) : countPublish ? (
|
||||
countPublish
|
||||
) : (
|
||||
"-"
|
||||
)
|
||||
,
|
||||
color: "green",
|
||||
icon: <IconUpload size={18} color="#4CAF4F" />
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Group Chat",
|
||||
jumlah: countRoom,
|
||||
jumlah: countRoom
|
||||
== null ? (
|
||||
<CustomSkeleton height={40} width={40} />
|
||||
) : countRoom ? (
|
||||
countRoom
|
||||
) : (
|
||||
"-"
|
||||
)
|
||||
,
|
||||
color: "orange",
|
||||
icon: <IconMessage2 size={18} color="#FF9800" />
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
name: "Reject",
|
||||
jumlah: countReject,
|
||||
jumlah: countReject
|
||||
== null ? (
|
||||
<CustomSkeleton height={40} width={40} />
|
||||
) : countReject ? (
|
||||
countReject
|
||||
) : (
|
||||
"-"
|
||||
)
|
||||
,
|
||||
color: "red",
|
||||
icon: <IconAlertTriangle size={18} color="#FF4B4C" />
|
||||
},
|
||||
@@ -84,3 +169,7 @@ export default function AdminColab_Dashboard({
|
||||
</>
|
||||
);
|
||||
}
|
||||
function apiGetAdminCollaborationStatuCountDashboard(arg0: { name: string; }) {
|
||||
throw new Error("Function not implemented.");
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
export {
|
||||
apiGetAdminCollaborationStatusCountDashboard,
|
||||
|
||||
}
|
||||
const apiGetAdminCollaborationStatusCountDashboard = async ({
|
||||
name
|
||||
}: {
|
||||
name: "Publish" | "Reject" | "Room";
|
||||
}) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
// console.log("Ini Token", token);
|
||||
const response = await fetch(`/api/admin/collaboration/dashboard/${name}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
}
|
||||
})
|
||||
// console.log("Ini Response", await response.json());
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
@@ -48,9 +48,7 @@ const apiGetAdminDonasiByStatus = async ({
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
console.log("Ini token", token)
|
||||
console.log("Ini Page", page)
|
||||
console.log("Ini search", search)
|
||||
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const isSearch = search ? `&search=${search}` : "";
|
||||
const response = await fetch(
|
||||
@@ -64,14 +62,14 @@ const apiGetAdminDonasiByStatus = async ({
|
||||
}
|
||||
}
|
||||
)
|
||||
console.log("Ini response", response)
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
const apiGetAdminDonasiKategori = async () => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
console.log("ini token", token)
|
||||
|
||||
const response = await fetch(`/api/admin/donasi/kategori`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
|
||||
@@ -73,7 +73,7 @@ function TableView() {
|
||||
try {
|
||||
const response = await apiGetAdminDonasiKategori();
|
||||
if (response) {
|
||||
console.log("ini response", response)
|
||||
|
||||
setData(response.data)
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -96,7 +96,7 @@ function TableView() {
|
||||
}
|
||||
|
||||
async function onChangeStatus() {
|
||||
// console.log(updateStatus.kategoriId, updateStatus.isActive);
|
||||
|
||||
const del = await adminDonasi_funDeleteKategori({
|
||||
kategoriId: updateStatus.kategoriId,
|
||||
isActive: updateStatus.isActive as any,
|
||||
|
||||
@@ -72,7 +72,7 @@ function TableStatus() {
|
||||
page: `${isActivePage}`,
|
||||
search: isSearch
|
||||
})
|
||||
console.log("IniData", response)
|
||||
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data);
|
||||
|
||||
@@ -162,11 +162,11 @@ export default function AdminEvent_ComponentTableReview() {
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
console.log("review >>", response.data.data);
|
||||
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -227,7 +227,7 @@ export default function AdminEvent_ComponentTableReview() {
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
console.log("review >>", response.data.data);
|
||||
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
|
||||
@@ -28,12 +28,10 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
|
||||
page: string,
|
||||
search: string
|
||||
}) => {
|
||||
console.log("dgsdg")
|
||||
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
console.log("Ini token", token)
|
||||
console.log("Ini Page", page)
|
||||
console.log("Ini Search", search)
|
||||
|
||||
|
||||
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
@@ -46,6 +44,6 @@ const apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
})
|
||||
console.log("Ini response", response)
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
Reference in New Issue
Block a user