From ebd6107c36a64927136b1305dc97ee0bfcd34b06 Mon Sep 17 00:00:00 2001 From: Bagasbanuna02 Date: Thu, 30 Oct 2025 16:38:24 +0800 Subject: [PATCH] Integrasi API: Investment: Add: - screens/Invesment/BoxBerandaSection.tsx Fix: - app/(application)/(user)/investment/(tabs)/index.tsx - screens/Donation/BoxPublish.tsx - screens/Invesment/BoxProgressSection.tsx - screens/Invesment/DetailDataPublishSection.tsx ### No Issue --- .../(user)/investment/(tabs)/index.tsx | 88 +---------------- screens/Donation/BoxPublish.tsx | 2 +- screens/Invesment/BoxBerandaSection.tsx | 97 +++++++++++++++++++ screens/Invesment/BoxProgressSection.tsx | 2 +- .../Invesment/DetailDataPublishSection.tsx | 56 ++++++++--- 5 files changed, 147 insertions(+), 98 deletions(-) create mode 100644 screens/Invesment/BoxBerandaSection.tsx diff --git a/app/(application)/(user)/investment/(tabs)/index.tsx b/app/(application)/(user)/investment/(tabs)/index.tsx index 2892c93..d1df709 100644 --- a/app/(application)/(user)/investment/(tabs)/index.tsx +++ b/app/(application)/(user)/investment/(tabs)/index.tsx @@ -11,6 +11,7 @@ import { import NoDataText from "@/components/_ShareComponent/NoDataText"; import API_STRORAGE from "@/constants/base-url-api-strorage"; import DUMMY_IMAGE from "@/constants/dummy-image-value"; +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"; @@ -34,7 +35,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); @@ -56,92 +57,9 @@ export default function InvestmentBursa() { ) : ( 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/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..7fc222a --- /dev/null +++ b/screens/Invesment/BoxBerandaSection.tsx @@ -0,0 +1,97 @@ +/* eslint-disable react-hooks/exhaustive-deps */ +import { + BaseBox, + Grid, + StackCustom, + TextCustom, + ProgressCustom, +} 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 dayjs from "dayjs"; +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 d2d2d57..ab03915 100644 --- a/screens/Invesment/DetailDataPublishSection.tsx +++ b/screens/Invesment/DetailDataPublishSection.tsx @@ -1,13 +1,15 @@ -import { Spacing, StackCustom } from "@/components"; +/* eslint-disable react-hooks/exhaustive-deps */ +import { ButtonCustom, Spacing, StackCustom, TextCustom } from "@/components"; import { listDataNotPublishInvesment, listDataPublishInvesment, } from "@/lib/dummy-data/investment/dummy-data-not-publish"; -import React from "react"; +import React, { useEffect, useState } from "react"; import Invesment_BoxDetailDataSection from "./BoxDetailDataSection"; import Invesment_BoxProgressSection from "./BoxProgressSection"; import Investment_ButtonStatusSection from "./ButtonStatusSection"; import ReportBox from "@/components/Box/ReportBox"; +import { countDownAndCondition } from "@/utils/countDownAndCondition"; export default function Invesment_DetailDataPublishSection({ status, @@ -20,14 +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") && ( - - )} - + {data && + data?.catatan && + (status === "draft" || status === "reject") && ( + + )} + - + + {value.reminder ? ( + + Periode Investasi Berakhir + + ) : ( + + )}