diff --git a/app/(application)/(user)/investment/(tabs)/transaction.tsx b/app/(application)/(user)/investment/(tabs)/transaction.tsx
index ff3bca8..99b24be 100644
--- a/app/(application)/(user)/investment/(tabs)/transaction.tsx
+++ b/app/(application)/(user)/investment/(tabs)/transaction.tsx
@@ -8,6 +8,7 @@ import {
TextCustom,
ViewWrapper,
} from "@/components";
+import NoDataText from "@/components/_ShareComponent/NoDataText";
import { useAuth } from "@/hooks/use-auth";
import { apiInvestmentGetInvoice } from "@/service/api-client/api-investment";
import { GStyles } from "@/styles/global-styles";
@@ -74,7 +75,7 @@ export default function InvestmentTransaction() {
{loadList ? (
) : _.isEmpty(list) ? (
- Tidak ada data
+
) : (
list.map((item: any, i: number) => (
{
try {
const response = await apiAdminInvestmentDetailById({ id: id as string });
- console.log("[DATA]", JSON.stringify(response, null, 2));
+ console.log("[GETONE INVEST]", JSON.stringify(response, null, 2));
if (response.success) {
setData(response.data);
}
@@ -134,7 +134,7 @@ export default function AdminInvestmentDetail() {
data: data,
});
- console.log("[RESPONSE]", JSON.stringify(response, null, 2));
+ // console.log("[GET ON INVEST]", JSON.stringify(response, null, 2));
if (!response.success) {
Toast.show({
type: "error",
@@ -181,11 +181,13 @@ export default function AdminInvestmentDetail() {
Sisa Saham}
- value={2490 lembar}
+ value={
+ {data && formatCurrencyDisplay(data?.sisaLembar)} lembar
+ }
/>
Validasi Transaksi}
- value={4 Transaksi}
+ value={{data && formatCurrencyDisplay(data?.lembarTerbeli)} Transaksi}
/>
diff --git a/app/(application)/admin/investment/[id]/[status]/transaction-detail.tsx b/app/(application)/admin/investment/[id]/[status]/transaction-detail.tsx
index 0e7c48a..4248b33 100644
--- a/app/(application)/admin/investment/[id]/[status]/transaction-detail.tsx
+++ b/app/(application)/admin/investment/[id]/[status]/transaction-detail.tsx
@@ -2,26 +2,33 @@
import {
BadgeCustom,
BaseBox,
- BoxButtonOnFooter,
ButtonCustom,
+ Spacing,
StackCustom,
TextCustom,
- ViewWrapper,
+ ViewWrapper
} from "@/components";
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
-import { apiAdminInvestmentGetOneInvoiceById } from "@/service/api-admin/api-admin-investment";
+import GridTwoView from "@/components/_ShareComponent/GridTwoView";
+import { MainColor } from "@/constants/color-palet";
+import {
+ apiAdminInvestmentGetOneInvoiceById,
+ apiAdminInvestmentUpdateInvoice,
+} 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";
+import Toast from "react-native-toast-message";
export default function AdminInvestmentTransactionDetail() {
const { id } = useLocalSearchParams();
console.log("[ID]", id);
const [data, setData] = useState(null);
+ const [isLoading, setLoading] = useState(false);
useFocusEffect(
useCallback(() => {
@@ -43,24 +50,22 @@ export default function AdminInvestmentTransactionDetail() {
}
};
- const buttonAction = (
-
- router.back()}>Terima
-
- );
-
const listData = [
{
label: "Investor",
- value: data?.Author?.username || "-",
+ value: (data && data?.Author?.username) || "-",
},
{
label: "Bank",
- value: data?.MasterBank?.namaBank || "-",
+ value: (data && data?.MasterBank?.namaBank) || "-",
},
{
label: "Jumlah Investasi",
- value: `Rp. ${formatCurrencyDisplay(data?.nominal) || "-"}`,
+ value: (data && `Rp. ${formatCurrencyDisplay(data?.nominal)}`) || "-",
+ },
+ {
+ label: "Lembar terbeli",
+ value: (data && formatCurrencyDisplay(data?.lembarTerbeli)) || "-",
},
{
label: "Status",
@@ -79,29 +84,128 @@ export default function AdminInvestmentTransactionDetail() {
},
{
label: "Tanggal",
- value: data && dateTimeView({ date: data?.createdAt }) || "-",
+ value: (data && dateTimeView({ date: data?.createdAt })) || "-",
},
{
label: "Bukti Transfer",
- value: (
-
- router.push(`/(application)/(image)/preview-image/${data?.imageId}`)
- }
- >
- Cek
-
- ),
+ value:
+ data && data?.imageId ? (
+
+ router.push(
+ `/(application)/(image)/preview-image/${data?.imageId}`
+ )
+ }
+ >
+ Cek
+
+ ) : (
+ "-"
+ ),
},
];
+ const handlerSubmit = async ({
+ category,
+ }: {
+ category: "accept" | "deny";
+ }) => {
+ try {
+ setLoading(true);
+ const response = await apiAdminInvestmentUpdateInvoice({
+ id: id as string,
+ category: category,
+ data: {
+ investasiId: data?.investasiId,
+ lembarTerbeli: data?.lembarTerbeli,
+ },
+ });
+
+ console.log("[RESPONSE SUBMIT]", JSON.stringify(response, null, 2));
+
+ if (!response.success) {
+ Toast.show({
+ type: "error",
+ text1: "Gagal update status transaksi",
+ });
+
+ return;
+ }
+
+ Toast.show({
+ type: "success",
+ text1: "Berhasil update status transaksi",
+ });
+ router.back();
+ } catch (error) {
+ console.log("[ERROR]", error);
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const buttonAction = () => {
+ if (data?.StatusInvoice?.name === "Proses") {
+ return (
+ {
+ handlerSubmit({
+ category: "deny",
+ });
+ }}
+ >
+ Tolak
+
+ }
+ rightIcon={
+ {
+ handlerSubmit({
+ category: "accept",
+ });
+ }}
+ >
+ Terima
+
+ }
+ />
+ );
+ } else if (data?.StatusInvoice?.name === "Gagal") {
+ return (
+ <>
+ router.back()}>
+ Gagal
+
+ >
+ );
+ } else {
+ return (
+ <>
+
+ Status: {data?.StatusInvoice?.name}
+
+ >
+ );
+ }
+ };
+
return (
<>
}
- footerComponent={buttonAction}
+ // footerComponent={buttonAction()}
>
@@ -114,6 +218,8 @@ export default function AdminInvestmentTransactionDetail() {
))}
+
+ {buttonAction()}
>
);
diff --git a/service/api-admin/api-admin-investment.ts b/service/api-admin/api-admin-investment.ts
index 3c009df..5bb57d3 100644
--- a/service/api-admin/api-admin-investment.ts
+++ b/service/api-admin/api-admin-investment.ts
@@ -86,3 +86,28 @@ export async function apiAdminInvestmentGetOneInvoiceById({
throw error;
}
}
+
+export async function apiAdminInvestmentUpdateInvoice({
+ id,
+ category,
+ data,
+}: {
+ id: string;
+ category: "deny" | "accept";
+ data: {
+ investasiId: string;
+ lembarTerbeli: number;
+ };
+}) {
+ try {
+ const response = await apiConfig.put(
+ `/mobile/admin/investment/${id}/invoice?category=${category}`,
+ {
+ data: data,
+ }
+ );
+ return response.data;
+ } catch (error) {
+ throw error;
+ }
+}