diff --git a/app/(application)/(user)/investment/(tabs)/index.tsx b/app/(application)/(user)/investment/(tabs)/index.tsx index e293ce9..0df5a60 100644 --- a/app/(application)/(user)/investment/(tabs)/index.tsx +++ b/app/(application)/(user)/investment/(tabs)/index.tsx @@ -1,23 +1,14 @@ import { - BaseBox, FloatingButton, - Grid, LoaderCustom, - ProgressCustom, - StackCustom, - TextCustom, - ViewWrapper, + ViewWrapper } from "@/components"; -import API_STRORAGE from "@/constants/base-url-api-strorage"; -import DUMMY_IMAGE from "@/constants/dummy-image-value"; +import NoDataText from "@/components/_ShareComponent/NoDataText"; +import Investment_BoxBerandaSection from "@/screens/Invesment/BoxBerandaSection"; import { apiInvestmentGetAll } from "@/service/api-client/api-investment"; -import { Ionicons } from "@expo/vector-icons"; -import dayjs from "dayjs"; -import { Image } from "expo-image"; import { router, useFocusEffect } from "expo-router"; import _ from "lodash"; import { useCallback, useState } from "react"; -import { View } from "react-native"; export default function InvestmentBursa() { const [list, setList] = useState(null); @@ -33,7 +24,7 @@ export default function InvestmentBursa() { try { setLoadingList(true); const response = await apiInvestmentGetAll(); - console.log("[DATA LIST]", JSON.stringify(response.data, null, 2)); + // console.log("[DATA LIST]", JSON.stringify(response.data, null, 2)); setList(response.data); } catch (error) { console.log("[ERROR]", error); @@ -52,95 +43,12 @@ export default function InvestmentBursa() { {loadingList ? ( ) : _.isEmpty(list) ? ( - Belum ada data + ) : ( list?.map((item: any, index: number) => ( - - - - - - - - - - - {item.title} - - {Number(item?.pencarianInvestor) - - dayjs().diff(dayjs(item.countDown), "days") <= - 0 ? ( - - - - Periode Investasi Selesai - - - ) : ( - - Sisa waktu:{" "} - {Number(item?.pencarianInvestor) - - dayjs().diff(dayjs(item.countDown), "days")}{" "} - hari - - )} - - - - + )) )} ); } - -// -// Progress 70% -// - -// Success Progress -// - -// Warning Progress (small) -// - -// Error Indeterminate -// - -// Custom Radius -// - -// - -// - -// - -// -// ; diff --git a/app/(application)/admin/investment/[id]/[status]/index.tsx b/app/(application)/admin/investment/[id]/[status]/index.tsx index ea75229..b1f7dd2 100644 --- a/app/(application)/admin/investment/[id]/[status]/index.tsx +++ b/app/(application)/admin/investment/[id]/[status]/index.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react-hooks/exhaustive-deps */ import { ActionIcon, AlertDefaultSystem, @@ -11,7 +12,7 @@ import { Spacing, StackCustom, TextCustom, - ViewWrapper + ViewWrapper, } from "@/components"; import { IconProspectus } from "@/components/_Icon"; import { IconDot, IconList } from "@/components/_Icon/IconComponent"; @@ -19,75 +20,141 @@ import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButt import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject"; import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview"; import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8"; +import ReportBox from "@/components/Box/ReportBox"; import { MainColor } from "@/constants/color-palet"; import { ICON_SIZE_BUTTON } from "@/constants/constans-value"; -import { router, useLocalSearchParams } from "expo-router"; +import { + apiAdminInvestasiUpdateByStatus, + apiAdminInvestmentDetailById, +} from "@/service/api-admin/api-admin-investment"; +import { colorBadgeStatus } from "@/utils/colorBadge"; +import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay"; +import { router, useFocusEffect, useLocalSearchParams } from "expo-router"; import _ from "lodash"; import React from "react"; +import Toast from "react-native-toast-message"; export default function AdminInvestmentDetail() { const { id, status } = useLocalSearchParams(); const [openDrawer, setOpenDrawer] = React.useState(false); - const colorBadge = () => { - if (status === "publish") { - return MainColor.green; - } else if (status === "review") { - return MainColor.orange; - } else if (status === "reject") { - return MainColor.red; - } else { - return MainColor.placeholder; + const [data, setData] = React.useState(null); + const [isLoading, setLoading] = React.useState(false); + + useFocusEffect( + React.useCallback(() => { + onLoadData(); + }, [id]) + ); + + const onLoadData = async () => { + try { + const response = await apiAdminInvestmentDetailById({ id: id as string }); + console.log("[DATA]", JSON.stringify(response, null, 2)); + if (response.success) { + setData(response.data); + } + } catch (error) { + console.log(error); } }; const listData = [ { label: "Username", - value: `Bagas Banuna ${id}`, + value: (data && data?.author?.username) || "-", }, { label: "Judul", - value: `Donasi Lorem ipsum dolor sit amet, consectetur adipisicing elit.`, + value: (data && data?.title) || "-", }, { label: "Status", - value: ( - - {_.startCase(status as string)} - - ), + value: + data && data?.MasterStatusInvestasi?.name ? ( + + {_.startCase(data?.MasterStatusInvestasi?.name as string)} + + ) : ( + "-" + ), }, { label: "Dana Dibutuhkan", - value: "Rp 10.000.000", + value: `Rp. ${ + (data && data?.targetDana && formatCurrencyDisplay(data?.targetDana)) || + "-" + }`, }, { label: "Harga Perlembar", - value: "Rp 2500", + value: `Rp. ${ + (data && + data?.hargaLembar && + formatCurrencyDisplay(data?.hargaLembar)) || + "-" + }`, }, { label: "Total Lembar", - value: "2490 lembar", + value: + (data && + data?.totalLembar && + formatCurrencyDisplay(data?.totalLembar)) || + "-", }, { label: "ROI", - value: "4 %", + value: `${(data && data?.roi && data?.roi) || 0} %`, }, { label: "Pembagian Deviden", - value: "3 bulan", + value: (data && data?.MasterPembagianDeviden?.name) + " bulan" || "-", }, { label: "Jadwal Pembagian", - value: "Selamanya", + value: (data && data?.MasterPeriodeDeviden?.name) || "-", }, { label: "Pencarian Investor", - value: "30 Hari", + value: (data && data?.MasterPencarianInvestor?.name) + " hari" || "-", }, ]; + const handlerSubmitPublish = async () => { + try { + setLoading(true); + const response = await apiAdminInvestasiUpdateByStatus({ + id: id as string, + status: "publish", + data: data, + }); + + console.log("[RESPONSE]", JSON.stringify(response, null, 2)); + if (!response.success) { + Toast.show({ + type: "error", + text1: "Gagal mempublikasikan data", + }); + return; + } + + Toast.show({ + type: "success", + text1: "Berhasil mempublikasikan data", + }); + router.replace(`/admin/investment/publish/status`); + } catch (error) { + console.log("[ERROR]", error); + } finally { + setLoading(false); + } + }; + const rightComponent = ( } @@ -126,7 +193,7 @@ export default function AdminInvestmentDetail() { - + {listData.map((item, i) => ( } onPress={() => { - router.push(`/(application)/(file)/${id}`); + router.push( + `/(application)/(file)/${data?.prospektusFileId}` + ); }} > Preview @@ -161,46 +230,66 @@ export default function AdminInvestmentDetail() { label={File Dokumen} value={ - {Array.from({ length: 5 }).map((_, i) => ( - - } - onPress={() => { - router.push(`/(application)/(file)/${id}`); - }} - > - Dokumen {i + 1} - - ))} + {_.isEmpty(data?.DokumenInvestasi) ? ( + - + ) : ( + data?.DokumenInvestasi?.map((item: any, index: number) => { + const titleFix = item?.title?.substring(0, 10) || ""; + + return ( + + } + onPress={() => { + router.push( + `/(application)/(file)/${item?.fileId}` + ); + }} + > + + {titleFix}... + + + ); + }) + )} } /> + {data && + data?.catatan && + (status === "review" || status === "reject") && ( + + )} + {status === "review" && ( { AlertDefaultSystem({ title: "Publish", message: "Apakah anda yakin ingin mempublikasikan data ini?", textLeft: "Batal", textRight: "Ya", - onPressLeft: () => { - router.back(); - }, onPressRight: () => { - router.back(); + handlerSubmitPublish(); }, }); }} onReject={() => { - router.push(`/admin/investment/${id}/reject-input`); + router.push( + `/admin/investment/${id}/reject-input?status=${_.lowerCase( + data?.MasterStatusInvestasi?.name + )}` + ); }} /> )} diff --git a/app/(application)/admin/investment/[id]/[status]/transaction-detail.tsx b/app/(application)/admin/investment/[id]/[status]/transaction-detail.tsx index c71cc13..0e7c48a 100644 --- a/app/(application)/admin/investment/[id]/[status]/transaction-detail.tsx +++ b/app/(application)/admin/investment/[id]/[status]/transaction-detail.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react-hooks/exhaustive-deps */ import { BadgeCustom, BaseBox, @@ -9,12 +10,38 @@ import { } from "@/components"; import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle"; import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8"; -import { MainColor } from "@/constants/color-palet"; -import dayjs from "dayjs"; -import { router, useLocalSearchParams } from "expo-router"; +import { apiAdminInvestmentGetOneInvoiceById } from "@/service/api-admin/api-admin-investment"; +import { colorBadgeTransaction } from "@/utils/colorBadge"; +import { dateTimeView } from "@/utils/dateTimeView"; +import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay"; +import { router, useFocusEffect, useLocalSearchParams } from "expo-router"; +import { useCallback, useState } from "react"; export default function AdminInvestmentTransactionDetail() { const { id } = useLocalSearchParams(); + console.log("[ID]", id); + + const [data, setData] = useState(null); + + useFocusEffect( + useCallback(() => { + onLoadData(); + }, [id]) + ); + + const onLoadData = async () => { + try { + const response = await apiAdminInvestmentGetOneInvoiceById({ + id: id as string, + }); + console.log("[RESPONSE]", JSON.stringify(response, null, 2)); + if (response.success) { + setData(response.data); + } + } catch (error) { + console.log("[ERROR]", error); + } + }; const buttonAction = ( @@ -25,30 +52,41 @@ export default function AdminInvestmentTransactionDetail() { const listData = [ { label: "Investor", - value: "Bagas Banuna", + value: data?.Author?.username || "-", }, { label: "Bank", - value: "BCA", + value: data?.MasterBank?.namaBank || "-", }, { label: "Jumlah Investasi", - value: "Rp. 1.000.000", + value: `Rp. ${formatCurrencyDisplay(data?.nominal) || "-"}`, }, { label: "Status", - value: Berhasil, + value: + data && data?.StatusInvoice?.name ? ( + + {data?.StatusInvoice?.name} + + ) : ( + "-" + ), }, { label: "Tanggal", - value: dayjs().format("DD-MM-YYYY HH:mm:ss"), + value: data && dateTimeView({ date: data?.createdAt }) || "-", }, { label: "Bukti Transfer", value: ( - router.push(`/(application)/(image)/preview-image/${id}`) + router.push(`/(application)/(image)/preview-image/${data?.imageId}`) } > Cek @@ -60,7 +98,9 @@ export default function AdminInvestmentTransactionDetail() { return ( <> } + headerComponent={ + + } footerComponent={buttonAction} > diff --git a/app/(application)/admin/investment/[id]/list-of-investor.tsx b/app/(application)/admin/investment/[id]/list-of-investor.tsx index c2b4194..bcd8ce5 100644 --- a/app/(application)/admin/investment/[id]/list-of-investor.tsx +++ b/app/(application)/admin/investment/[id]/list-of-investor.tsx @@ -1,7 +1,9 @@ +/* eslint-disable react-hooks/exhaustive-deps */ import { ActionIcon, BadgeCustom, CenterCustom, + LoaderCustom, SelectCustom, StackCustom, TextCustom, @@ -10,23 +12,100 @@ import { import { IconView } from "@/components/_Icon/IconComponent"; import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle"; import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan"; +import NoDataText from "@/components/_ShareComponent/NoDataText"; import { MainColor } from "@/constants/color-palet"; import { ICON_SIZE_BUTTON } from "@/constants/constans-value"; import { dummyMasterStatusTransaction } from "@/lib/dummy-data/_master/status-transaction"; -import { router, useLocalSearchParams } from "expo-router"; -import React from "react"; +import { apiAdminInvestmentListOfInvestor } from "@/service/api-admin/api-admin-investment"; +import { apiMasterTransaction } from "@/service/api-client/api-master"; +import { colorBadgeTransaction } from "@/utils/colorBadge"; +import { router, useFocusEffect, useLocalSearchParams } from "expo-router"; +import _ from "lodash"; +import React, { useEffect } from "react"; import { View } from "react-native"; import { Divider } from "react-native-paper"; export default function AdminInvestmentListOfInvestor() { const { id } = useLocalSearchParams(); + console.log("[ID]", id); + + const [listData, setListData] = React.useState(null); + const [loadData, setLoadData] = React.useState(false); + const [master, setMaster] = React.useState([]); + + const [selectValue, setSelectValue] = React.useState(null); + const [selectedStatus, setSelectedStatus] = React.useState( + null + ); + + useEffect(() => { + onLoadMaster(); + }, []); + + const onLoadMaster = async () => { + try { + const response = await apiMasterTransaction(); + + if (response.success) { + setMaster(response.data); + } + } catch (error) { + console.log("[ERROR]", error); + setMaster([]); + } + }; + + useFocusEffect( + React.useCallback(() => { + onLoadData(); + }, [id, selectValue]) + ); + + const onLoadData = async () => { + try { + setLoadData(true); + const response = await apiAdminInvestmentListOfInvestor({ + id: id as string, + status: selectedStatus as any, + }); + console.log("[LIST OF INVESTOR]", JSON.stringify(response, null, 2)); + + if (response.success) { + setListData(response.data); + } + } catch (error) { + console.log("[ERROR]", error); + setListData([]); + } finally { + setLoadData(false); + } + }; + + useEffect(() => { + onLoadMaster(); + }, []); + const searchComponent = ( console.log(value)} + data={ + _.isEmpty(master) + ? [] + : master?.map((item: any) => ({ + label: item.name, + value: item.id, + })) + } + value={selectValue} + onChange={(value: any) => { + setSelectValue(value); + const nameSelected = master.find((item: any) => item.id === value); + const statusChooses = _.lowerCase(nameSelected?.name); + setSelectedStatus(statusChooses); + }} styleContainer={{ width: "100%", marginBottom: 0 }} + allowClear /> ); @@ -40,66 +119,77 @@ export default function AdminInvestmentListOfInvestor() { return ( <> - - - Aksi - - } - component2={ - - Investor - - } - component3={ - - Status - - } - /> - + - {Array.from({ length: 10 }).map((_, index) => ( - - - } - onPress={() => { - router.push( - `/admin/investment/${id}/berhasil/transaction-detail` - ); - }} - /> - - } - component2={ - - Bagas Banuna - - } - component3={ - - Berhasil - - } - /> - - - ))} + + Aksi + + } + component2={ + + Investor + + } + component3={ + + Status + + } + /> + + + {loadData ? ( + + ) : _.isEmpty(listData) ? ( + + ) : ( + listData?.map((item: any, index: number) => ( + + + + } + onPress={() => { + router.push( + `/admin/investment/${item?.id}/${_.lowerCase( + item?.StatusInvoice?.name + )}/transaction-detail` + ); + }} + /> + + } + component2={ + + {item?.Author?.username || "-"} + + } + component3={ + + {item?.StatusInvoice?.name} + + } + /> + + )) + )} + diff --git a/app/(application)/admin/investment/[id]/reject-input.tsx b/app/(application)/admin/investment/[id]/reject-input.tsx index e974139..c7361e0 100644 --- a/app/(application)/admin/investment/[id]/reject-input.tsx +++ b/app/(application)/admin/investment/[id]/reject-input.tsx @@ -1,3 +1,4 @@ +/* eslint-disable react-hooks/exhaustive-deps */ import { AlertDefaultSystem, BoxButtonOnFooter, @@ -6,15 +7,83 @@ import { } from "@/components"; import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle"; import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject"; -import { router, useLocalSearchParams } from "expo-router"; -import { useState } from "react"; +import { apiAdminInvestasiUpdateByStatus, apiAdminInvestmentDetailById } from "@/service/api-admin/api-admin-investment"; +import { router, useFocusEffect, useLocalSearchParams } from "expo-router"; +import { useCallback, useState } from "react"; +import Toast from "react-native-toast-message"; export default function AdminInvestmentRejectInput() { - const { id } = useLocalSearchParams(); - const [value, setValue] = useState(id as string); + const { id, status } = useLocalSearchParams(); + console.log("[STATUS]", status); + const [value, setValue] = useState(null); + const [isLoading , setLoading] = useState(false) + + useFocusEffect( + useCallback(() => { + onLoadData(); + }, [id]) + ); + + const onLoadData = async () => { + try { + const response = await apiAdminInvestmentDetailById({ id: id as string }); + console.log("[DATA]", JSON.stringify(response, null, 2)); + if (response.success) { + setValue(response.data?.catatan); + } + } catch (error) { + console.log(error); + } + }; + + const handlerSubmit = async () => { + if (!value) { + Toast.show({ + type: "error", + text1: "Harap masukan alasan penolakan", + }); + return; + } + + try { + setLoading(true) + const response = await apiAdminInvestasiUpdateByStatus({ + id: id as string, + status: "reject", + data: value, + }); + + console.log("[RESPONSE]", JSON.stringify(response, null, 2)); + + if (!response.success) { + Toast.show({ + type: "error", + text1: "Gagal melakukan report", + }); + return; + } + + Toast.show({ + type: "success", + text1: "Berhasil melakukan report", + }); + + if (status === "review") { + router.replace(`/admin/investment/reject/status`); + } else { + router.back(); + } + } catch (error) { + console.error(["ERROR"], error); + } finally { + setLoading(false) + } + }; + const buttonSubmit = ( AlertDefaultSystem({ @@ -22,12 +91,8 @@ export default function AdminInvestmentRejectInput() { message: "Apakah anda yakin ingin menolak data ini?", textLeft: "Batal", textRight: "Ya", - onPressLeft: () => { - router.back(); - }, onPressRight: () => { - console.log("value:", value); - router.replace(`/admin/investment/reject/status`); + handlerSubmit(); }, }) } @@ -39,7 +104,9 @@ export default function AdminInvestmentRejectInput() { <> } + headerComponent={ + + } > (null); + const [loadData, setLoadingData] = React.useState(false); + const [search, setSearch] = React.useState(""); + + useFocusEffect( + useCallback(() => { + onLoadData(); + }, [status, search]) + ); + + const onLoadData = async () => { + try { + setLoadingData(true); + const response = await apiAdminInvestment({ + category: status as "publish" | "review" | "reject", + search, + }); + console.log("[LIST DATA]", JSON.stringify(response, null, 2)); + if (response.success) { + setListData(response.data); + } + } catch (error) { + console.log(error); + setListData([]); + } finally { + setLoadingData(false); + } + }; + const rightComponent = ( ); return ( <> - }> + - } - > - - - - - {Array.from({ length: 10 }).map((_, index) => ( - - } - onPress={() => { - router.push(`/admin/investment/${index}/${status}`); - }} - /> - } - value2={Username username} - value3={ - - Lorem ipsum dolor sit amet consectetur adipisicing elit. - Blanditiis asperiores quidem deleniti architecto eaque et - nostrum, ad consequuntur eveniet quisquam quae voluptatum - ducimus! Dolorem nobis modi officia debitis, beatae mollitia. - - } + - ))} + + + + {loadData ? ( + + ) : _.isEmpty(listData) ? ( + + ) : ( + listData?.map((item: any, index: number) => ( + + } + onPress={() => { + router.push(`/admin/investment/${item.id}/${status}`); + }} + /> + } + value2={{item?.author?.username}} + value3={ + + {item?.title} + + } + /> + )) + )} + ); diff --git a/app/(application)/admin/investment/index.tsx b/app/(application)/admin/investment/index.tsx index 553bfe0..dada5f7 100644 --- a/app/(application)/admin/investment/index.tsx +++ b/app/(application)/admin/investment/index.tsx @@ -7,8 +7,51 @@ import { import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard"; import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage"; import { MainColor } from "@/constants/color-palet"; +import { apiAdminInvestment } from "@/service/api-admin/api-admin-investment"; +import { useFocusEffect } from "expo-router"; +import React, { useCallback } from "react"; export default function AdminInvestment() { + const [data, setData] = React.useState(null); + + useFocusEffect( + useCallback(() => { + onLoadData(); + }, []) + ); + + const onLoadData = async () => { + try { + const response = await apiAdminInvestment({ + category: "dashboard", + }); + console.log(JSON.stringify(response, null, 2)); + if (response.success) { + setData(response.data); + } + } catch (error) { + console.log(error); + } + }; + + const listData = [ + { + label: "Publish", + value: (data && data.publish) || 0, + icon: , + }, + { + label: "Review", + value: (data && data.review) || 0, + icon: , + }, + { + label: "Reject", + value: (data && data.reject) || 0, + icon: , + }, + ]; + return ( <> @@ -23,21 +66,3 @@ export default function AdminInvestment() { ); } - -const listData = [ - { - label: "Publish", - value: 3, - icon: , - }, - { - label: "Review", - value: 5, - icon: , - }, - { - label: "Reject", - value: 8, - icon: , - }, -]; diff --git a/components/_ShareComponent/NoDataText.tsx b/components/_ShareComponent/NoDataText.tsx new file mode 100644 index 0000000..d5b8178 --- /dev/null +++ b/components/_ShareComponent/NoDataText.tsx @@ -0,0 +1,9 @@ +import TextCustom from "../Text/TextCustom"; + +export default function NoDataText({ text }: { text?: string }) { + return ( + + {text ? text : "Belum ada data"} + + ); +} diff --git a/screens/Donation/BoxPublish.tsx b/screens/Donation/BoxPublish.tsx index a2f191b..713a0b2 100644 --- a/screens/Donation/BoxPublish.tsx +++ b/screens/Donation/BoxPublish.tsx @@ -22,7 +22,7 @@ export default function Donation_BoxPublish({ sisa: 0, reminder: false, }); - + useEffect(() => { updateCountDown(); }, [data]); diff --git a/screens/Invesment/BoxBerandaSection.tsx b/screens/Invesment/BoxBerandaSection.tsx new file mode 100644 index 0000000..0d2bd2d --- /dev/null +++ b/screens/Invesment/BoxBerandaSection.tsx @@ -0,0 +1,96 @@ +/* eslint-disable react-hooks/exhaustive-deps */ +import { + BaseBox, + Grid, + ProgressCustom, + StackCustom, + TextCustom, +} from "@/components"; +import API_STRORAGE from "@/constants/base-url-api-strorage"; +import DUMMY_IMAGE from "@/constants/dummy-image-value"; +import { countDownAndCondition } from "@/utils/countDownAndCondition"; +import { Ionicons } from "@expo/vector-icons"; +import { Image } from "expo-image"; +import { useEffect, useState } from "react"; +import { View } from "react-native"; + +export default function Investment_BoxBerandaSection({ + id, + data, +}: { + id: string; + data: any; +}) { +// console.log("[DATA By one]", JSON.stringify(data, null, 2)); + + const [value, setValue] = useState({ + sisa: 0, + reminder: false, + }); + + useEffect(() => { + updateCountDown(); + }, [data]); + + const updateCountDown = () => { + const countDown = countDownAndCondition({ + duration: data?.pencarianInvestor, + publishTime: data?.countDown, + }); + + setValue({ + sisa: countDown.durationDay, + reminder: countDown.reminder, + }); + }; + + return ( + <> + + + + + + + + + + + {data.title} + + {value.reminder ? ( + + + + Periode Investasi Berakhir + + + ) : ( + + Sisa waktu: {value.sisa} hari + + )} + + + + + + ); +} diff --git a/screens/Invesment/BoxProgressSection.tsx b/screens/Invesment/BoxProgressSection.tsx index 8a6dba0..7c5c3dc 100644 --- a/screens/Invesment/BoxProgressSection.tsx +++ b/screens/Invesment/BoxProgressSection.tsx @@ -7,7 +7,7 @@ export default function Invesment_BoxProgressSection({progress, status}: {progre Progress Saham - + )} diff --git a/screens/Invesment/DetailDataPublishSection.tsx b/screens/Invesment/DetailDataPublishSection.tsx index cef8fe4..d67b93f 100644 --- a/screens/Invesment/DetailDataPublishSection.tsx +++ b/screens/Invesment/DetailDataPublishSection.tsx @@ -1,9 +1,12 @@ -import { Spacing, StackCustom } from "@/components"; +/* eslint-disable react-hooks/exhaustive-deps */ +import { ButtonCustom, Spacing, StackCustom } from "@/components"; +import ReportBox from "@/components/Box/ReportBox"; import { listDataNotPublishInvesment, listDataPublishInvesment, } from "@/lib/dummy-data/investment/dummy-data-not-publish"; -import React from "react"; +import { countDownAndCondition } from "@/utils/countDownAndCondition"; +import React, { useEffect, useState } from "react"; import Invesment_BoxDetailDataSection from "./BoxDetailDataSection"; import Invesment_BoxProgressSection from "./BoxProgressSection"; import Investment_ButtonStatusSection from "./ButtonStatusSection"; @@ -19,11 +22,39 @@ export default function Invesment_DetailDataPublishSection({ bottomSection?: React.ReactNode; buttonSection?: React.ReactNode; }) { + const [value, setValue] = useState({ + sisa: 0, + reminder: false, + }); + + useEffect(() => { + updateCountDown(); + }, [data]); + + const updateCountDown = () => { + const countDown = countDownAndCondition({ + duration: data?.durasiDonasi, + publishTime: data?.publishTime, + }); + + setValue({ + sisa: countDown.durationDay, + reminder: countDown.reminder, + }); + }; return ( <> - + {data && + data?.catatan && + (status === "draft" || status === "reject") && ( + + )} + - + + {value.reminder ? ( + + Periode Investasi Berakhir + + ) : ( + + )} diff --git a/service/api-admin/api-admin-investment.ts b/service/api-admin/api-admin-investment.ts new file mode 100644 index 0000000..3c009df --- /dev/null +++ b/service/api-admin/api-admin-investment.ts @@ -0,0 +1,88 @@ +import { apiConfig } from "../api-config"; + +export async function apiAdminInvestment({ + category, + search, +}: { + category: "dashboard" | "publish" | "review" | "reject"; + search?: string; +}) { + const propsQuery = + category === "dashboard" + ? `category=${category}` + : `category=${category}&search=${search}`; + + try { + const response = await apiConfig.get( + `/mobile/admin/investment?${propsQuery}` + ); + return response.data; + } catch (error) { + throw error; + } +} + +export async function apiAdminInvestmentDetailById({ id }: { id: string }) { + try { + const response = await apiConfig.get(`/mobile/admin/investment/${id}`); + return response.data; + } catch (error) { + throw error; + } +} + +export async function apiAdminInvestasiUpdateByStatus({ + id, + status, + data, +}: { + id: string; + status: "publish" | "review" | "reject"; + data: any; +}) { + try { + const response = await apiConfig.put( + `/mobile/admin/investment/${id}?status=${status}`, + { + data: data, + } + ); + return response.data; + } catch (error) { + throw error; + } +} + +export async function apiAdminInvestmentListOfInvestor({ + id, + status, +}: { + id: string; + status: "berhasil" | "gagal" | "proses" | "menunggu" | null; +}) { + const query = status && status !== null ? `?status=${status}` : ""; + + try { + const response = await apiConfig.get( + `/mobile/admin/investment/${id}/investor${query}` + ); + return response.data; + } catch (error) { + throw error; + } +} + +export async function apiAdminInvestmentGetOneInvoiceById({ + id, +}: { + id: string; +}) { + try { + const response = await apiConfig.get( + `/mobile/admin/investment/${id}/invoice` + ); + return response.data; + } catch (error) { + throw error; + } +}