Compare commits
1 Commits
api-admin/
...
api-admin/
| Author | SHA1 | Date | |
|---|---|---|---|
| f9f996f195 |
@@ -8,6 +8,7 @@ import {
|
|||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import NoDataText from "@/components/_ShareComponent/NoDataText";
|
||||||
import { useAuth } from "@/hooks/use-auth";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import { apiInvestmentGetInvoice } from "@/service/api-client/api-investment";
|
import { apiInvestmentGetInvoice } from "@/service/api-client/api-investment";
|
||||||
import { GStyles } from "@/styles/global-styles";
|
import { GStyles } from "@/styles/global-styles";
|
||||||
@@ -74,7 +75,7 @@ export default function InvestmentTransaction() {
|
|||||||
{loadList ? (
|
{loadList ? (
|
||||||
<LoaderCustom />
|
<LoaderCustom />
|
||||||
) : _.isEmpty(list) ? (
|
) : _.isEmpty(list) ? (
|
||||||
<TextCustom>Tidak ada data</TextCustom>
|
<NoDataText/>
|
||||||
) : (
|
) : (
|
||||||
list.map((item: any, i: number) => (
|
list.map((item: any, i: number) => (
|
||||||
<BaseBox
|
<BaseBox
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export default function AdminInvestmentDetail() {
|
|||||||
const onLoadData = async () => {
|
const onLoadData = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiAdminInvestmentDetailById({ id: id as string });
|
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) {
|
if (response.success) {
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
}
|
}
|
||||||
@@ -134,7 +134,7 @@ export default function AdminInvestmentDetail() {
|
|||||||
data: data,
|
data: data,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[RESPONSE]", JSON.stringify(response, null, 2));
|
// console.log("[GET ON INVEST]", JSON.stringify(response, null, 2));
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "error",
|
type: "error",
|
||||||
@@ -181,11 +181,13 @@ export default function AdminInvestmentDetail() {
|
|||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
label={<TextCustom bold>Sisa Saham</TextCustom>}
|
label={<TextCustom bold>Sisa Saham</TextCustom>}
|
||||||
value={<TextCustom>2490 lembar</TextCustom>}
|
value={
|
||||||
|
<TextCustom>{data && formatCurrencyDisplay(data?.sisaLembar)} lembar</TextCustom>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
label={<TextCustom bold>Validasi Transaksi</TextCustom>}
|
label={<TextCustom bold>Validasi Transaksi</TextCustom>}
|
||||||
value={<TextCustom>4 Transaksi</TextCustom>}
|
value={<TextCustom>{data && formatCurrencyDisplay(data?.lembarTerbeli)} Transaksi</TextCustom>}
|
||||||
/>
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|||||||
@@ -2,26 +2,33 @@
|
|||||||
import {
|
import {
|
||||||
BadgeCustom,
|
BadgeCustom,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
BoxButtonOnFooter,
|
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
|
Spacing,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
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 { colorBadgeTransaction } from "@/utils/colorBadge";
|
||||||
import { dateTimeView } from "@/utils/dateTimeView";
|
import { dateTimeView } from "@/utils/dateTimeView";
|
||||||
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminInvestmentTransactionDetail() {
|
export default function AdminInvestmentTransactionDetail() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
console.log("[ID]", id);
|
console.log("[ID]", id);
|
||||||
|
|
||||||
const [data, setData] = useState<any | null>(null);
|
const [data, setData] = useState<any | null>(null);
|
||||||
|
const [isLoading, setLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
@@ -43,24 +50,22 @@ export default function AdminInvestmentTransactionDetail() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const buttonAction = (
|
|
||||||
<BoxButtonOnFooter>
|
|
||||||
<ButtonCustom onPress={() => router.back()}>Terima</ButtonCustom>
|
|
||||||
</BoxButtonOnFooter>
|
|
||||||
);
|
|
||||||
|
|
||||||
const listData = [
|
const listData = [
|
||||||
{
|
{
|
||||||
label: "Investor",
|
label: "Investor",
|
||||||
value: data?.Author?.username || "-",
|
value: (data && data?.Author?.username) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Bank",
|
label: "Bank",
|
||||||
value: data?.MasterBank?.namaBank || "-",
|
value: (data && data?.MasterBank?.namaBank) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Jumlah Investasi",
|
label: "Jumlah Investasi",
|
||||||
value: `Rp. ${formatCurrencyDisplay(data?.nominal) || "-"}`,
|
value: (data && `Rp. ${formatCurrencyDisplay(data?.nominal)}`) || "-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Lembar terbeli",
|
||||||
|
value: (data && formatCurrencyDisplay(data?.lembarTerbeli)) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Status",
|
label: "Status",
|
||||||
@@ -79,29 +84,128 @@ export default function AdminInvestmentTransactionDetail() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Tanggal",
|
label: "Tanggal",
|
||||||
value: data && dateTimeView({ date: data?.createdAt }) || "-",
|
value: (data && dateTimeView({ date: data?.createdAt })) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Bukti Transfer",
|
label: "Bukti Transfer",
|
||||||
value: (
|
value:
|
||||||
<ButtonCustom
|
data && data?.imageId ? (
|
||||||
onPress={() =>
|
<ButtonCustom
|
||||||
router.push(`/(application)/(image)/preview-image/${data?.imageId}`)
|
onPress={() =>
|
||||||
}
|
router.push(
|
||||||
>
|
`/(application)/(image)/preview-image/${data?.imageId}`
|
||||||
Cek
|
)
|
||||||
</ButtonCustom>
|
}
|
||||||
),
|
>
|
||||||
|
Cek
|
||||||
|
</ButtonCustom>
|
||||||
|
) : (
|
||||||
|
"-"
|
||||||
|
),
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
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 (
|
||||||
|
<GridTwoView
|
||||||
|
spanLeft={6}
|
||||||
|
spanRight={6}
|
||||||
|
styleLeft={{ paddingRight: 10 }}
|
||||||
|
styleRight={{ paddingLeft: 10 }}
|
||||||
|
leftIcon={
|
||||||
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
|
backgroundColor={MainColor.red}
|
||||||
|
textColor="white"
|
||||||
|
onPress={() => {
|
||||||
|
handlerSubmit({
|
||||||
|
category: "deny",
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Tolak
|
||||||
|
</ButtonCustom>
|
||||||
|
}
|
||||||
|
rightIcon={
|
||||||
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
|
onPress={() => {
|
||||||
|
handlerSubmit({
|
||||||
|
category: "accept",
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Terima
|
||||||
|
</ButtonCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
} else if (data?.StatusInvoice?.name === "Gagal") {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ButtonCustom textColor="red" onPress={() => router.back()}>
|
||||||
|
Gagal
|
||||||
|
</ButtonCustom>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ButtonCustom disabled={true}>
|
||||||
|
Status: {data?.StatusInvoice?.name}
|
||||||
|
</ButtonCustom>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
headerComponent={
|
headerComponent={
|
||||||
<AdminBackButtonAntTitle title="Detail Transaksi Investor" />
|
<AdminBackButtonAntTitle title="Detail Transaksi Investor" />
|
||||||
}
|
}
|
||||||
footerComponent={buttonAction}
|
// footerComponent={buttonAction()}
|
||||||
>
|
>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
@@ -114,6 +218,8 @@ export default function AdminInvestmentTransactionDetail() {
|
|||||||
))}
|
))}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
<Spacing />
|
||||||
|
{buttonAction()}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -86,3 +86,28 @@ export async function apiAdminInvestmentGetOneInvoiceById({
|
|||||||
throw error;
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user