Merge pull request #275 from bipproduction/Nico/04-feb-25
API Table Investasi Admin
This commit is contained in:
@@ -49,6 +49,7 @@ import adminNotifikasi_funCreateToUser from "../../notifikasi/fun/create/fun_cre
|
||||
import { adminEvent_funGetListReview } from "../fun";
|
||||
import { AdminEvent_funEditStatusPublishById } from "../fun/edit/fun_edit_status_publish_by_id";
|
||||
import { AdminEvent_funEditCatatanById } from "../fun/edit/fun_edit_status_reject_by_id";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
|
||||
export default function AdminEvent_ComponentTableReview() {
|
||||
const [data, setData] = useState<MODEL_EVENT[] | null>(null);
|
||||
@@ -261,28 +262,28 @@ export default function AdminEvent_ComponentTableReview() {
|
||||
return data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text>{e?.Author?.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text lineClamp={2}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text>{e.lokasi}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text>{e.EventMaster_TipeAcara.name}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
@@ -297,7 +298,7 @@ export default function AdminEvent_ComponentTableReview() {
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
@@ -313,7 +314,7 @@ export default function AdminEvent_ComponentTableReview() {
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Center c={AdminColor.white} w={400}>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
maxHeight={50}
|
||||
@@ -371,7 +372,7 @@ export default function AdminEvent_ComponentTableReview() {
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
name="Review"
|
||||
color={"orange.5"}
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<TextInput
|
||||
disabled={!data}
|
||||
@@ -387,7 +388,7 @@ export default function AdminEvent_ComponentTableReview() {
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
) : (
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
||||
{isShowReload && (
|
||||
<Affix position={{ top: rem(200) }} w={"100%"}>
|
||||
<Center>
|
||||
@@ -416,35 +417,33 @@ export default function AdminEvent_ComponentTableReview() {
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
striped
|
||||
highlightOnHover
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Username</Center>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Judul</Center>
|
||||
<Center c={AdminColor.white}>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Lokasi</Center>
|
||||
<Center c={AdminColor.white}>Lokasi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tipe Acara</Center>
|
||||
<Center c={AdminColor.white}>Tipe Acara</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal & Waktu Mulai</Center>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Mulai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal & Waktu Selesai</Center>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Selesai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
<Center c={AdminColor.white}>Deskripsi</Center>
|
||||
</th>
|
||||
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -137,20 +137,20 @@ function TableStatus() {
|
||||
return data.map((e, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>{e?.Author?.username}</Center>
|
||||
<Center c={AdminColor.white} w={200}>{e?.Author?.username}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>{e.title}</Center>
|
||||
<Center c={AdminColor.white} w={200}>{e.title}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>{e.lokasi}</Center>
|
||||
<Center c={AdminColor.white} w={200}>{e.lokasi}</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>{e.EventMaster_TipeAcara.name}</Center>
|
||||
<Center c={AdminColor.white} w={200}>{e.EventMaster_TipeAcara.name}</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
@@ -165,7 +165,7 @@ function TableStatus() {
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Center c={AdminColor.white} w={200}>
|
||||
<Text align="center">
|
||||
{new Intl.DateTimeFormat("id-ID", {
|
||||
dateStyle: "full",
|
||||
@@ -181,7 +181,7 @@ function TableStatus() {
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={500}>
|
||||
<Center c={AdminColor.white} w={500}>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
maxHeight={50}
|
||||
@@ -193,7 +193,7 @@ function TableStatus() {
|
||||
</td>
|
||||
<td>
|
||||
{" "}
|
||||
<Center w={400}>
|
||||
<Center c={AdminColor.white} w={400}>
|
||||
<Spoiler
|
||||
hideLabel="sembunyikan"
|
||||
maxHeight={50}
|
||||
@@ -227,7 +227,7 @@ function TableStatus() {
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
<ComponentAdminGlobal_TitlePage
|
||||
name="Reject"
|
||||
color={"red.5"}
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<TextInput
|
||||
disabled={!data}
|
||||
@@ -244,44 +244,43 @@ function TableStatus() {
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
) : (
|
||||
<Paper p={"md"} withBorder shadow="lg" h={"80vh"}>
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"}>
|
||||
<Table
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
p={"md"}
|
||||
w={1500}
|
||||
striped
|
||||
highlightOnHover
|
||||
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<Center>Username</Center>
|
||||
<Center c={AdminColor.white}>Username</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Judul</Center>
|
||||
<Center c={AdminColor.white}>Judul</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Lokasi</Center>
|
||||
<Center c={AdminColor.white}>Lokasi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tipe Acara</Center>
|
||||
<Center c={AdminColor.white}>Tipe Acara</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal & Waktu Mulai</Center>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Mulai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Tanggal & Waktu Selesai</Center>
|
||||
<Center c={AdminColor.white}>Tanggal & Waktu Selesai</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Cacatan</Center>
|
||||
<Center c={AdminColor.white}>Cacatan</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Deskripsi</Center>
|
||||
<Center c={AdminColor.white}>Deskripsi</Center>
|
||||
</th>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
<Center c={AdminColor.white}>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
export {
|
||||
apiGetAdminInvestasiCountDashboard,
|
||||
apiGetAdminInvestasiByStatus,
|
||||
}
|
||||
const apiGetAdminInvestasiCountDashboard = 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/investasi/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 apiGetAdminInvestasiByStatus = async ({ status, page, search }: {
|
||||
status: "Publish" | "Review" | "Reject",
|
||||
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}` : "";
|
||||
const isSearch = search ? `&search=${search}` : "";
|
||||
const response = await fetch(`/api/admin/investasi/${status}${isPage}${isSearch}`, {
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
Accept: "application/json",
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
Authorization: `Bearer ${token}`,
|
||||
},
|
||||
})
|
||||
console.log("Ini response", response)
|
||||
return await response.json().catch(() => null);
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
const apiGetInvestasiCountDashboard = 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/investasi/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);
|
||||
};
|
||||
|
||||
export default apiGetInvestasiCountDashboard;
|
||||
@@ -25,6 +25,10 @@ import { adminInvestasi_funGetAllPublish } from "../fun/get/get_all_publish";
|
||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import { AccentColor, AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { apiGetAdminInvestasiByStatus } from "../_lib/api_fetch_admin_investasi";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export default function Admin_TablePublishInvestasi({
|
||||
dataInvestsi,
|
||||
@@ -50,83 +54,116 @@ function TableView({ listData }: { listData: any }) {
|
||||
const [isSearch, setSearch] = useState("");
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [idData, setIdData] = useState("");
|
||||
const [origin, setOrigin] = useState("");
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
useShallowEffect(() => {
|
||||
if (typeof window !== "undefined") {
|
||||
setOrigin(window.location.origin);
|
||||
}
|
||||
}, [])
|
||||
|
||||
useShallowEffect(() => {
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
const response = await apiGetAdminInvestasiByStatus({
|
||||
status: "Publish",
|
||||
page: `${activePage}`,
|
||||
search: isSearch,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data table publish", error);
|
||||
setData([]);
|
||||
}
|
||||
};
|
||||
|
||||
loadInitialData();
|
||||
}, [activePage, isSearch]);
|
||||
const onSearch = async (searchTerm: string) => {
|
||||
setSearch(searchTerm);
|
||||
setActivePage(1);
|
||||
const loadData = await adminInvestasi_funGetAllPublish({
|
||||
page: 1,
|
||||
search: s,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminInvestasi_funGetAllPublish({
|
||||
search: isSearch,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
const onPageClick = (page: number) => {
|
||||
setActivePage(page)
|
||||
}
|
||||
|
||||
const tableBody = data.map((e) => (
|
||||
<tr key={e.id}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.author.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>{_.toNumber(e.progress).toFixed(2)} %</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumFractionDigits: 10,
|
||||
}).format(+e.sisaLembar)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumFractionDigits: 10,
|
||||
}).format(+e.totalLembar)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.Investasi_Invoice.length}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Button
|
||||
loading={isLoading && idData === e.id}
|
||||
loaderPosition="center"
|
||||
bg={"green"}
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
leftIcon={<IconEyeCheck size={20} />}
|
||||
onClick={() => {
|
||||
setIdData(e.id);
|
||||
setLoading(true);
|
||||
router.push(RouterAdminInvestasi.detail_publish + `${e.id}`);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
const renderTableBody = () => {
|
||||
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, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.author.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>{_.toNumber(e.progress).toFixed(2)} %</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumFractionDigits: 10,
|
||||
}).format(+e.sisaLembar)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
{new Intl.NumberFormat("id-ID", {
|
||||
maximumFractionDigits: 10,
|
||||
}).format(+e.totalLembar)}
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.Investasi_Invoice.length}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Button
|
||||
loading={isLoading && idData === e.id}
|
||||
loaderPosition="center"
|
||||
bg={"green"}
|
||||
color="green"
|
||||
radius={"xl"}
|
||||
leftIcon={<IconEyeCheck size={20} />}
|
||||
onClick={() => {
|
||||
setIdData(e.id);
|
||||
setLoading(true);
|
||||
router.push(RouterAdminInvestasi.detail_publish + `${e.id}`);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -164,8 +201,8 @@ function TableView({ listData }: { listData: any }) {
|
||||
/>
|
||||
</Group> */}
|
||||
|
||||
{_.isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width={"100%"} />
|
||||
) : (
|
||||
<Paper bg={AdminColor.softBlue} p={"md"} shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"} offsetScrollbars>
|
||||
@@ -203,7 +240,7 @@ function TableView({ listData }: { listData: any }) {
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{tableBody}</tbody>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
|
||||
@@ -31,162 +31,186 @@ import { RouterAdminInvestasi } from "@/app/lib/router_admin/router_admin_invest
|
||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||
import { MainColor } from "@/app_modules/_global/color";
|
||||
import { AccentColor, AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import { apiGetAdminInvestasiByStatus } from "../_lib/api_fetch_admin_investasi";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export default function Admin_TableRejectInvestasi({
|
||||
dataInvestsi,
|
||||
}: {
|
||||
dataInvestsi: any[];
|
||||
}) {
|
||||
const [investasi, setInvestasi] = useState(dataInvestsi);
|
||||
const router = useRouter();
|
||||
|
||||
export default function Admin_TableRejectInvestasi() {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Investasi" />
|
||||
<TableView listData={dataInvestsi} />
|
||||
<TableView/>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
|
||||
const tableBody = investasi.map((e) =>
|
||||
e.MasterStatusInvestasi.id === "4" ? (
|
||||
<tr key={e.id}>
|
||||
<td>
|
||||
<Group position="left">
|
||||
<Avatar variant="outline" radius={"xl"} />
|
||||
<Text>{e.author.username}</Text>
|
||||
</Group>
|
||||
</td>
|
||||
<td>{_.capitalize(e.title)}</td>
|
||||
<td>{e.catatan}</td>
|
||||
<td>
|
||||
<Center>
|
||||
<Tooltip label="Konfirmasi" withArrow position="bottom">
|
||||
<ActionIcon
|
||||
variant="transparent"
|
||||
onClick={() =>
|
||||
router.push(RouterAdminInvestasi_OLD.konfirmasi + `${e.id}`)
|
||||
}
|
||||
>
|
||||
<IconEdit color="green" />
|
||||
</ActionIcon>
|
||||
</Tooltip>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
""
|
||||
)
|
||||
);
|
||||
// const tableBody = investasi.map((e) =>
|
||||
// e.MasterStatusInvestasi.id === "4" ? (
|
||||
// <tr key={e.id}>
|
||||
// <td>
|
||||
// <Group position="left">
|
||||
// <Avatar variant="outline" radius={"xl"} />
|
||||
// <Text>{e.author.username}</Text>
|
||||
// </Group>
|
||||
// </td>
|
||||
// <td>{_.capitalize(e.title)}</td>
|
||||
// <td>{e.catatan}</td>
|
||||
// <td>
|
||||
// <Center>
|
||||
// <Tooltip label="Konfirmasi" withArrow position="bottom">
|
||||
// <ActionIcon
|
||||
// variant="transparent"
|
||||
// onClick={() =>
|
||||
// router.push(RouterAdminInvestasi_OLD.konfirmasi + `${e.id}`)
|
||||
// }
|
||||
// >
|
||||
// <IconEdit color="green" />
|
||||
// </ActionIcon>
|
||||
// </Tooltip>
|
||||
// </Center>
|
||||
// </td>
|
||||
// </tr>
|
||||
// ) : (
|
||||
// ""
|
||||
// )
|
||||
// );
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ActionIcon
|
||||
variant="outline"
|
||||
onClick={() => router.push(RouterAdminInvestasi_OLD.main_investasi)}
|
||||
>
|
||||
<IconChevronLeft />
|
||||
</ActionIcon>
|
||||
<Box>
|
||||
<ScrollArea w={"100%"}>
|
||||
<Badge color="red" variant="light" radius={0} size={"xl"}>
|
||||
Reject
|
||||
</Badge>
|
||||
<Table
|
||||
withBorder
|
||||
highlightOnHover
|
||||
verticalSpacing={"md"}
|
||||
horizontalSpacing={"md"}
|
||||
>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Username</th>
|
||||
<th>Nama Proyek Investasi</th>
|
||||
<th>Catatan</th>
|
||||
<th>
|
||||
<Center>Aksi</Center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{tableBody}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
</Box>
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
// return (
|
||||
// <>
|
||||
// <Stack>
|
||||
// <ActionIcon
|
||||
// variant="outline"
|
||||
// onClick={() => router.push(RouterAdminInvestasi_OLD.main_investasi)}
|
||||
// >
|
||||
// <IconChevronLeft />
|
||||
// </ActionIcon>
|
||||
// <Box>
|
||||
// <ScrollArea w={"100%"}>
|
||||
// <Badge color="red" variant="light" radius={0} size={"xl"}>
|
||||
// Reject
|
||||
// </Badge>
|
||||
// <Table
|
||||
// withBorder
|
||||
// highlightOnHover
|
||||
// verticalSpacing={"md"}
|
||||
// horizontalSpacing={"md"}
|
||||
// >
|
||||
// <thead>
|
||||
// <tr>
|
||||
// <th>Username</th>
|
||||
// <th>Nama Proyek Investasi</th>
|
||||
// <th>Catatan</th>
|
||||
// <th>
|
||||
// <Center>Aksi</Center>
|
||||
// </th>
|
||||
// </tr>
|
||||
// </thead>
|
||||
// <tbody>{tableBody}</tbody>
|
||||
// </Table>
|
||||
// </ScrollArea>
|
||||
// </Box>
|
||||
// </Stack>
|
||||
// </>
|
||||
// );
|
||||
}
|
||||
|
||||
function TableView({ listData }: { listData: any }) {
|
||||
function TableView() {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_INVESTASI[]>(listData.data);
|
||||
const [nPage, setNPage] = useState(listData.nPage);
|
||||
const [data, setData] = useState<MODEL_INVESTASI[] | null > (null);
|
||||
const [nPage, setNPage] = useState(1);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
const [idData, setIdData] = useState("");
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
|
||||
useShallowEffect(() => {
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
const response = await apiGetAdminInvestasiByStatus({
|
||||
status: "Reject",
|
||||
page: `${activePage}`,
|
||||
search: isSearch,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data.data) {
|
||||
setData(response.data.data);
|
||||
setNPage(response.data.nPage || 1);
|
||||
} else {
|
||||
console.error("Invalid data format recieved:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data reject", error);
|
||||
setData([]);
|
||||
}
|
||||
}
|
||||
loadInitialData();
|
||||
}, [activePage, isSearch]);
|
||||
const onSearch = async (searchTerm: string) => {
|
||||
setSearch(searchTerm);
|
||||
setActivePage(1);
|
||||
const loadData = await adminInvestasi_funGetAllReject({
|
||||
page: 1,
|
||||
search: s,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminInvestasi_funGetAllReject({
|
||||
search: isSearch,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
async function onPageClick(page: number) {
|
||||
setActivePage(page);
|
||||
}
|
||||
|
||||
const tableBody = data.map((e) => (
|
||||
<tr key={e.id}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.author.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.catatan}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
const renderTableBody = () => {
|
||||
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, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.author.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={400}>
|
||||
<Text c={AccentColor.white} lineClamp={1}>{e.catatan}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Button
|
||||
loading={isLoading && idData === e.id}
|
||||
loaderPosition="center"
|
||||
color="green"
|
||||
leftIcon={<IconEyeCheck size={20}/>}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setIdData(e.id);
|
||||
setLoading(true);
|
||||
router.push(RouterAdminInvestasi.detail_reject + `${e.id}`);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
}
|
||||
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Button
|
||||
loading={isLoading && idData === e.id}
|
||||
loaderPosition="center"
|
||||
color="green"
|
||||
leftIcon={<IconEyeCheck size={20}/>}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setIdData(e.id);
|
||||
setLoading(true);
|
||||
router.push(RouterAdminInvestasi.detail_reject + `${e.id}`);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -224,8 +248,8 @@ function TableView({ listData }: { listData: any }) {
|
||||
/>
|
||||
</Group> */}
|
||||
|
||||
{_.isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width="100%" />
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
||||
<ScrollArea w={"100%"} h={"90%"} offsetScrollbars>
|
||||
@@ -253,7 +277,7 @@ function TableView({ listData }: { listData: any }) {
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{tableBody}</tbody>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
|
||||
@@ -30,26 +30,25 @@ import ComponentAdminGlobal_TampilanRupiahDonasi from "../../_admin_global/tampi
|
||||
import { adminInvestasi_funGetAllReview } from "../fun/get/get_all_review";
|
||||
import { ComponentAdminGlobal_TitlePage } from "../../_admin_global/_component";
|
||||
import { AdminColor } from "@/app_modules/_global/color/color_pallet";
|
||||
import { apiGetAdminInvestasiByStatus } from "../_lib/api_fetch_admin_investasi";
|
||||
import { clientLogger } from "@/util/clientLogger";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
|
||||
export default function Admin_TableReviewInvestasi({
|
||||
dataInvestsi,
|
||||
}: {
|
||||
dataInvestsi: any[];
|
||||
}) {
|
||||
export default function Admin_TableReviewInvestasi() {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentAdminGlobal_HeaderTamplate name="Investasi" />
|
||||
<TableView listData={dataInvestsi} />
|
||||
<TableView />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function TableView({ listData }: { listData: any }) {
|
||||
function TableView() {
|
||||
const router = useRouter();
|
||||
const [data, setData] = useState<MODEL_INVESTASI[]>(listData.data);
|
||||
const [nPage, setNPage] = useState(listData.nPage);
|
||||
const [data, setData] = useState<MODEL_INVESTASI[] | null>(null);
|
||||
const [nPage, setNPage] = useState<number>(1);
|
||||
const [activePage, setActivePage] = useState(1);
|
||||
const [isSearch, setSearch] = useState("");
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
@@ -62,94 +61,108 @@ function TableView({ listData }: { listData: any }) {
|
||||
const [isLoadingReload, setLoadingReload] = useState(false);
|
||||
|
||||
useShallowEffect(() => {
|
||||
if (isAdminInvestasi_TriggerReview) {
|
||||
setIsShowReload(false);
|
||||
setIsAdminInvestasi_TriggerReview(false)
|
||||
}
|
||||
}, [isAdminInvestasi_TriggerReview]);
|
||||
loadInitialData();
|
||||
}, [activePage, isSearch]);
|
||||
const loadInitialData = async () => {
|
||||
try {
|
||||
const response = await apiGetAdminInvestasiByStatus({
|
||||
status: "Review",
|
||||
page: `${activePage}`,
|
||||
search: isSearch,
|
||||
});
|
||||
|
||||
if (response?.success && response?.data?.data) {
|
||||
setData(response.data.data)
|
||||
setNPage(response.data.nPage || 1)
|
||||
} else {
|
||||
console.error("Invalid data format received:", response);
|
||||
setData([]);
|
||||
}
|
||||
} catch (error) {
|
||||
clientLogger.error("Error get data table review", error);
|
||||
setData([]);
|
||||
}
|
||||
}
|
||||
const onSearch = async (searchTerm: string) => {
|
||||
setSearch(searchTerm);
|
||||
setActivePage(1);
|
||||
}
|
||||
|
||||
const onPageClick = (page: number) => {
|
||||
setActivePage(page);
|
||||
}
|
||||
async function onLoadData() {
|
||||
const loadData = await adminInvestasi_funGetAllReview({ page: 1 });
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
setLoadingReload(false);
|
||||
loadInitialData();
|
||||
setLoading(false);
|
||||
setIsShowReload(false);
|
||||
setIsAdminInvestasi_TriggerReview(false);
|
||||
}
|
||||
|
||||
async function onSearch(s: string) {
|
||||
setSearch(s);
|
||||
setActivePage(1);
|
||||
const loadData = await adminInvestasi_funGetAllReview({
|
||||
page: 1,
|
||||
search: s,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
const renderTableBody = () => {
|
||||
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, i) => (
|
||||
<tr key={i}>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Text lineClamp={1}>{e.author.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={400}>
|
||||
<Text lineClamp={1}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Text lineClamp={1}>{e.roi} %</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<ComponentAdminGlobal_TampilanRupiahDonasi
|
||||
nominal={_.toNumber(e.targetDana)}
|
||||
/>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<ComponentAdminGlobal_TampilanRupiahDonasi
|
||||
nominal={_.toNumber(e.hargaLembar)}
|
||||
/>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Button
|
||||
loading={isLoading && idData === e.id}
|
||||
loaderPosition="center"
|
||||
color="green"
|
||||
leftIcon={<IconEyeCheck size={20} />}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setIdData(e.id);
|
||||
setLoading(true);
|
||||
router.push(RouterAdminInvestasi_OLD.konfirmasi + `${e.id}`);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
}
|
||||
|
||||
async function onPageClick(p: any) {
|
||||
setActivePage(p);
|
||||
const loadData = await adminInvestasi_funGetAllReview({
|
||||
search: isSearch,
|
||||
page: p,
|
||||
});
|
||||
setData(loadData.data as any);
|
||||
setNPage(loadData.nPage);
|
||||
}
|
||||
|
||||
const tableBody = data.map((e) => (
|
||||
<tr key={e.id}>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Text lineClamp={1}>{e.author.username}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={400}>
|
||||
<Text lineClamp={1}>{e.title}</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<Text lineClamp={1}>{e.roi} %</Text>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<ComponentAdminGlobal_TampilanRupiahDonasi
|
||||
nominal={_.toNumber(e.targetDana)}
|
||||
/>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center c={AccentColor.white} w={200}>
|
||||
<ComponentAdminGlobal_TampilanRupiahDonasi
|
||||
nominal={_.toNumber(e.hargaLembar)}
|
||||
/>
|
||||
</Center>
|
||||
</td>
|
||||
<td>
|
||||
<Center w={200}>
|
||||
<Button
|
||||
loading={isLoading && idData === e.id}
|
||||
loaderPosition="center"
|
||||
color="green"
|
||||
leftIcon={<IconEyeCheck size={20}/>}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
setIdData(e.id);
|
||||
setLoading(true);
|
||||
router.push(RouterAdminInvestasi_OLD.konfirmasi + `${e.id}`);
|
||||
}}
|
||||
>
|
||||
Detail
|
||||
</Button>
|
||||
</Center>
|
||||
</td>
|
||||
</tr>
|
||||
));
|
||||
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"xs"} h={"100%"}>
|
||||
@@ -158,13 +171,13 @@ function TableView({ listData }: { listData: any }) {
|
||||
color={AdminColor.softBlue}
|
||||
component={
|
||||
<TextInput
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Cari nama proyek"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
icon={<IconSearch size={20} />}
|
||||
radius={"xl"}
|
||||
placeholder="Cari nama proyek"
|
||||
onChange={(val) => {
|
||||
onSearch(val.currentTarget.value);
|
||||
}}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
{/* <Group
|
||||
@@ -186,8 +199,8 @@ function TableView({ listData }: { listData: any }) {
|
||||
/>
|
||||
</Group> */}
|
||||
|
||||
{_.isEmpty(data) ? (
|
||||
<ComponentAdminGlobal_IsEmptyData />
|
||||
{!data ? (
|
||||
<CustomSkeleton height={"80vh"} width={"100%"} />
|
||||
) : (
|
||||
<Paper p={"md"} bg={AdminColor.softBlue} shadow="lg" h={"80vh"}>
|
||||
{isShowReload && (
|
||||
@@ -245,7 +258,7 @@ function TableView({ listData }: { listData: any }) {
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>{tableBody}</tbody>
|
||||
<tbody>{renderTableBody()}</tbody>
|
||||
</Table>
|
||||
</ScrollArea>
|
||||
<Center mt={"xl"}>
|
||||
|
||||
@@ -50,7 +50,8 @@ import { clientLogger } from "@/util/clientLogger";
|
||||
import CustomSkeleton from "@/app_modules/components/CustomSkeleton";
|
||||
import global_limit from "@/app/lib/limit";
|
||||
import { useShallowEffect } from "@mantine/hooks";
|
||||
import apiGetInvestasiCountDashboard from "../_lib/api_fetch_count_status";
|
||||
import { apiGetAdminInvestasiCountDashboard } from "../_lib/api_fetch_admin_investasi";
|
||||
|
||||
|
||||
export default function Admin_Investasi({
|
||||
listInvestasi,
|
||||
@@ -88,7 +89,7 @@ export default function Admin_Investasi({
|
||||
async function onLoadCountPublish() {
|
||||
try {
|
||||
|
||||
const response = await apiGetInvestasiCountDashboard({
|
||||
const response = await apiGetAdminInvestasiCountDashboard({
|
||||
name: "Publish",
|
||||
});
|
||||
|
||||
@@ -103,7 +104,7 @@ export default function Admin_Investasi({
|
||||
}
|
||||
async function onLoadCountReview() {
|
||||
try {
|
||||
const response = await apiGetInvestasiCountDashboard({
|
||||
const response = await apiGetAdminInvestasiCountDashboard({
|
||||
name: "Review",
|
||||
});
|
||||
|
||||
@@ -116,7 +117,7 @@ export default function Admin_Investasi({
|
||||
}
|
||||
async function onLoadCountReject() {
|
||||
try {
|
||||
const response = await apiGetInvestasiCountDashboard({
|
||||
const response = await apiGetAdminInvestasiCountDashboard({
|
||||
name: "Reject",
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user