fix: admin donasi
deskripsi: - fix perubahan use server menjadi API src/app/api/admin/donasi/[id]/count/route.ts src/app/api/admin/donasi/[id]/pencairan/route.ts src/app/dev/admin/donasi/detail/publish/[id]/page.tsx src/app_modules/admin/_admin_global/comp_preview_image_admin.tsx src/app_modules/admin/donasi/detail/publish/detail_list_donatur.tsx src/app_modules/admin/donasi/detail/publish/detail_list_pencairan.tsx src/app_modules/admin/donasi/detail/publish/detail_publish.tsx src/app_modules/admin/donasi/lib/api_fetch_admin_donasi.ts src/app_modules/admin/donasi/sub-detail/bukti_transfer_pencairan.tsx No Issue
This commit is contained in:
29
src/app/api/admin/donasi/[id]/count/route.ts
Normal file
29
src/app/api/admin/donasi/[id]/count/route.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
export async function GET(
|
||||
req: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
const { id } = params;
|
||||
try {
|
||||
const data = await prisma.donasi_Invoice.count({
|
||||
where: {
|
||||
donasiId: id,
|
||||
donasiMaster_StatusInvoiceId: "1",
|
||||
},
|
||||
});
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Data berhasil diambil",
|
||||
data: data,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Error get count donasi ", error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Error get count donasi",
|
||||
reason: (error as Error).message,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,64 @@
|
||||
import prisma from "@/lib/prisma";
|
||||
import backendLogger from "@/util/backendLogger";
|
||||
import _ from "lodash";
|
||||
import { NextResponse } from "next/server";
|
||||
export async function GET(req: Request, { params }: { params: { id: string } }) {
|
||||
const donasiId = params.id
|
||||
try {
|
||||
const data = await prisma.donasi_PencairanDana.findMany({
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
donasiId: donasiId,
|
||||
}
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get pencairan donasi >>", error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Error get pencairan donasi",
|
||||
reason: (error as Error).message
|
||||
})
|
||||
export async function GET(
|
||||
req: Request,
|
||||
{ params }: { params: { id: string } }
|
||||
) {
|
||||
|
||||
let fixData;
|
||||
const donasiId = params.id;
|
||||
const { searchParams } = new URL(req.url);
|
||||
const page = searchParams.get("page");
|
||||
const takeData = 10
|
||||
const skipData = Number(page) * takeData - takeData;
|
||||
|
||||
try {
|
||||
if (!page) {
|
||||
fixData = await prisma.donasi_PencairanDana.findMany({
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
donasiId: donasiId,
|
||||
},
|
||||
});
|
||||
} else {
|
||||
const data = await prisma.donasi_PencairanDana.findMany({
|
||||
take: takeData,
|
||||
skip: skipData,
|
||||
orderBy: {
|
||||
createdAt: "desc",
|
||||
},
|
||||
where: {
|
||||
donasiId: donasiId,
|
||||
},
|
||||
});
|
||||
|
||||
const nCount = await prisma.donasi_PencairanDana.count({
|
||||
where: {
|
||||
donasiId: donasiId,
|
||||
},
|
||||
});
|
||||
|
||||
fixData = {
|
||||
data: data,
|
||||
nPage: _.ceil(nCount / takeData),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
success: true,
|
||||
message: "Data berhasil diambil",
|
||||
data: fixData,
|
||||
});
|
||||
} catch (error) {
|
||||
backendLogger.error("Error get pencairan donasi >>", error);
|
||||
return NextResponse.json({
|
||||
success: false,
|
||||
message: "Error get pencairan donasi",
|
||||
reason: (error as Error).message,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,10 @@ import { AdminDonasi_DetailPublish } from "@/app_modules/admin/donasi";
|
||||
import { AdminDonasi_funCountDonatur } from "@/app_modules/admin/donasi/fun/count/fun_count_donatur";
|
||||
import { AdminDonasi_getListPencairanDana } from "@/app_modules/admin/donasi/fun/get/get_list_pencairan_dana_by_id";
|
||||
|
||||
export default async function Page({ params }: { params: { id: string } }) {
|
||||
let donasiId = params.id;
|
||||
// const dataPublish = await AdminDonasi_getOneById(params.id);
|
||||
const countDonatur = await AdminDonasi_funCountDonatur(params.id);
|
||||
const listPencairan = await AdminDonasi_getListPencairanDana(params.id);
|
||||
|
||||
export default async function Page() {
|
||||
return (
|
||||
<>
|
||||
<AdminDonasi_DetailPublish
|
||||
countDonatur={countDonatur}
|
||||
listPencairan={listPencairan as any}
|
||||
/>
|
||||
<AdminDonasi_DetailPublish />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -5,15 +5,18 @@ import Admin_ComponentBackButton from "./back_button";
|
||||
import { APIs, pathAssetImage } from "@/lib";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { useState } from "react";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export function Admin_ComponentPreviewImageAdmin({
|
||||
fileId,
|
||||
size,
|
||||
}: {
|
||||
fileId: string;
|
||||
size?: string;
|
||||
}) {
|
||||
const [isImage, setIsImage] = useState<boolean | null>(null);
|
||||
|
||||
const url = APIs.GET({ fileId: fileId, size: "500" });
|
||||
const url = APIs.GET({ fileId: fileId, size: size || "1000" });
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadImage();
|
||||
@@ -35,18 +38,20 @@ export function Admin_ComponentPreviewImageAdmin({
|
||||
<>
|
||||
<Stack>
|
||||
<Admin_ComponentBackButton />
|
||||
<Box style={{ zIndex: 0 }} h={"90vh"} pos={"static"} px={"lg"}>
|
||||
<Box style={{ zIndex: 0 }} h={"80vh"} pos={"static"} px={"lg"}>
|
||||
{isImage === null ? (
|
||||
<Center>
|
||||
<Skeleton height={300} w={200} radius={"sm"} />
|
||||
<CustomSkeleton height={500} w={300} radius={"sm"} />
|
||||
</Center>
|
||||
) : isImage ? (
|
||||
<ScrollArea h={"100%"}>
|
||||
<Center>
|
||||
<Image alt="Image" src={url} maw={500} miw={200} />
|
||||
</Center>
|
||||
</ScrollArea>
|
||||
<Center>
|
||||
<Image alt="Image" src={url} maw={300} />
|
||||
</Center>
|
||||
) : (
|
||||
// <ScrollArea h={"100%"}>
|
||||
// <Center>
|
||||
// </Center>
|
||||
// </ScrollArea>
|
||||
<Box
|
||||
bg={"gray"}
|
||||
style={{
|
||||
|
||||
@@ -271,7 +271,6 @@ function TampilanListDonatur({
|
||||
verticalSpacing={"xl"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1120}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
|
||||
@@ -1,114 +1,176 @@
|
||||
import { AccentColor } from '@/app_modules/_global/color';
|
||||
import { AdminColor } from '@/app_modules/_global/color/color_pallet';
|
||||
import { ComponentAdminGlobal_TitlePage } from '@/app_modules/admin/_admin_global/_component';
|
||||
import TampilanRupiahDonasi from '@/app_modules/donasi/component/tampilan_rupiah';
|
||||
import { MODEL_DONASI_PENCAIRAN_DANA } from '@/app_modules/donasi/model/interface';
|
||||
import { RouterAdminDonasi } from '@/lib/router_admin/router_admin_donasi';
|
||||
import { Center, Box, Spoiler, Button, Stack, Group, ActionIcon, Paper, ScrollArea, Table, Text, TextInput } from '@mantine/core';
|
||||
import { useDisclosure } from '@mantine/hooks';
|
||||
import { IconReload } from '@tabler/icons-react';
|
||||
import moment from 'moment';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import React, { useState } from 'react';
|
||||
import { AccentColor } from "@/app_modules/_global/color";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { ComponentAdminGlobal_TitlePage } from "@/app_modules/admin/_admin_global/_component";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import TampilanRupiahDonasi from "@/app_modules/donasi/component/tampilan_rupiah";
|
||||
import { MODEL_DONASI_PENCAIRAN_DANA } from "@/app_modules/donasi/model/interface";
|
||||
import { RouterAdminDonasi } from "@/lib/router_admin/router_admin_donasi";
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Center,
|
||||
Paper,
|
||||
ScrollArea,
|
||||
Spoiler,
|
||||
Stack,
|
||||
Table,
|
||||
Text,
|
||||
} from "@mantine/core";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import moment from "moment";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { apiGetAdminDonasiPencairan } from "../../lib/api_fetch_admin_donasi";
|
||||
import { Admin_V3_ComponentPaginationBreakpoint } from "@/app_modules/admin/_components_v3/comp_pagination_breakpoint";
|
||||
|
||||
function TampilanListPencairan({
|
||||
pencairan,
|
||||
}: {
|
||||
pencairan: MODEL_DONASI_PENCAIRAN_DANA[];
|
||||
}) {
|
||||
function TampilanListPencairan() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState(pencairan);
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const [gambarId, setGambarId] = useState("");
|
||||
const [data, setData] = useState<MODEL_DONASI_PENCAIRAN_DANA[] | null>(null);
|
||||
const [nPage, setNPage] = useState<number>(1);
|
||||
const [activePage, setActivePage] = useState<number>(1);
|
||||
const [loading, setLoading] = useState("");
|
||||
|
||||
const rowTable = data.map((e) => (
|
||||
<tr key={e.id}>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<TampilanRupiahDonasi nominal={e.nominalCair} />
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>{moment(e.createdAt).format("ll")}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white}>
|
||||
<Text>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Box w={"100%"}>
|
||||
<Spoiler c={AdminColor.white} hideLabel="Sembunyikan" maxHeight={70} showLabel="Lihat">
|
||||
{e.deskripsi}
|
||||
</Spoiler>
|
||||
</Box>
|
||||
</td>
|
||||
<td>
|
||||
<Box>
|
||||
useShallowEffect(() => {
|
||||
onLoadData();
|
||||
}, [activePage]);
|
||||
|
||||
async function onLoadData() {
|
||||
try {
|
||||
const response = await apiGetAdminDonasiPencairan({
|
||||
id: params.id,
|
||||
page: `${activePage}`,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data) {
|
||||
// console.log("response", response.data);
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage);
|
||||
} else {
|
||||
setData([]);
|
||||
setNPage(1);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get pencairan donasi:", error);
|
||||
setData([]);
|
||||
setNPage(1);
|
||||
}
|
||||
}
|
||||
|
||||
const onPageClick = (page: number) => {
|
||||
setActivePage(page);
|
||||
};
|
||||
|
||||
const rowTable = () => {
|
||||
if (!Array.isArray(data) || data.length === 0) {
|
||||
return (
|
||||
<tr>
|
||||
<td colSpan={12}>
|
||||
<Center>
|
||||
<Text color="gray">Tidak ada data</Text>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
}
|
||||
|
||||
return data.map((e) => (
|
||||
<tr key={e.id}>
|
||||
<td>
|
||||
<Center c={AdminColor.white} w={150}>
|
||||
<TampilanRupiahDonasi nominal={e.nominalCair} />
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AdminColor.white} w={150}>
|
||||
{moment(e.createdAt).format("ll")}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Box w={200}>
|
||||
<Spoiler
|
||||
c={AdminColor.white}
|
||||
hideLabel="Sembunyikan"
|
||||
maxHeight={70}
|
||||
showLabel="Lihat"
|
||||
>
|
||||
{e.title}
|
||||
</Spoiler>
|
||||
</Box>
|
||||
</td>
|
||||
<td>
|
||||
<Box w={400}>
|
||||
<Spoiler
|
||||
c={AdminColor.white}
|
||||
hideLabel="Sembunyikan"
|
||||
maxHeight={70}
|
||||
showLabel="Lihat"
|
||||
>
|
||||
{e.deskripsi}
|
||||
</Spoiler>
|
||||
</Box>
|
||||
</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Button
|
||||
loaderPosition="center"
|
||||
loading={loading === e.id}
|
||||
radius={"xl"}
|
||||
bg={"green"}
|
||||
color="green"
|
||||
onClick={() => {
|
||||
// open();
|
||||
// setGambarId(e.imagesId);
|
||||
setLoading(e.id);
|
||||
router.push(
|
||||
RouterAdminDonasi.transfer_invoice_reimbursement + e?.imagesId
|
||||
RouterAdminDonasi.transfer_invoice_reimbursement + e.imageId
|
||||
);
|
||||
}}
|
||||
>
|
||||
Cek
|
||||
</Button>
|
||||
</Center>
|
||||
</Box>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
};
|
||||
|
||||
if (!data) return <CustomSkeleton height={400} />;
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
name="Rincian Pencairan Dana"
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<Group>
|
||||
<ActionIcon
|
||||
size={"lg"}
|
||||
radius={"xl"}
|
||||
variant="light"
|
||||
onClick={() => {
|
||||
// onRelaod();
|
||||
}}
|
||||
>
|
||||
<IconReload />
|
||||
</ActionIcon>
|
||||
{/* <Select
|
||||
placeholder="Pilih status"
|
||||
value={isSelect}
|
||||
data={listMasterStatus.map((e) => ({
|
||||
value: e.id,
|
||||
label: e.name,
|
||||
}))}
|
||||
onChange={(val) => {
|
||||
onSelect(val);
|
||||
}}
|
||||
/> */}
|
||||
</Group>
|
||||
}
|
||||
// component={
|
||||
// <Group>
|
||||
// <ActionIcon
|
||||
// size={"lg"}
|
||||
// radius={"xl"}
|
||||
// variant="light"
|
||||
// onClick={() => {
|
||||
// // onRelaod();
|
||||
// }}
|
||||
// >
|
||||
// <IconReload />
|
||||
// </ActionIcon>
|
||||
// {/* <Select
|
||||
// placeholder="Pilih status"
|
||||
// value={isSelect}
|
||||
// data={listMasterStatus.map((e) => ({
|
||||
// value: e.id,
|
||||
// label: e.name,
|
||||
// }))}
|
||||
// onChange={(val) => {
|
||||
// onSelect(val);
|
||||
// }}
|
||||
// /> */}
|
||||
// </Group>
|
||||
// }
|
||||
/>
|
||||
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"xl"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1100}
|
||||
|
||||
>
|
||||
<Table verticalSpacing={"xl"} horizontalSpacing={"md"} p={"md"}>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
@@ -118,7 +180,7 @@ function TampilanListPencairan({
|
||||
<Center c={AccentColor.white}>Tanggal</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center c={AccentColor.white}>Judul</Center>
|
||||
<Text c={AccentColor.white}>Judul</Text>
|
||||
</th>
|
||||
<th style={{ color: AccentColor.white }}>Deskripsi</th>
|
||||
<th>
|
||||
@@ -126,28 +188,21 @@ function TampilanListPencairan({
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{rowTable}</tbody>
|
||||
<tbody>{rowTable()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
|
||||
{/* <Center mt={"xl"}>
|
||||
<Pagination
|
||||
value={isActivePage}
|
||||
total={isNPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Center> */}
|
||||
<Admin_V3_ComponentPaginationBreakpoint
|
||||
value={activePage}
|
||||
total={nPage}
|
||||
onChange={(val) => {
|
||||
onPageClick(val);
|
||||
}}
|
||||
/>
|
||||
</Paper>
|
||||
</Stack>
|
||||
|
||||
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
export default TampilanListPencairan;
|
||||
|
||||
|
||||
|
||||
@@ -6,12 +6,10 @@ import { Admin_ComponentLoadImageLandscape } from "@/app_modules/admin/_admin_gl
|
||||
import CustomSkeletonAdmin from "@/app_modules/admin/_admin_global/_component/skeleton/customSkeletonAdmin";
|
||||
import Admin_ComponentBackButton from "@/app_modules/admin/_admin_global/back_button";
|
||||
import {
|
||||
MODEL_DONASI,
|
||||
MODEL_DONASI_PENCAIRAN_DANA,
|
||||
MODEL_DONASI
|
||||
} from "@/app_modules/donasi/model/interface";
|
||||
import { RouterAdminDonasi } from "@/lib/router_admin/router_admin_donasi";
|
||||
import { RouterAdminDonasi_OLD } from "@/lib/router_hipmi/router_admin";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import {
|
||||
Button,
|
||||
Center,
|
||||
@@ -28,20 +26,16 @@ import { useDisclosure, useShallowEffect } from "@mantine/hooks";
|
||||
import { toNumber } from "lodash";
|
||||
import { useParams, useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { apiGetAdminDonasiById } from "../../lib/api_fetch_admin_donasi";
|
||||
import {
|
||||
apiGetAdminDonasiById,
|
||||
apiGetAdminDonasiCountDonatur,
|
||||
} from "../../lib/api_fetch_admin_donasi";
|
||||
import TampilanListDonatur from "./detail_list_donatur";
|
||||
import TampilanListPencairan from "./detail_list_pencairan";
|
||||
|
||||
export default function AdminDonasi_DetailPublish({
|
||||
countDonatur,
|
||||
listPencairan,
|
||||
}: {
|
||||
countDonatur: number;
|
||||
listPencairan: MODEL_DONASI_PENCAIRAN_DANA[];
|
||||
}) {
|
||||
const [pencairan, setPencairan] = useState(listPencairan);
|
||||
const [isReload, setReload] = useState(false);
|
||||
export default function AdminDonasi_DetailPublish() {
|
||||
const params = useParams<{ id: string }>();
|
||||
const [isReload, setReload] = useState(false);
|
||||
const [data, setData] = useState<MODEL_DONASI | null>(null);
|
||||
|
||||
useShallowEffect(() => {
|
||||
@@ -61,23 +55,20 @@ export default function AdminDonasi_DetailPublish({
|
||||
setData(null);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Invalid data format recieved:", error);
|
||||
console.error("Invalid data format recieved:", error);
|
||||
setData(null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* <pre>{JSON.stringify(pencairan, null, 2)}</pre> */}
|
||||
<Stack>
|
||||
<>
|
||||
<Admin_ComponentBackButton
|
||||
path={RouterAdminDonasi.table_publish}
|
||||
/>
|
||||
<Admin_ComponentBackButton path={RouterAdminDonasi.table_publish} />
|
||||
{!data ? (
|
||||
<CustomSkeletonAdmin height={"40vh"} />
|
||||
) : (
|
||||
<TampilanDetailDonasi countDonatur={countDonatur} donasi={data} />
|
||||
<TampilanDetailDonasi donasi={data} />
|
||||
)}
|
||||
{!data ? (
|
||||
<CustomSkeletonAdmin height={"80vh"} />
|
||||
@@ -90,7 +81,7 @@ export default function AdminDonasi_DetailPublish({
|
||||
isReload={isReload}
|
||||
/>
|
||||
)}
|
||||
<TampilanListPencairan pencairan={pencairan} />
|
||||
<TampilanListPencairan />
|
||||
</>
|
||||
</Stack>
|
||||
</>
|
||||
@@ -98,15 +89,34 @@ export default function AdminDonasi_DetailPublish({
|
||||
}
|
||||
|
||||
function TampilanDetailDonasi({
|
||||
countDonatur,
|
||||
// countDonatur,
|
||||
donasi,
|
||||
}: {
|
||||
countDonatur: number;
|
||||
// countDonatur: number;
|
||||
donasi: MODEL_DONASI;
|
||||
}) {
|
||||
const [opened, { open, close }] = useDisclosure(false);
|
||||
const router = useRouter();
|
||||
const [isLoadingPencairanDana, setIsLoadingPencairanDana] = useState(false);
|
||||
const [countDonatur, setCountDonatur] = useState(0);
|
||||
|
||||
useShallowEffect(() => {
|
||||
onLoadData()
|
||||
}, []);
|
||||
|
||||
async function onLoadData() {
|
||||
try {
|
||||
const response = await apiGetAdminDonasiCountDonatur({ id: donasi.id });
|
||||
if (response?.success && response?.data) {
|
||||
setCountDonatur(response.data);
|
||||
} else {
|
||||
setCountDonatur(0);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error get count donatur", error);
|
||||
setCountDonatur(0);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -227,7 +237,7 @@ function TampilanDetailDonasi({
|
||||
</Grid.Col>
|
||||
<Grid.Col span={"auto"}>
|
||||
<Title order={5} c={AdminColor.white}>
|
||||
{countDonatur}
|
||||
{countDonatur ? countDonatur : "-"}
|
||||
</Title>
|
||||
</Grid.Col>
|
||||
</Grid>
|
||||
|
||||
@@ -1,163 +1,237 @@
|
||||
export {
|
||||
apiGetAdminDonasiStatusCountDashboard,
|
||||
apiGetAdminDonasiKategoriCountDashboard,
|
||||
apiGetAdminDonasiByStatus,
|
||||
apiGetAdminDonasiKategori,
|
||||
apiGetAdminDonasiById,
|
||||
apiGetAdminAllDaftarDonatur,
|
||||
apiGetAdminStatusDaftarDonatur
|
||||
apiGetAdminDonasiStatusCountDashboard,
|
||||
apiGetAdminDonasiKategoriCountDashboard,
|
||||
apiGetAdminDonasiByStatus,
|
||||
apiGetAdminDonasiKategori,
|
||||
apiGetAdminDonasiById,
|
||||
apiGetAdminAllDaftarDonatur,
|
||||
apiGetAdminStatusDaftarDonatur,
|
||||
apiGetAdminDonasiCountDonatur,
|
||||
apiGetAdminDonasiPencairan,
|
||||
};
|
||||
const apiGetAdminDonasiStatusCountDashboard = async ({ name }:
|
||||
{ name: "Publish" | "Review" | "Reject" }) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
const apiGetAdminDonasiStatusCountDashboard = async ({
|
||||
name,
|
||||
}: {
|
||||
name: "Publish" | "Review" | "Reject";
|
||||
}) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const response = await fetch(`/api/admin/donasi/dashboard/${name}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
}
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
const response = await fetch(`/api/admin/donasi/dashboard/${name}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
|
||||
const apiGetAdminDonasiKategoriCountDashboard = async () => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const response = await fetch(`/api/admin/donasi/dashboard/kategori`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control_Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
const response = await fetch(`/api/admin/donasi/dashboard/kategori`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control_Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
|
||||
const apiGetAdminDonasiByStatus = async ({
|
||||
name,
|
||||
page,
|
||||
search }: {
|
||||
name: "Publish" | "Review" | "Reject",
|
||||
page: string;
|
||||
search: string;
|
||||
}) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const isSearch = search ? `&search=${search}` : "";
|
||||
const response = await fetch(
|
||||
`/api/admin/donasi/status/${name}${isPage}${isSearch}`,
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
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);
|
||||
|
||||
|
||||
const response = await fetch(`/api/admin/donasi/kategori`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`
|
||||
|
||||
}
|
||||
})
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
const apiGetAdminDonasiById = async ({ id }: { id: string }) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const response = await fetch(`/api/admin/donasi/${id}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
const apiGetAdminAllDaftarDonatur = async ({
|
||||
id,
|
||||
page,
|
||||
status
|
||||
name,
|
||||
page,
|
||||
search,
|
||||
}: {
|
||||
id: string,
|
||||
page: string,
|
||||
status?: string | undefined
|
||||
name: "Publish" | "Review" | "Reject";
|
||||
page: string;
|
||||
search: string;
|
||||
}) => {
|
||||
try {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) {
|
||||
console.error("No token found");
|
||||
return null;
|
||||
}
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const isStatus = status ? `&status=${status}` : "";
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const response = await fetch(
|
||||
`/api/admin/donasi/${id}/donatur${isPage}${isStatus}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error("Error get daftar donatur:",
|
||||
errorData?.message || "Unknown error");
|
||||
return null;
|
||||
}
|
||||
|
||||
return response.json();
|
||||
} catch (error) {
|
||||
console.error("Error get daftar donatur:", error);
|
||||
throw error;
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const isSearch = search ? `&search=${search}` : "";
|
||||
const response = await fetch(
|
||||
`/api/admin/donasi/status/${name}${isPage}${isSearch}`,
|
||||
{
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
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);
|
||||
|
||||
const response = await fetch(`/api/admin/donasi/kategori`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
const apiGetAdminDonasiById = async ({ id }: { id: string }) => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const response = await fetch(`/api/admin/donasi/${id}`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
const apiGetAdminAllDaftarDonatur = async ({
|
||||
id,
|
||||
page,
|
||||
status,
|
||||
}: {
|
||||
id: string;
|
||||
page: string;
|
||||
status?: string | undefined;
|
||||
}) => {
|
||||
try {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) {
|
||||
console.error("No token found");
|
||||
return null;
|
||||
}
|
||||
|
||||
const isStatus = status ? `&status=${status}` : "";
|
||||
const isPage = page ? `?page=${page}` : "";
|
||||
const response = await fetch(
|
||||
`/api/admin/donasi/${id}/donatur${isPage}${isStatus}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Error get daftar donatur:",
|
||||
errorData?.message || "Unknown error"
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
return response.json();
|
||||
} catch (error) {
|
||||
console.error("Error get daftar donatur:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const apiGetAdminStatusDaftarDonatur = async () => {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const response = await fetch(`/api/master/status_transaksi`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
};
|
||||
|
||||
const apiGetAdminDonasiCountDonatur = async ({ id }: { id: string }) => {
|
||||
try {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const response = await fetch(`/api/master/status_transaksi`, {
|
||||
const response = await fetch(`/api/admin/donasi/${id}/count`, {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Error get count donatur:",
|
||||
errorData?.message || "Unknown error"
|
||||
);
|
||||
return null;
|
||||
}
|
||||
const data = await response.json().catch(() => null);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error get count donatur:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
const apiGetAdminDonasiPencairan = async ({
|
||||
id,
|
||||
page,
|
||||
}: {
|
||||
id: string;
|
||||
page: string;
|
||||
}) => {
|
||||
try {
|
||||
const { token } = await fetch("/api/get-cookie").then((res) => res.json());
|
||||
if (!token) return await token.json().catch(() => null);
|
||||
|
||||
const response = await fetch(
|
||||
`/api/admin/donasi/${id}/pencairan?page=${page}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`
|
||||
}
|
||||
})
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
if (!response.ok) {
|
||||
const errorData = await response.json().catch(() => null);
|
||||
console.error(
|
||||
"Error get pencairan donasi:",
|
||||
errorData?.message || "Unknown error"
|
||||
);
|
||||
return null;
|
||||
}
|
||||
const data = await response.json().catch(() => null);
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error("Error get pencairan donasi:", error);
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { AspectRatio, Box, Image, Paper, Stack } from "@mantine/core";
|
||||
import Admin_ComponentBackButton from "../../_admin_global/back_button";
|
||||
import { RouterAdminDonasi_OLD } from "@/lib/router_hipmi/router_admin";
|
||||
import { RouterDonasi } from "@/lib/router_hipmi/router_donasi";
|
||||
import { Stack } from "@mantine/core";
|
||||
import { Admin_ComponentPreviewImageAdmin } from "../../_admin_global/comp_preview_image_admin";
|
||||
|
||||
export default function AdminDonasi_BuktiTransferPencairan({
|
||||
imageId,
|
||||
@@ -13,36 +11,8 @@ export default function AdminDonasi_BuktiTransferPencairan({
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<Admin_ComponentBackButton />
|
||||
<BuktiTransfer imageId={imageId} />
|
||||
<Admin_ComponentPreviewImageAdmin fileId={imageId} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function BuktiTransfer({ imageId }: { imageId: string }) {
|
||||
return (
|
||||
<>
|
||||
<Paper withBorder p={"lg"} bg={"gray.3"}>
|
||||
<AspectRatio ratio={2 / 1} mx="auto">
|
||||
<Image
|
||||
alt="Foto"
|
||||
src={RouterDonasi.api_gambar_pencairan + `${imageId}`}
|
||||
/>
|
||||
</AspectRatio>
|
||||
{/* <AspectRatio ratio={1 / 1} mah={500} p={"lg"} bg={"cyan"}>
|
||||
<Paper bg={"grape"} h={"100%"}>
|
||||
<Image
|
||||
// height={500}
|
||||
// width={"100%"}
|
||||
alt="Foto"
|
||||
src={
|
||||
RouterAdminDonasi_OLD.api_gambar_bukti_transfer + `${imageId}`
|
||||
}
|
||||
/>
|
||||
</Paper>
|
||||
</AspectRatio> */}
|
||||
</Paper>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user