# 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) { export async function POST(req: Request) {
if (req.method === "POST") { if (req.method === "POST") {
const body = await req.json(); const body = await req.json();
console.log(body); // console.log(body);
if (body.nomor === "1234567890") { if (body.nomor === "1234567890") {
return NextResponse.json({ return NextResponse.json({

View File

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

View File

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

View File

@@ -1,12 +1,24 @@
import { Admin_Investasi } from "@/app_modules/admin/investasi"; 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"; import Admin_funGetAllInvestasi from "@/app_modules/admin/investasi/fun/get_all_investasi";
export default async function Page() { export default async function Page() {
const listInvestasi = await Admin_funGetAllInvestasi(); 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 ( 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 ( return (
<> <>
{/* {children} */}
<AppShell header={<HeaderTamplate title="Pilih Aksi" />}> <AppShell header={<HeaderTamplate title="Pilih Aksi" />}>
{children} {children}
</AppShell> </AppShell>

View File

@@ -3,11 +3,13 @@
import { RouterAdminInvestasi } from "@/app/lib/router_hipmi/router_admin"; import { RouterAdminInvestasi } from "@/app/lib/router_hipmi/router_admin";
import { import {
Box, Box,
Button,
Center, Center,
Flex, Flex,
Grid, Grid,
Group, Group,
Paper, Paper,
SimpleGrid,
Stack, Stack,
Text, Text,
Title, Title,
@@ -34,7 +36,38 @@ export default function Admin_HalamanAksi() {
return ( 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) => ( {listHalamanAksi.map((e) => (
<Grid.Col key={e.id} onClick={() => router.push(e.route)}> <Grid.Col key={e.id} onClick={() => router.push(e.route)}>
<Paper bg={"gray"} p={"xs"}> <Paper bg={"gray"} p={"xs"}>
@@ -54,7 +87,7 @@ export default function Admin_HalamanAksi() {
</Paper> </Paper>
</Grid.Col> </Grid.Col>
))} ))}
</Grid> </Grid> */}
</> </>
); );
} }

View File

@@ -7,49 +7,58 @@ import {
Badge, Badge,
Box, Box,
Center, Center,
Divider,
Grid, Grid,
Paper, Paper,
ScrollArea, ScrollArea,
Stack, Stack,
Table, Table,
Text, Text,
Title,
} from "@mantine/core"; } from "@mantine/core";
import { IconEdit } from "@tabler/icons-react"; import { IconEdit } from "@tabler/icons-react";
import { useRouter } from "next/navigation"; import { useRouter } from "next/navigation";
import { useState } from "react"; 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({ export default function Admin_Investasi({
listInvestasi, listInvestasi,
countDraft,
countReview,
countPublish,
countReject,
}: { }: {
listInvestasi: MODEL_Investasi[]; listInvestasi: MODEL_Investasi[];
countDraft: number | any;
countReview: number | any;
countPublish: number | any;
countReject: number | any;
}) { }) {
const [investasi, setInvestasi] = useState(listInvestasi); const [investasi, setInvestasi] = useState(listInvestasi);
const router = useRouter(); 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) => ( const tableBody = investasi.map((e) => (
<tr key={e.id}> <tr key={e.id}>
<td>{e.title}</td> <td>{e.title}</td>
@@ -79,9 +88,11 @@ export default function Admin_Investasi({
return ( return (
<> <>
<Title>Investasi</Title>
<Divider mb={"md"} />
<Grid mb={"md"}> <Grid mb={"md"}>
{listBox.map((e) => ( {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"}> <Paper h={100} bg={"gray"} p={"xs"}>
<Center> <Center>
<Stack spacing={0}> <Stack spacing={0}>
@@ -98,7 +109,7 @@ export default function Admin_Investasi({
))} ))}
</Grid> </Grid>
<Box> <Box my={"lg"}>
<Center my={"xs"}> <Center my={"xs"}>
<Text>List Investasi</Text> <Text>List Investasi</Text>
</Center> </Center>

View File

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

View File

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