# feat:
- Count jumlah perstatus
- Get data review untuk admin
### no issue
This commit is contained in:
2023-11-10 17:51:08 +08:00
parent 65548de7c8
commit 6e7be766b9
10 changed files with 177 additions and 50 deletions

View File

@@ -9,7 +9,7 @@ import { NextResponse } from "next/server";
export async function POST(req: Request) {
if (req.method === "POST") {
const body = await req.json();
console.log(body);
// console.log(body);
if (body.nomor === "1234567890") {
return NextResponse.json({

View File

@@ -1,15 +1,10 @@
import { Admin_LayoutHalamanAksi } from "@/app_modules/admin/investasi";
import React from "react";
export default async function Layout({
children,
}: {
children: React.ReactNode;
}) {
return (
<>
<Admin_LayoutHalamanAksi>{children}</Admin_LayoutHalamanAksi>
</>
);
export default async function Layout({ children }: { children: React.ReactNode }) {
return <>
<Admin_LayoutHalamanAksi>{children}</Admin_LayoutHalamanAksi>
</>;
}

View File

@@ -1,8 +1,9 @@
import { Admin_HalamanAksi } from "@/app_modules/admin/investasi";
export default async function Page() {
return<>
<Admin_HalamanAksi/>
return (
<>
<Admin_HalamanAksi />
</>
}
);
}

View File

@@ -1,12 +1,24 @@
import { Admin_Investasi } from "@/app_modules/admin/investasi";
import Admin_CountStatusInvestasi from "@/app_modules/admin/investasi/fun/count_status";
import Admin_funGetAllInvestasi from "@/app_modules/admin/investasi/fun/get_all_investasi";
export default async function Page() {
const listInvestasi = await Admin_funGetAllInvestasi();
// console.log(listInvestasi)
const countDraft = await Admin_CountStatusInvestasi(1);
const countReview = await Admin_CountStatusInvestasi(2);
const countPublish = await Admin_CountStatusInvestasi(3);
const countReject = await Admin_CountStatusInvestasi(4);
return (
<>
<Admin_Investasi listInvestasi={listInvestasi as any} />
<Admin_Investasi
listInvestasi={listInvestasi as any}
countDraft={countDraft}
countReview={countReview}
countPublish={countPublish}
countReject={countReject}
/>
</>
);
}

View File

@@ -0,0 +1,65 @@
"use server";
import prisma from "@/app/lib/prisma";
import _ from "lodash";
/**
*
* @param id
*
* @type number
* @returns count of status investasi
*/
export default async function Admin_CountStatusInvestasi(id: number) {
if (id === 1) {
const count = await prisma.investasi.count({
where: {
MasterStatusInvestasi: {
name: {
equals: "Draft",
},
},
},
});
return count;
}
if (id === 2) {
const count = await prisma.investasi.count({
where: {
MasterStatusInvestasi: {
name: {
equals: "Review",
},
},
},
});
return count;
}
if (id === 3) {
const count = await prisma.investasi.count({
where: {
MasterStatusInvestasi: {
name: {
equals: "Publish",
},
},
},
});
return count;
}
if (id === 4) {
const count = await prisma.investasi.count({
where: {
MasterStatusInvestasi: {
name: {
equals: "Reject",
},
},
},
});
return count;
}
}

View File

@@ -11,6 +11,7 @@ export default function Admin_LayoutHalamanAksi({
}) {
return (
<>
{/* {children} */}
<AppShell header={<HeaderTamplate title="Pilih Aksi" />}>
{children}
</AppShell>

View File

@@ -3,11 +3,13 @@
import { RouterAdminInvestasi } from "@/app/lib/router_hipmi/router_admin";
import {
Box,
Button,
Center,
Flex,
Grid,
Group,
Paper,
SimpleGrid,
Stack,
Text,
Title,
@@ -34,7 +36,38 @@ export default function Admin_HalamanAksi() {
return (
<>
<Grid mb={"md"} align="center">
<SimpleGrid
cols={4}
spacing="sm"
breakpoints={[
// { maxWidth: "lg", cols: 6, spacing: "lg" },
{ maxWidth: "md", cols: 3, spacing: "md" },
{ maxWidth: "sm", cols: 2, spacing: "sm" },
{ maxWidth: "xs", cols: 1, spacing: "xs" },
]}
>
{listHalamanAksi.map((e) => (
<Paper key={e.id} bg={"gray"} p={"sm"}>
<Stack>
<Stack spacing={0}>
<Title order={6}>{e.name}</Title>
<Text fz={"sm"}>{e.desc}</Text>
</Stack>
<Center>
<Button
compact
radius={50}
w={100}
onClick={() => router.push(e.route)}
>
Lihat
</Button>
</Center>
</Stack>
</Paper>
))}
</SimpleGrid>
{/* <Grid mb={"md"} align="center">
{listHalamanAksi.map((e) => (
<Grid.Col key={e.id} onClick={() => router.push(e.route)}>
<Paper bg={"gray"} p={"xs"}>
@@ -54,7 +87,7 @@ export default function Admin_HalamanAksi() {
</Paper>
</Grid.Col>
))}
</Grid>
</Grid> */}
</>
);
}

View File

@@ -7,49 +7,58 @@ import {
Badge,
Box,
Center,
Divider,
Grid,
Paper,
ScrollArea,
Stack,
Table,
Text,
Title,
} from "@mantine/core";
import { IconEdit } from "@tabler/icons-react";
import { useRouter } from "next/navigation";
import { useState } from "react";
const listBox = [
{
id: 1,
name: "Investasi Baru",
jumlah: 12,
},
{
id: 2,
name: "Investasi Aktif",
jumlah: 3,
},
{
id: 3,
name: "Investasi Selesai",
jumlah: 5,
},
{
id: 4,
name: "Total Proyek Investasi",
jumlah: 2,
},
];
export default function Admin_Investasi({
listInvestasi,
countDraft,
countReview,
countPublish,
countReject,
}: {
listInvestasi: MODEL_Investasi[];
countDraft: number | any;
countReview: number | any;
countPublish: number | any;
countReject: number | any;
}) {
const [investasi, setInvestasi] = useState(listInvestasi);
const router = useRouter();
const listBox = [
{
id: 1,
name: "Draft",
jumlah: countDraft,
},
{
id: 2,
name: "Review",
jumlah: countReview,
},
{
id: 3,
name: "Publish",
jumlah: countPublish,
},
{
id: 4,
name: "Reject",
jumlah: countReject,
},
];
const tableBody = investasi.map((e) => (
<tr key={e.id}>
<td>{e.title}</td>
@@ -79,9 +88,11 @@ export default function Admin_Investasi({
return (
<>
<Title>Investasi</Title>
<Divider mb={"md"} />
<Grid mb={"md"}>
{listBox.map((e) => (
<Grid.Col sm={12} md={6} lg={4} key={e.id}>
<Grid.Col sm={12} md={6} lg={3} key={e.id}>
<Paper h={100} bg={"gray"} p={"xs"}>
<Center>
<Stack spacing={0}>
@@ -98,7 +109,7 @@ export default function Admin_Investasi({
))}
</Grid>
<Box>
<Box my={"lg"}>
<Center my={"xs"}>
<Text>List Investasi</Text>
</Center>

View File

@@ -39,7 +39,7 @@ export default function AdminLayout({
const theme = useMantineTheme();
const [opened, setOpened] = useState(false);
const router = useRouter();
// const [active, setActive] = useState(false)
const [active, setActive] = useState(1);
const listAdminPage = [
{
@@ -67,12 +67,19 @@ export default function AdminLayout({
asideOffsetBreakpoint="sm"
navbar={
<MediaQuery smallerThan={"md"} styles={{ display: "none" }}>
<Navbar width={{ lg: 200, md: 200, sm: 200, base: 200 }} hiddenBreakpoint="md" hidden={!opened} p="xs" bg={"gray.2"}>
<Navbar
width={{ lg: 200, md: 200, sm: 200, base: 200 }}
hiddenBreakpoint="md"
hidden={!opened}
p="xs"
bg={"gray.2"}
>
{listAdminPage.map((e) => (
<NavLink
key={e.id}
label={e.name}
onClick={() => {
// setActive(e.id);
router.push(e.route);
}}
/>
@@ -105,8 +112,8 @@ export default function AdminLayout({
{/* Web View */}
<MediaQuery smallerThan={"md"} styles={{ display: "none" }}>
<Group position="apart" align="center" h={50} px={"md"}>
<Text fw={"lighter"}>HIPMI</Text>
<Title order={4}>Dashboard Admin</Title>
<Text fw={"lighter"}>Dashboard Admin</Text>
<Title order={4}> HIPMI</Title>
{/* <Group>
{listAdminPage.map((e) => (
<Text key={e.id} onClick={() => router.push(e.route)}>
@@ -120,6 +127,8 @@ export default function AdminLayout({
</Header>
}
>
{/* {JSON.stringify(active)} */}
{children}
</AppShell>
<Drawer opened={opened} onClose={() => setOpened(false)} size={"50%"}>

View File

@@ -38,7 +38,7 @@ export default function Login() {
})
.then((res) => res.json())
.then((val) => {
console.log(val);
// console.log(val);
if (val.success === true) {
router.push(RouterAdminDashboard.splash_admin);
} else {