Compare commits
5 Commits
api-admin/
...
api-admin/
| Author | SHA1 | Date | |
|---|---|---|---|
| f9f996f195 | |||
| 4625831377 | |||
| ebd6107c36 | |||
| f23cfe1107 | |||
| b3209dc7ee |
@@ -1,17 +1,71 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BaseBox,
|
BaseBox,
|
||||||
ButtonCenteredOnly,
|
ButtonCenteredOnly,
|
||||||
Grid,
|
Grid,
|
||||||
InformationBox,
|
InformationBox,
|
||||||
|
LoaderCustom,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import {
|
||||||
|
apiDonationDisbursementOfFundsListById,
|
||||||
|
apiDonationGetOne,
|
||||||
|
} from "@/service/api-client/api-donation";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
|
||||||
export default function DonationFundDisbursement() {
|
export default function DonationFundDisbursement() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
|
||||||
|
const [data, setData] = useState({
|
||||||
|
totalPencairan: 0,
|
||||||
|
akumulasiPencairan: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
const [listData, setListData] = React.useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = React.useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
React.useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
|
||||||
|
const responseData = await apiDonationGetOne({
|
||||||
|
id: id as string,
|
||||||
|
category: "permanent",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (responseData.success) {
|
||||||
|
setData({
|
||||||
|
totalPencairan: responseData.data.totalPencairan,
|
||||||
|
akumulasiPencairan: responseData.data.akumulasiPencairan,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const responseList = await apiDonationDisbursementOfFundsListById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (responseList.success) {
|
||||||
|
setListData(responseList.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
@@ -20,47 +74,50 @@ export default function DonationFundDisbursement() {
|
|||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={6}>
|
<Grid.Col span={6}>
|
||||||
<TextCustom bold color="yellow">
|
<TextCustom bold color="yellow">
|
||||||
Rp. 0
|
Rp. {formatCurrencyDisplay(data?.totalPencairan)}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom size="small">Total Pencairan Dana</TextCustom>
|
<TextCustom size="small">Total Pencairan Dana</TextCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={6}>
|
<Grid.Col span={6}>
|
||||||
<TextCustom bold color="yellow">
|
<TextCustom bold color="yellow">
|
||||||
0 kali
|
{data?.akumulasiPencairan} kali
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom size="small">Akumulasi Pencairan</TextCustom>
|
<TextCustom size="small">Akumulasi Pencairan</TextCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadData ? (
|
||||||
<BaseBox key={index}>
|
<LoaderCustom />
|
||||||
<StackCustom>
|
) : _.isEmpty(listData) ? (
|
||||||
<Grid>
|
<TextCustom align="center" color="gray">
|
||||||
<Grid.Col span={8}>
|
Belum ada data
|
||||||
<TextCustom bold>Pencairan ke - {index + 1}</TextCustom>
|
</TextCustom>
|
||||||
</Grid.Col>
|
) : (
|
||||||
<Grid.Col span={4} style={{ alignItems: "flex-end" }}>
|
listData?.map((item, index) => (
|
||||||
<TextCustom>{dayjs().format("DD MMM YYYY")}</TextCustom>
|
<BaseBox key={index}>
|
||||||
</Grid.Col>
|
<StackCustom>
|
||||||
</Grid>
|
<Grid>
|
||||||
<TextCustom>
|
<Grid.Col span={8}>
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit.
|
<TextCustom bold>{item?.title}</TextCustom>
|
||||||
Nesciunt dolor ad sit? Eaque rem nihil natus, id, esse possimus
|
</Grid.Col>
|
||||||
perferendis provident velit illo consectetur distinctio ab
|
<Grid.Col span={4} style={{ alignItems: "flex-end" }}>
|
||||||
accusantium quis earum omnis!
|
<TextCustom>{dayjs(item?.createdAt).format("DD MMM YYYY")}</TextCustom>
|
||||||
</TextCustom>
|
</Grid.Col>
|
||||||
<ButtonCenteredOnly
|
</Grid>
|
||||||
onPress={() => {
|
<TextCustom>{item?.deskripsi}</TextCustom>
|
||||||
router.navigate(`/(application)/(file)/${id}`);
|
<ButtonCenteredOnly
|
||||||
}}
|
onPress={() => {
|
||||||
icon="file-text"
|
router.navigate(`/(application)/(image)/preview-image/${item?.imageId}`);
|
||||||
>
|
}}
|
||||||
Bukti Transaksi
|
icon="file-text"
|
||||||
</ButtonCenteredOnly>
|
>
|
||||||
</StackCustom>
|
Bukti Transaksi
|
||||||
</BaseBox>
|
</ButtonCenteredOnly>
|
||||||
))}
|
</StackCustom>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,46 +1,93 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BaseBox,
|
BaseBox,
|
||||||
Grid,
|
Grid,
|
||||||
|
LoaderCustom,
|
||||||
|
Spacing,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import { apiAdminDonationListOfDonaturById } from "@/service/api-admin/api-admin-donation";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import { FontAwesome6 } from "@expo/vector-icons";
|
import { FontAwesome6 } from "@expo/vector-icons";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
|
import { useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function Donation_ListOfDonatur() {
|
export default function Donation_ListOfDonatur() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [listData, setListData] = useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminDonationListOfDonaturById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadData ? (
|
||||||
<BaseBox key={index}>
|
<LoaderCustom />
|
||||||
<Grid>
|
) : _.isEmpty(listData) ? (
|
||||||
<Grid.Col
|
<TextCustom bold align="center">
|
||||||
span={3}
|
Belum ada donatur
|
||||||
style={{ alignItems: "center", justifyContent: "center" }}
|
</TextCustom>
|
||||||
>
|
) : (
|
||||||
<FontAwesome6
|
listData?.map((item: any, index: number) => (
|
||||||
name="face-smile-wink"
|
<BaseBox key={index}>
|
||||||
size={50}
|
<Grid>
|
||||||
style={{ color: MainColor.yellow }}
|
<Grid.Col
|
||||||
/>
|
span={3}
|
||||||
</Grid.Col>
|
style={{ alignItems: "center", justifyContent: "center" }}
|
||||||
<Grid.Col span={9}>
|
>
|
||||||
<StackCustom gap={"xs"}>
|
<FontAwesome6
|
||||||
|
name="face-smile-wink"
|
||||||
|
size={50}
|
||||||
|
style={{ color: MainColor.yellow }}
|
||||||
|
/>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={9}>
|
||||||
<TextCustom bold size="large">
|
<TextCustom bold size="large">
|
||||||
Username
|
{item?.Author?.username || "-"}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom>Berdonas sebesar </TextCustom>
|
<Spacing/>
|
||||||
<TextCustom bold size="large" color="yellow">
|
<StackCustom gap={"xs"}>
|
||||||
Rp. 100.000
|
<TextCustom size={"small"}>Berdonas sebesar </TextCustom>
|
||||||
</TextCustom>
|
<TextCustom bold size="large" color="yellow">
|
||||||
<TextCustom>{dayjs().format("DD MMM YYYY")}</TextCustom>
|
Rp. {formatCurrencyDisplay(item?.nominal)}
|
||||||
</StackCustom>
|
</TextCustom>
|
||||||
</Grid.Col>
|
<TextCustom>
|
||||||
</Grid>
|
{dayjs(item?.createdAt).format("DD MMM YYYY, HH:mm")}
|
||||||
</BaseBox>
|
</TextCustom>
|
||||||
))}
|
</StackCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,23 +1,14 @@
|
|||||||
import {
|
import {
|
||||||
BaseBox,
|
|
||||||
FloatingButton,
|
FloatingButton,
|
||||||
Grid,
|
|
||||||
LoaderCustom,
|
LoaderCustom,
|
||||||
ProgressCustom,
|
ViewWrapper
|
||||||
StackCustom,
|
|
||||||
TextCustom,
|
|
||||||
ViewWrapper,
|
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import API_STRORAGE from "@/constants/base-url-api-strorage";
|
import NoDataText from "@/components/_ShareComponent/NoDataText";
|
||||||
import DUMMY_IMAGE from "@/constants/dummy-image-value";
|
import Investment_BoxBerandaSection from "@/screens/Invesment/BoxBerandaSection";
|
||||||
import { apiInvestmentGetAll } from "@/service/api-client/api-investment";
|
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 { router, useFocusEffect } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
import { View } from "react-native";
|
|
||||||
|
|
||||||
export default function InvestmentBursa() {
|
export default function InvestmentBursa() {
|
||||||
const [list, setList] = useState<any[] | null>(null);
|
const [list, setList] = useState<any[] | null>(null);
|
||||||
@@ -33,7 +24,7 @@ export default function InvestmentBursa() {
|
|||||||
try {
|
try {
|
||||||
setLoadingList(true);
|
setLoadingList(true);
|
||||||
const response = await apiInvestmentGetAll();
|
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);
|
setList(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
@@ -52,95 +43,12 @@ export default function InvestmentBursa() {
|
|||||||
{loadingList ? (
|
{loadingList ? (
|
||||||
<LoaderCustom />
|
<LoaderCustom />
|
||||||
) : _.isEmpty(list) ? (
|
) : _.isEmpty(list) ? (
|
||||||
<TextCustom>Belum ada data</TextCustom>
|
<NoDataText />
|
||||||
) : (
|
) : (
|
||||||
list?.map((item: any, index: number) => (
|
list?.map((item: any, index: number) => (
|
||||||
<BaseBox
|
<Investment_BoxBerandaSection id={item.id} data={item} key={index} />
|
||||||
key={index}
|
|
||||||
paddingTop={7}
|
|
||||||
paddingBottom={7}
|
|
||||||
href={`/investment/${item.id}`}
|
|
||||||
>
|
|
||||||
<Grid>
|
|
||||||
<Grid.Col span={5}>
|
|
||||||
<Image
|
|
||||||
source={
|
|
||||||
item && item.imageId
|
|
||||||
? API_STRORAGE.GET({ fileId: item.imageId })
|
|
||||||
: DUMMY_IMAGE.background
|
|
||||||
}
|
|
||||||
style={{ width: "auto", height: 100, borderRadius: 10 }}
|
|
||||||
/>
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col span={1}>
|
|
||||||
<View />
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col span={6}>
|
|
||||||
<StackCustom>
|
|
||||||
<TextCustom truncate={2}>{item.title}</TextCustom>
|
|
||||||
<ProgressCustom
|
|
||||||
label={`${item.progress}%`}
|
|
||||||
value={item.progress}
|
|
||||||
size="lg"
|
|
||||||
/>
|
|
||||||
{Number(item?.pencarianInvestor) -
|
|
||||||
dayjs().diff(dayjs(item.countDown), "days") <=
|
|
||||||
0 ? (
|
|
||||||
<View
|
|
||||||
style={{
|
|
||||||
flexDirection: "row",
|
|
||||||
alignItems: "center",
|
|
||||||
gap: 5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Ionicons
|
|
||||||
name="alert-circle-outline"
|
|
||||||
size={16}
|
|
||||||
color="red"
|
|
||||||
/>
|
|
||||||
<TextCustom color="red" size="small">
|
|
||||||
Periode Investasi Selesai
|
|
||||||
</TextCustom>
|
|
||||||
</View>
|
|
||||||
) : (
|
|
||||||
<TextCustom>
|
|
||||||
Sisa waktu:{" "}
|
|
||||||
{Number(item?.pencarianInvestor) -
|
|
||||||
dayjs().diff(dayjs(item.countDown), "days")}{" "}
|
|
||||||
hari
|
|
||||||
</TextCustom>
|
|
||||||
)}
|
|
||||||
</StackCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
</Grid>
|
|
||||||
</BaseBox>
|
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// <View style={{ padding: 20, gap: 16 }}>
|
|
||||||
// <TextCustom>Progress 70%</TextCustom>
|
|
||||||
// <ProgressCustom value={70} color="primary" size="md" />
|
|
||||||
|
|
||||||
// <TextCustom>Success Progress</TextCustom>
|
|
||||||
// <ProgressCustom value={40} color="success" size="lg" />
|
|
||||||
|
|
||||||
// <TextCustom>Warning Progress (small)</TextCustom>
|
|
||||||
// <ProgressCustom value={90} color="warning" size="sm" />
|
|
||||||
|
|
||||||
// <TextCustom>Error Indeterminate</TextCustom>
|
|
||||||
// <ProgressCustom value={null} color="error" size="md" />
|
|
||||||
|
|
||||||
// <TextCustom>Custom Radius</TextCustom>
|
|
||||||
// <ProgressCustom value={60} color="info" size="xl" radius={4} />
|
|
||||||
|
|
||||||
// <ProgressCustom value={70} color="primary" size="lg" />
|
|
||||||
|
|
||||||
// <ProgressCustom value={45} color="success" size="md" label="Halfway!" />
|
|
||||||
|
|
||||||
// <ProgressCustom value={90} color="warning" size="lg" showLabel={false} />
|
|
||||||
|
|
||||||
// <ProgressCustom value={null} color="error" size="sm" label="Loading..." />
|
|
||||||
// </View>;
|
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -53,8 +53,6 @@ export default function AdminDonationDetail() {
|
|||||||
id: id as string,
|
id: id as string,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[RES GET BY ID]", JSON.stringify(response, null, 2));
|
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setData(response.data.donasi);
|
setData(response.data.donasi);
|
||||||
setCountDonatur(response.data.donatur);
|
setCountDonatur(response.data.donatur);
|
||||||
@@ -79,7 +77,9 @@ export default function AdminDonationDetail() {
|
|||||||
value:
|
value:
|
||||||
data && data?.DonasiMaster_Status?.name ? (
|
data && data?.DonasiMaster_Status?.name ? (
|
||||||
<BadgeCustom
|
<BadgeCustom
|
||||||
color={colorBadgeStatus({ status: data?.DonasiMaster_Status?.name })}
|
color={colorBadgeStatus({
|
||||||
|
status: data?.DonasiMaster_Status?.name,
|
||||||
|
})}
|
||||||
>
|
>
|
||||||
{_.startCase(data?.DonasiMaster_Status?.name)}
|
{_.startCase(data?.DonasiMaster_Status?.name)}
|
||||||
</BadgeCustom>
|
</BadgeCustom>
|
||||||
@@ -107,7 +107,7 @@ export default function AdminDonationDetail() {
|
|||||||
const listPencarianDana = [
|
const listPencarianDana = [
|
||||||
{
|
{
|
||||||
label: "Total Dana Dicairkan",
|
label: "Total Dana Dicairkan",
|
||||||
value: `Rp ${(data && data?.totalPencairan) || 0}`,
|
value: `Rp ${(data && formatCurrencyDisplay(data?.totalPencairan)) || 0}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Sisa Dana Masuk",
|
label: "Sisa Dana Masuk",
|
||||||
@@ -207,7 +207,15 @@ export default function AdminDonationDetail() {
|
|||||||
iconLeft={
|
iconLeft={
|
||||||
<Ionicons name="cash-outline" size={ICON_SIZE_BUTTON} />
|
<Ionicons name="cash-outline" size={ICON_SIZE_BUTTON} />
|
||||||
}
|
}
|
||||||
|
disabled={data?.terkumpul - data?.totalPencairan <= 0}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
if (data?.terkumpul - data?.totalPencairan <= 0) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Tidak ada dana yang tersisa",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
router.push(`/admin/donation/${id}/disbursement-of-funds`);
|
router.push(`/admin/donation/${id}/disbursement-of-funds`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -227,7 +235,6 @@ export default function AdminDonationDetail() {
|
|||||||
/>
|
/>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
|
|
||||||
|
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
label={<TextCustom bold>Jumlah Donatur</TextCustom>}
|
label={<TextCustom bold>Jumlah Donatur</TextCustom>}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BaseBox,
|
BaseBox,
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
@@ -7,27 +8,53 @@ import {
|
|||||||
} 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 dayjs from "dayjs";
|
import { apiAdminDonationDisbursementOfFundsListById } from "@/service/api-admin/api-admin-donation";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { dateTimeView } from "@/utils/dateTimeView";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import React, { useCallback } from "react";
|
||||||
|
|
||||||
export default function AdminDonationDetailDisbursementOfFunds() {
|
export default function AdminDonationDetailDisbursementOfFunds() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = React.useState<any | null>(null);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminDonationDisbursementOfFundsListById({
|
||||||
|
id: id as string,
|
||||||
|
category: "get-one",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const listData = [
|
const listData = [
|
||||||
{
|
{
|
||||||
label: "Nominal",
|
label: "Nominal",
|
||||||
value: "Rp 1.000.000",
|
value: `Rp ${(data && formatCurrencyDisplay(data?.nominalCair)) || 0}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Tanggal",
|
label: "Tanggal",
|
||||||
value: dayjs().format("DD-MM-YYYY HH:mm"),
|
value: dateTimeView({ date: data?.createdAt }),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Judul",
|
label: "Judul",
|
||||||
value: `Judul Pencairan Dana ${id}`,
|
value: (data && data?.title) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Deskripsi",
|
label: "Deskripsi",
|
||||||
value: `Lorem ipsum dolor sit amet consectetur adipisicing elit. Itaque velit eos facere a dicta nemo repellendus harum laboriosam quos, earum reprehenderit. Nisi sapiente, quo earum quis alias ullam temporibus quidem.`,
|
value: (data && data?.deskripsi) || "-",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
return (
|
return (
|
||||||
@@ -39,7 +66,7 @@ export default function AdminDonationDetailDisbursementOfFunds() {
|
|||||||
>
|
>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
{listData.map((item, index) => (
|
{listData?.map((item, index) => (
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
key={index}
|
key={index}
|
||||||
label={<TextCustom bold>{item.label}</TextCustom>}
|
label={<TextCustom bold>{item.label}</TextCustom>}
|
||||||
@@ -51,7 +78,7 @@ export default function AdminDonationDetailDisbursementOfFunds() {
|
|||||||
|
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
onPress={() =>
|
onPress={() =>
|
||||||
router.push(`/(application)/(image)/preview-image/${id}`)
|
router.push(`/(application)/(image)/preview-image/${data?.imageId}`)
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
Cek Bukti Transaksi
|
Cek Bukti Transaksi
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BaseBox,
|
BaseBox,
|
||||||
BoxButtonOnFooter,
|
BoxButtonOnFooter,
|
||||||
@@ -12,15 +13,122 @@ import {
|
|||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
|
import { apiAdminDonationDetailById, apiAdminDonationDisbursementOfFundsCreated } from "@/service/api-admin/api-admin-donation";
|
||||||
|
import { uploadFileService } from "@/service/upload-service";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
|
import pickFile from "@/utils/pickFile";
|
||||||
|
import { Image } from "expo-image";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import React from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminDonationDisbursementOfFunds() {
|
export default function AdminDonationDisbursementOfFunds() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const handleSubmit = (
|
|
||||||
|
const [data, setData] = React.useState<any | null>(null);
|
||||||
|
const [isLoading, setIsLoading] = React.useState(false);
|
||||||
|
|
||||||
|
const [value, setValue] = React.useState({
|
||||||
|
nominalCair: "",
|
||||||
|
title: "",
|
||||||
|
deskripsi: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
const [image, setImage] = React.useState<any | null>(null);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
React.useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminDonationDetailById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data.donasi);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setData(null);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
if (!image) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Harap upload bukti transfer",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!value.nominalCair || !value.title || !value.deskripsi) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Harap isi semua data",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
const uploadImage = await uploadFileService({
|
||||||
|
dirId: DIRECTORY_ID.donasi_bukti_trf_pencairan_dana,
|
||||||
|
imageUri: image.uri,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!uploadFileService) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengunggah gambar",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const imageId = uploadImage.data.id;
|
||||||
|
|
||||||
|
const newData = {
|
||||||
|
...value,
|
||||||
|
imageId: imageId,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await apiAdminDonationDisbursementOfFundsCreated({
|
||||||
|
id: id as string,
|
||||||
|
data: newData,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Pencairan dana berhasil disimpan",
|
||||||
|
});
|
||||||
|
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttonSubmit = (
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.back();
|
handleSubmit();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
@@ -31,7 +139,7 @@ export default function AdminDonationDisbursementOfFunds() {
|
|||||||
return (
|
return (
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
headerComponent={<AdminBackButtonAntTitle title="Pencairan Dana" />}
|
headerComponent={<AdminBackButtonAntTitle title="Pencairan Dana" />}
|
||||||
footerComponent={handleSubmit}
|
footerComponent={buttonSubmit}
|
||||||
>
|
>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom gap="md">
|
<StackCustom gap="md">
|
||||||
@@ -39,7 +147,7 @@ export default function AdminDonationDisbursementOfFunds() {
|
|||||||
Dana Tersisa
|
Dana Tersisa
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom align="center" bold size="large">
|
<TextCustom align="center" bold size="large">
|
||||||
Rp 1.000.000
|
Rp {formatCurrencyDisplay(data?.terkumpul - data?.totalPencairan)}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
@@ -56,9 +164,27 @@ export default function AdminDonationDisbursementOfFunds() {
|
|||||||
label="Nominal"
|
label="Nominal"
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
iconLeft={"Rp"}
|
iconLeft={"Rp"}
|
||||||
|
value={value.nominalCair}
|
||||||
|
onChangeText={(text) => {
|
||||||
|
setValue({
|
||||||
|
...value,
|
||||||
|
nominalCair: text,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextInputCustom required label="Judul" placeholder="Masukan judul" />
|
<TextInputCustom
|
||||||
|
required
|
||||||
|
label="Judul"
|
||||||
|
placeholder="Masukan judul"
|
||||||
|
value={value.title}
|
||||||
|
onChangeText={(text) => {
|
||||||
|
setValue({
|
||||||
|
...value,
|
||||||
|
title: text,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
<TextAreaCustom
|
<TextAreaCustom
|
||||||
required
|
required
|
||||||
@@ -66,20 +192,37 @@ export default function AdminDonationDisbursementOfFunds() {
|
|||||||
placeholder="Masukan deskripsi"
|
placeholder="Masukan deskripsi"
|
||||||
showCount
|
showCount
|
||||||
maxLength={500}
|
maxLength={500}
|
||||||
|
value={value.deskripsi}
|
||||||
|
onChangeText={(text) => {
|
||||||
|
setValue({
|
||||||
|
...value,
|
||||||
|
deskripsi: text,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
<InformationBox text="Wajib menyertakan bukti transfer" />
|
|
||||||
|
|
||||||
|
<Spacing />
|
||||||
|
|
||||||
|
<InformationBox text="Wajib menyertakan bukti transfer" />
|
||||||
<ButtonCenteredOnly
|
<ButtonCenteredOnly
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.push(`/(application)/(image)/take-picture/${id}`);
|
pickFile({
|
||||||
|
allowedType: "image",
|
||||||
|
aspectRatio: [9, 16],
|
||||||
|
setImageUri: (file) => {
|
||||||
|
setImage(file);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
icon="upload"
|
icon="upload"
|
||||||
>
|
>
|
||||||
Upload
|
Upload
|
||||||
</ButtonCenteredOnly>
|
</ButtonCenteredOnly>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
|
<Image source={image?.uri} style={{ width: "100%", height: 300 }} />
|
||||||
|
<Spacing />
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,21 +1,54 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
CenterCustom,
|
CenterCustom,
|
||||||
Divider,
|
Divider,
|
||||||
StackCustom,
|
LoaderCustom,
|
||||||
TextCustom,
|
StackCustom,
|
||||||
ViewWrapper
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconView } from "@/components/_Icon/IconComponent";
|
import { IconView } from "@/components/_Icon/IconComponent";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
|
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
|
import { apiAdminDonationDisbursementOfFundsListById } from "@/service/api-admin/api-admin-donation";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import React, { useCallback } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function AdminDonasiListOfDisbursementOfFunds() {
|
export default function AdminDonasiListOfDisbursementOfFunds() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
const [listData, setListData] = React.useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = React.useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminDonationDisbursementOfFundsListById({
|
||||||
|
id: id as string,
|
||||||
|
category: "get-all",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
@@ -45,36 +78,47 @@ export default function AdminDonasiListOfDisbursementOfFunds() {
|
|||||||
/>
|
/>
|
||||||
<Divider />
|
<Divider />
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadData ? (
|
||||||
<View key={index}>
|
<LoaderCustom />
|
||||||
<GridViewCustomSpan
|
) : _.isEmpty(listData) ? (
|
||||||
span1={3}
|
<TextCustom align="center" color="gray">
|
||||||
span2={5}
|
Belum ada data
|
||||||
span3={4}
|
</TextCustom>
|
||||||
component1={
|
) : (
|
||||||
<CenterCustom>
|
listData?.map((item, index) => (
|
||||||
<ActionIcon
|
<View key={index}>
|
||||||
icon={<IconView size={ICON_SIZE_BUTTON} color="black" />}
|
<GridViewCustomSpan
|
||||||
onPress={() => {
|
span1={3}
|
||||||
router.push(
|
span2={5}
|
||||||
`/admin/donation/${id}/detail-disbursement-of-funds`
|
span3={4}
|
||||||
);
|
component1={
|
||||||
}}
|
<CenterCustom>
|
||||||
/>
|
<ActionIcon
|
||||||
</CenterCustom>
|
icon={
|
||||||
}
|
<IconView size={ICON_SIZE_BUTTON} color="black" />
|
||||||
component2={
|
}
|
||||||
<TextCustom bold align="center" truncate>
|
onPress={() => {
|
||||||
{dayjs()
|
router.push(
|
||||||
.add(index + 1, "day")
|
`/admin/donation/${item?.id}/detail-disbursement-of-funds`
|
||||||
.format("DD-MM-YYYY HH:mm")}
|
);
|
||||||
</TextCustom>
|
}}
|
||||||
}
|
/>
|
||||||
component3={<TextCustom>Rp. 1.000.000</TextCustom>}
|
</CenterCustom>
|
||||||
/>
|
}
|
||||||
<Divider />
|
component2={
|
||||||
</View>
|
<TextCustom align="center" truncate>
|
||||||
))}
|
{dayjs(item?.createdAt).format("DD-MM-YYYY")}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
component3={
|
||||||
|
<TextCustom align="center" truncate>
|
||||||
|
Rp. {formatCurrencyDisplay(item?.nominalCair)}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
@@ -11,7 +12,7 @@ import {
|
|||||||
Spacing,
|
Spacing,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconProspectus } from "@/components/_Icon";
|
import { IconProspectus } from "@/components/_Icon";
|
||||||
import { IconDot, IconList } from "@/components/_Icon/IconComponent";
|
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 AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
||||||
import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview";
|
import AdminButtonReview from "@/components/_ShareComponent/Admin/ButtonReview";
|
||||||
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
import { GridDetail_4_8 } from "@/components/_ShareComponent/GridDetail_4_8";
|
||||||
|
import ReportBox from "@/components/Box/ReportBox";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
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 _ from "lodash";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminInvestmentDetail() {
|
export default function AdminInvestmentDetail() {
|
||||||
const { id, status } = useLocalSearchParams();
|
const { id, status } = useLocalSearchParams();
|
||||||
const [openDrawer, setOpenDrawer] = React.useState(false);
|
const [openDrawer, setOpenDrawer] = React.useState(false);
|
||||||
|
|
||||||
const colorBadge = () => {
|
const [data, setData] = React.useState<any | null>(null);
|
||||||
if (status === "publish") {
|
const [isLoading, setLoading] = React.useState(false);
|
||||||
return MainColor.green;
|
|
||||||
} else if (status === "review") {
|
useFocusEffect(
|
||||||
return MainColor.orange;
|
React.useCallback(() => {
|
||||||
} else if (status === "reject") {
|
onLoadData();
|
||||||
return MainColor.red;
|
}, [id])
|
||||||
} else {
|
);
|
||||||
return MainColor.placeholder;
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminInvestmentDetailById({ id: id as string });
|
||||||
|
console.log("[GETONE INVEST]", JSON.stringify(response, null, 2));
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const listData = [
|
const listData = [
|
||||||
{
|
{
|
||||||
label: "Username",
|
label: "Username",
|
||||||
value: `Bagas Banuna ${id}`,
|
value: (data && data?.author?.username) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Judul",
|
label: "Judul",
|
||||||
value: `Donasi Lorem ipsum dolor sit amet, consectetur adipisicing elit.`,
|
value: (data && data?.title) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Status",
|
label: "Status",
|
||||||
value: (
|
value:
|
||||||
<BadgeCustom color={colorBadge()}>
|
data && data?.MasterStatusInvestasi?.name ? (
|
||||||
{_.startCase(status as string)}
|
<BadgeCustom
|
||||||
</BadgeCustom>
|
color={colorBadgeStatus({
|
||||||
),
|
status: data?.MasterStatusInvestasi?.name as string,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{_.startCase(data?.MasterStatusInvestasi?.name as string)}
|
||||||
|
</BadgeCustom>
|
||||||
|
) : (
|
||||||
|
"-"
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Dana Dibutuhkan",
|
label: "Dana Dibutuhkan",
|
||||||
value: "Rp 10.000.000",
|
value: `Rp. ${
|
||||||
|
(data && data?.targetDana && formatCurrencyDisplay(data?.targetDana)) ||
|
||||||
|
"-"
|
||||||
|
}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Harga Perlembar",
|
label: "Harga Perlembar",
|
||||||
value: "Rp 2500",
|
value: `Rp. ${
|
||||||
|
(data &&
|
||||||
|
data?.hargaLembar &&
|
||||||
|
formatCurrencyDisplay(data?.hargaLembar)) ||
|
||||||
|
"-"
|
||||||
|
}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Total Lembar",
|
label: "Total Lembar",
|
||||||
value: "2490 lembar",
|
value:
|
||||||
|
(data &&
|
||||||
|
data?.totalLembar &&
|
||||||
|
formatCurrencyDisplay(data?.totalLembar)) ||
|
||||||
|
"-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "ROI",
|
label: "ROI",
|
||||||
value: "4 %",
|
value: `${(data && data?.roi && data?.roi) || 0} %`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Pembagian Deviden",
|
label: "Pembagian Deviden",
|
||||||
value: "3 bulan",
|
value: (data && data?.MasterPembagianDeviden?.name) + " bulan" || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Jadwal Pembagian",
|
label: "Jadwal Pembagian",
|
||||||
value: "Selamanya",
|
value: (data && data?.MasterPeriodeDeviden?.name) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Pencarian Investor",
|
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("[GET ON INVEST]", 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 = (
|
const rightComponent = (
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
icon={<IconDot size={ICON_SIZE_BUTTON} />}
|
icon={<IconDot size={ICON_SIZE_BUTTON} />}
|
||||||
@@ -114,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>
|
||||||
@@ -126,7 +195,7 @@ export default function AdminInvestmentDetail() {
|
|||||||
|
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<DummyLandscapeImage />
|
<DummyLandscapeImage imageId={data?.imageId} />
|
||||||
{listData.map((item, i) => (
|
{listData.map((item, i) => (
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
key={i}
|
key={i}
|
||||||
@@ -150,7 +219,9 @@ export default function AdminInvestmentDetail() {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.push(`/(application)/(file)/${id}`);
|
router.push(
|
||||||
|
`/(application)/(file)/${data?.prospektusFileId}`
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Preview
|
Preview
|
||||||
@@ -161,46 +232,66 @@ export default function AdminInvestmentDetail() {
|
|||||||
label={<TextCustom bold>File Dokumen</TextCustom>}
|
label={<TextCustom bold>File Dokumen</TextCustom>}
|
||||||
value={
|
value={
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
{Array.from({ length: 5 }).map((_, i) => (
|
{_.isEmpty(data?.DokumenInvestasi) ? (
|
||||||
<ButtonCustom
|
<TextCustom align="center">-</TextCustom>
|
||||||
key={i}
|
) : (
|
||||||
iconLeft={
|
data?.DokumenInvestasi?.map((item: any, index: number) => {
|
||||||
<IconProspectus
|
const titleFix = item?.title?.substring(0, 10) || "";
|
||||||
size={ICON_SIZE_BUTTON}
|
|
||||||
color={MainColor.darkblue}
|
return (
|
||||||
/>
|
<ButtonCustom
|
||||||
}
|
key={item.id || index} // ✅ pastikan key unik
|
||||||
onPress={() => {
|
iconLeft={
|
||||||
router.push(`/(application)/(file)/${id}`);
|
<IconProspectus
|
||||||
}}
|
size={ICON_SIZE_BUTTON}
|
||||||
>
|
color={MainColor.darkblue}
|
||||||
Dokumen {i + 1}
|
/>
|
||||||
</ButtonCustom>
|
}
|
||||||
))}
|
onPress={() => {
|
||||||
|
router.push(
|
||||||
|
`/(application)/(file)/${item?.fileId}`
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextCustom color="black" truncate>
|
||||||
|
{titleFix}...
|
||||||
|
</TextCustom>
|
||||||
|
</ButtonCustom>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
|
{data &&
|
||||||
|
data?.catatan &&
|
||||||
|
(status === "review" || status === "reject") && (
|
||||||
|
<ReportBox text={data?.catatan} />
|
||||||
|
)}
|
||||||
|
|
||||||
{status === "review" && (
|
{status === "review" && (
|
||||||
<AdminButtonReview
|
<AdminButtonReview
|
||||||
|
isLoading={isLoading}
|
||||||
onPublish={() => {
|
onPublish={() => {
|
||||||
AlertDefaultSystem({
|
AlertDefaultSystem({
|
||||||
title: "Publish",
|
title: "Publish",
|
||||||
message: "Apakah anda yakin ingin mempublikasikan data ini?",
|
message: "Apakah anda yakin ingin mempublikasikan data ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Ya",
|
textRight: "Ya",
|
||||||
onPressLeft: () => {
|
|
||||||
router.back();
|
|
||||||
},
|
|
||||||
onPressRight: () => {
|
onPressRight: () => {
|
||||||
router.back();
|
handlerSubmitPublish();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
onReject={() => {
|
onReject={() => {
|
||||||
router.push(`/admin/investment/${id}/reject-input`);
|
router.push(
|
||||||
|
`/admin/investment/${id}/reject-input?status=${_.lowerCase(
|
||||||
|
data?.MasterStatusInvestasi?.name
|
||||||
|
)}`
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,67 +1,211 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
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 GridTwoView from "@/components/_ShareComponent/GridTwoView";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import dayjs from "dayjs";
|
import {
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
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() {
|
export default function AdminInvestmentTransactionDetail() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
console.log("[ID]", id);
|
||||||
|
|
||||||
const buttonAction = (
|
const [data, setData] = useState<any | null>(null);
|
||||||
<BoxButtonOnFooter>
|
const [isLoading, setLoading] = useState<boolean>(false);
|
||||||
<ButtonCustom onPress={() => router.back()}>Terima</ButtonCustom>
|
|
||||||
</BoxButtonOnFooter>
|
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 listData = [
|
const listData = [
|
||||||
{
|
{
|
||||||
label: "Investor",
|
label: "Investor",
|
||||||
value: "Bagas Banuna",
|
value: (data && data?.Author?.username) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Bank",
|
label: "Bank",
|
||||||
value: "BCA",
|
value: (data && data?.MasterBank?.namaBank) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Jumlah Investasi",
|
label: "Jumlah Investasi",
|
||||||
value: "Rp. 1.000.000",
|
value: (data && `Rp. ${formatCurrencyDisplay(data?.nominal)}`) || "-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Lembar terbeli",
|
||||||
|
value: (data && formatCurrencyDisplay(data?.lembarTerbeli)) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Status",
|
label: "Status",
|
||||||
value: <BadgeCustom color={MainColor.green}>Berhasil</BadgeCustom>,
|
value:
|
||||||
|
data && data?.StatusInvoice?.name ? (
|
||||||
|
<BadgeCustom
|
||||||
|
color={colorBadgeTransaction({
|
||||||
|
status: data?.StatusInvoice?.name,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{data?.StatusInvoice?.name}
|
||||||
|
</BadgeCustom>
|
||||||
|
) : (
|
||||||
|
"-"
|
||||||
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Tanggal",
|
label: "Tanggal",
|
||||||
value: dayjs().format("DD-MM-YYYY HH:mm:ss"),
|
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/${id}`)
|
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={<AdminBackButtonAntTitle title="Detail Transaksi Investor" />}
|
headerComponent={
|
||||||
footerComponent={buttonAction}
|
<AdminBackButtonAntTitle title="Detail Transaksi Investor" />
|
||||||
|
}
|
||||||
|
// footerComponent={buttonAction()}
|
||||||
>
|
>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
@@ -74,6 +218,8 @@ export default function AdminInvestmentTransactionDetail() {
|
|||||||
))}
|
))}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
<Spacing />
|
||||||
|
{buttonAction()}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
BadgeCustom,
|
BadgeCustom,
|
||||||
CenterCustom,
|
CenterCustom,
|
||||||
|
LoaderCustom,
|
||||||
SelectCustom,
|
SelectCustom,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
@@ -10,23 +12,100 @@ import {
|
|||||||
import { IconView } from "@/components/_Icon/IconComponent";
|
import { IconView } from "@/components/_Icon/IconComponent";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
|
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
|
||||||
|
import NoDataText from "@/components/_ShareComponent/NoDataText";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
import { dummyMasterStatusTransaction } from "@/lib/dummy-data/_master/status-transaction";
|
import { dummyMasterStatusTransaction } from "@/lib/dummy-data/_master/status-transaction";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { apiAdminInvestmentListOfInvestor } from "@/service/api-admin/api-admin-investment";
|
||||||
import React from "react";
|
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 { View } from "react-native";
|
||||||
import { Divider } from "react-native-paper";
|
import { Divider } from "react-native-paper";
|
||||||
|
|
||||||
export default function AdminInvestmentListOfInvestor() {
|
export default function AdminInvestmentListOfInvestor() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
console.log("[ID]", id);
|
||||||
|
|
||||||
|
const [listData, setListData] = React.useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = React.useState(false);
|
||||||
|
const [master, setMaster] = React.useState<any[]>([]);
|
||||||
|
|
||||||
|
const [selectValue, setSelectValue] = React.useState<string | null>(null);
|
||||||
|
const [selectedStatus, setSelectedStatus] = React.useState<string | null>(
|
||||||
|
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 = (
|
const searchComponent = (
|
||||||
<View style={{ flexDirection: "row", gap: 5 }}>
|
<View style={{ flexDirection: "row", gap: 5 }}>
|
||||||
<SelectCustom
|
<SelectCustom
|
||||||
placeholder="Pilih status transaksi"
|
placeholder="Pilih status transaksi"
|
||||||
data={dummyMasterStatusTransaction}
|
data={
|
||||||
onChange={(value) => console.log(value)}
|
_.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 }}
|
styleContainer={{ width: "100%", marginBottom: 0 }}
|
||||||
|
allowClear
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
@@ -40,66 +119,77 @@ export default function AdminInvestmentListOfInvestor() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper headerComponent={headerComponent}>
|
||||||
headerComponent={headerComponent}
|
|
||||||
>
|
|
||||||
<GridViewCustomSpan
|
|
||||||
span1={3}
|
|
||||||
span2={5}
|
|
||||||
span3={4}
|
|
||||||
component1={
|
|
||||||
<TextCustom bold align="center">
|
|
||||||
Aksi
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
component2={
|
|
||||||
<TextCustom bold align="center">
|
|
||||||
Investor
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
component3={
|
|
||||||
<TextCustom bold align="center">
|
|
||||||
Status
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Divider />
|
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
<GridViewCustomSpan
|
||||||
<View key={index}>
|
span1={3}
|
||||||
<GridViewCustomSpan
|
span2={5}
|
||||||
span1={3}
|
span3={4}
|
||||||
span2={5}
|
component1={
|
||||||
span3={4}
|
<TextCustom bold align="center">
|
||||||
component1={
|
Aksi
|
||||||
<CenterCustom>
|
</TextCustom>
|
||||||
<ActionIcon
|
}
|
||||||
icon={<IconView size={ICON_SIZE_BUTTON} color="black" />}
|
component2={
|
||||||
onPress={() => {
|
<TextCustom bold align="center">
|
||||||
router.push(
|
Investor
|
||||||
`/admin/investment/${id}/berhasil/transaction-detail`
|
</TextCustom>
|
||||||
);
|
}
|
||||||
}}
|
component3={
|
||||||
/>
|
<TextCustom bold align="center">
|
||||||
</CenterCustom>
|
Status
|
||||||
}
|
</TextCustom>
|
||||||
component2={
|
}
|
||||||
<TextCustom bold align="center" truncate>
|
/>
|
||||||
Bagas Banuna
|
<Divider />
|
||||||
</TextCustom>
|
<StackCustom>
|
||||||
}
|
{loadData ? (
|
||||||
component3={
|
<LoaderCustom />
|
||||||
<BadgeCustom
|
) : _.isEmpty(listData) ? (
|
||||||
style={{ alignSelf: "center" }}
|
<NoDataText />
|
||||||
color={MainColor.green}
|
) : (
|
||||||
>
|
listData?.map((item: any, index: number) => (
|
||||||
Berhasil
|
<View key={index}>
|
||||||
</BadgeCustom>
|
<GridViewCustomSpan
|
||||||
}
|
span1={3}
|
||||||
/>
|
span2={5}
|
||||||
<Divider />
|
span3={4}
|
||||||
</View>
|
component1={
|
||||||
))}
|
<CenterCustom>
|
||||||
|
<ActionIcon
|
||||||
|
icon={
|
||||||
|
<IconView size={ICON_SIZE_BUTTON} color="black" />
|
||||||
|
}
|
||||||
|
onPress={() => {
|
||||||
|
router.push(
|
||||||
|
`/admin/investment/${item?.id}/${_.lowerCase(
|
||||||
|
item?.StatusInvoice?.name
|
||||||
|
)}/transaction-detail`
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</CenterCustom>
|
||||||
|
}
|
||||||
|
component2={
|
||||||
|
<TextCustom bold align="center" truncate>
|
||||||
|
{item?.Author?.username || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
component3={
|
||||||
|
<BadgeCustom
|
||||||
|
style={{ alignSelf: "center" }}
|
||||||
|
color={colorBadgeTransaction({
|
||||||
|
status: item?.StatusInvoice?.name,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{item?.StatusInvoice?.name}
|
||||||
|
</BadgeCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
BoxButtonOnFooter,
|
BoxButtonOnFooter,
|
||||||
@@ -6,15 +7,83 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { apiAdminInvestasiUpdateByStatus, apiAdminInvestmentDetailById } from "@/service/api-admin/api-admin-investment";
|
||||||
import { useState } from "react";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminInvestmentRejectInput() {
|
export default function AdminInvestmentRejectInput() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id, status } = useLocalSearchParams();
|
||||||
const [value, setValue] = useState(id as string);
|
console.log("[STATUS]", status);
|
||||||
|
const [value, setValue] = useState<any | null>(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 = (
|
const buttonSubmit = (
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<AdminButtonReject
|
<AdminButtonReject
|
||||||
|
isLoading={isLoading}
|
||||||
title="Reject"
|
title="Reject"
|
||||||
onReject={() =>
|
onReject={() =>
|
||||||
AlertDefaultSystem({
|
AlertDefaultSystem({
|
||||||
@@ -22,12 +91,8 @@ export default function AdminInvestmentRejectInput() {
|
|||||||
message: "Apakah anda yakin ingin menolak data ini?",
|
message: "Apakah anda yakin ingin menolak data ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Ya",
|
textRight: "Ya",
|
||||||
onPressLeft: () => {
|
|
||||||
router.back();
|
|
||||||
},
|
|
||||||
onPressRight: () => {
|
onPressRight: () => {
|
||||||
console.log("value:", value);
|
handlerSubmit();
|
||||||
router.replace(`/admin/investment/reject/status`);
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -39,7 +104,9 @@ export default function AdminInvestmentRejectInput() {
|
|||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
footerComponent={buttonSubmit}
|
footerComponent={buttonSubmit}
|
||||||
headerComponent={<AdminBackButtonAntTitle title="Penolakan Investasi" />}
|
headerComponent={
|
||||||
|
<AdminBackButtonAntTitle title="Penolakan Investasi" />
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<TextAreaCustom
|
<TextAreaCustom
|
||||||
value={value}
|
value={value}
|
||||||
|
|||||||
@@ -1,69 +1,114 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
SearchInput,
|
LoaderCustom,
|
||||||
Spacing,
|
SearchInput,
|
||||||
TextCustom,
|
StackCustom,
|
||||||
ViewWrapper
|
TextCustom,
|
||||||
|
ViewWrapper
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
||||||
import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle";
|
import AdminTitleTable from "@/components/_ShareComponent/Admin/TableTitle";
|
||||||
import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
import AdminTableValue from "@/components/_ShareComponent/Admin/TableValue";
|
||||||
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
|
import NoDataText from "@/components/_ShareComponent/NoDataText";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
|
import { apiAdminInvestment } from "@/service/api-admin/api-admin-investment";
|
||||||
import { Octicons } from "@expo/vector-icons";
|
import { Octicons } from "@expo/vector-icons";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
|
import React, { useCallback } from "react";
|
||||||
import { Divider } from "react-native-paper";
|
import { Divider } from "react-native-paper";
|
||||||
|
|
||||||
export default function AdminInvestmentStatus() {
|
export default function AdminInvestmentStatus() {
|
||||||
const { status } = useLocalSearchParams();
|
const { status } = useLocalSearchParams();
|
||||||
|
console.log("[STATUS]", status);
|
||||||
|
|
||||||
|
const [listData, setListData] = React.useState<any[] | null>(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 = (
|
const rightComponent = (
|
||||||
<SearchInput
|
<SearchInput
|
||||||
containerStyle={{ width: "100%", marginBottom: 0 }}
|
containerStyle={{ width: "100%", marginBottom: 0 }}
|
||||||
placeholder="Cari"
|
placeholder="Cari"
|
||||||
|
value={search}
|
||||||
|
onChangeText={setSearch}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper headerComponent={<AdminTitlePage title="Investasi" />}>
|
||||||
headerComponent={
|
<StackCustom gap={"sm"}>
|
||||||
<AdminComp_BoxTitle
|
<AdminComp_BoxTitle
|
||||||
title={`Investasi ${_.startCase(status as string)}`}
|
title={`${_.startCase(status as string)}`}
|
||||||
rightComponent={rightComponent}
|
rightComponent={rightComponent}
|
||||||
/>
|
/>
|
||||||
}
|
<AdminTitleTable
|
||||||
>
|
title1="Aksi"
|
||||||
<AdminTitleTable
|
title2="Username"
|
||||||
title1="Aksi"
|
title3="Judul Investasi"
|
||||||
title2="Username"
|
|
||||||
title3="Judul Investasi"
|
|
||||||
/>
|
|
||||||
<Spacing />
|
|
||||||
<Divider />
|
|
||||||
|
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
|
||||||
<AdminTableValue
|
|
||||||
key={index}
|
|
||||||
value1={
|
|
||||||
<ActionIcon
|
|
||||||
icon={
|
|
||||||
<Octicons name="eye" size={ICON_SIZE_BUTTON} color="black" />
|
|
||||||
}
|
|
||||||
onPress={() => {
|
|
||||||
router.push(`/admin/investment/${index}/${status}`);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
value2={<TextCustom truncate={1}>Username username</TextCustom>}
|
|
||||||
value3={
|
|
||||||
<TextCustom truncate={2}>
|
|
||||||
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.
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
))}
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
{loadData ? (
|
||||||
|
<LoaderCustom />
|
||||||
|
) : _.isEmpty(listData) ? (
|
||||||
|
<NoDataText />
|
||||||
|
) : (
|
||||||
|
listData?.map((item: any, index: number) => (
|
||||||
|
<AdminTableValue
|
||||||
|
key={index}
|
||||||
|
value1={
|
||||||
|
<ActionIcon
|
||||||
|
icon={
|
||||||
|
<Octicons
|
||||||
|
name="eye"
|
||||||
|
size={ICON_SIZE_BUTTON}
|
||||||
|
color="black"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
onPress={() => {
|
||||||
|
router.push(`/admin/investment/${item.id}/${status}`);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
value2={<TextCustom truncate={1}>{item?.author?.username}</TextCustom>}
|
||||||
|
value3={
|
||||||
|
<TextCustom truncate={2}>
|
||||||
|
{item?.title}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -7,8 +7,51 @@ import {
|
|||||||
import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard";
|
import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard";
|
||||||
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
import AdminTitlePage from "@/components/_ShareComponent/Admin/TitlePage";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
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() {
|
export default function AdminInvestment() {
|
||||||
|
const [data, setData] = React.useState<any | null>(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: <IconPublish size={25} color={MainColor.green} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Review",
|
||||||
|
value: (data && data.review) || 0,
|
||||||
|
icon: <IconReview size={25} color={MainColor.orange} />,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Reject",
|
||||||
|
value: (data && data.reject) || 0,
|
||||||
|
icon: <IconReject size={25} color={MainColor.red} />,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
@@ -23,21 +66,3 @@ export default function AdminInvestment() {
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const listData = [
|
|
||||||
{
|
|
||||||
label: "Publish",
|
|
||||||
value: 3,
|
|
||||||
icon: <IconPublish size={25} color={MainColor.green} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Review",
|
|
||||||
value: 5,
|
|
||||||
icon: <IconReview size={25} color={MainColor.orange} />,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: "Reject",
|
|
||||||
value: 8,
|
|
||||||
icon: <IconReject size={25} color={MainColor.red} />,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|||||||
9
components/_ShareComponent/NoDataText.tsx
Normal file
9
components/_ShareComponent/NoDataText.tsx
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import TextCustom from "../Text/TextCustom";
|
||||||
|
|
||||||
|
export default function NoDataText({ text }: { text?: string }) {
|
||||||
|
return (
|
||||||
|
<TextCustom color="gray" align="center" bold size={"small"}>
|
||||||
|
{text ? text : "Belum ada data"}
|
||||||
|
</TextCustom>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -22,7 +22,7 @@ export default function Donation_BoxPublish({
|
|||||||
sisa: 0,
|
sisa: 0,
|
||||||
reminder: false,
|
reminder: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
updateCountDown();
|
updateCountDown();
|
||||||
}, [data]);
|
}, [data]);
|
||||||
|
|||||||
96
screens/Invesment/BoxBerandaSection.tsx
Normal file
96
screens/Invesment/BoxBerandaSection.tsx
Normal file
@@ -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 (
|
||||||
|
<>
|
||||||
|
<BaseBox paddingTop={7} paddingBottom={7} href={`/investment/${id}`}>
|
||||||
|
<Grid>
|
||||||
|
<Grid.Col span={5}>
|
||||||
|
<Image
|
||||||
|
source={
|
||||||
|
data && data.imageId
|
||||||
|
? API_STRORAGE.GET({ fileId: data.imageId })
|
||||||
|
: DUMMY_IMAGE.background
|
||||||
|
}
|
||||||
|
style={{ width: "auto", height: 100, borderRadius: 10 }}
|
||||||
|
/>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={1}>
|
||||||
|
<View />
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={6}>
|
||||||
|
<StackCustom>
|
||||||
|
<TextCustom truncate={2}>{data.title}</TextCustom>
|
||||||
|
<ProgressCustom
|
||||||
|
label={`${data.progress}%`}
|
||||||
|
value={data.progress}
|
||||||
|
size="lg"
|
||||||
|
/>
|
||||||
|
{value.reminder ? (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 5,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Ionicons name="alert-circle-outline" size={16} color="red" />
|
||||||
|
<TextCustom truncate color="red" size="small">
|
||||||
|
Periode Investasi Berakhir
|
||||||
|
</TextCustom>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<TextCustom>
|
||||||
|
Sisa waktu: {value.sisa} hari
|
||||||
|
</TextCustom>
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</BaseBox>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -7,7 +7,7 @@ export default function Invesment_BoxProgressSection({progress, status}: {progre
|
|||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<TextCustom bold>Progress Saham</TextCustom>
|
<TextCustom bold>Progress Saham</TextCustom>
|
||||||
<ProgressCustom label={progress + "%"} value={progress} size="lg" />
|
<ProgressCustom label={(progress || 0) + "%"} value={progress || 0} size="lg" />
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -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 {
|
import {
|
||||||
listDataNotPublishInvesment,
|
listDataNotPublishInvesment,
|
||||||
listDataPublishInvesment,
|
listDataPublishInvesment,
|
||||||
} from "@/lib/dummy-data/investment/dummy-data-not-publish";
|
} 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_BoxDetailDataSection from "./BoxDetailDataSection";
|
||||||
import Invesment_BoxProgressSection from "./BoxProgressSection";
|
import Invesment_BoxProgressSection from "./BoxProgressSection";
|
||||||
import Investment_ButtonStatusSection from "./ButtonStatusSection";
|
import Investment_ButtonStatusSection from "./ButtonStatusSection";
|
||||||
@@ -19,11 +22,39 @@ export default function Invesment_DetailDataPublishSection({
|
|||||||
bottomSection?: React.ReactNode;
|
bottomSection?: React.ReactNode;
|
||||||
buttonSection?: 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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<StackCustom gap={"sm"}>
|
<StackCustom gap={"sm"}>
|
||||||
<Invesment_BoxProgressSection progress={data?.progress} status={status as string} />
|
{data &&
|
||||||
|
data?.catatan &&
|
||||||
|
(status === "draft" || status === "reject") && (
|
||||||
|
<ReportBox text={data?.catatan} />
|
||||||
|
)}
|
||||||
|
<Invesment_BoxProgressSection
|
||||||
|
progress={data?.progress}
|
||||||
|
status={status as string}
|
||||||
|
/>
|
||||||
<Invesment_BoxDetailDataSection
|
<Invesment_BoxDetailDataSection
|
||||||
title={data?.title}
|
title={data?.title}
|
||||||
author={data?.author}
|
author={data?.author}
|
||||||
@@ -35,11 +66,18 @@ export default function Invesment_DetailDataPublishSection({
|
|||||||
}
|
}
|
||||||
bottomSection={bottomSection}
|
bottomSection={bottomSection}
|
||||||
/>
|
/>
|
||||||
<Investment_ButtonStatusSection
|
|
||||||
id={data?.id}
|
{value.reminder ? (
|
||||||
status={status as string}
|
<ButtonCustom disabled>
|
||||||
buttonPublish={buttonSection}
|
Periode Investasi Berakhir
|
||||||
/>
|
</ButtonCustom>
|
||||||
|
) : (
|
||||||
|
<Investment_ButtonStatusSection
|
||||||
|
id={data?.id}
|
||||||
|
status={status as string}
|
||||||
|
buttonPublish={buttonSection}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -103,3 +103,52 @@ export async function apiAdminDonationInvoiceUpdateById({
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationListOfDonaturById({
|
||||||
|
id,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/donation/${id}/donatur`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationDisbursementOfFundsCreated({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.post(
|
||||||
|
`/mobile/admin/donation/${id}/disbursement`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationDisbursementOfFundsListById({
|
||||||
|
id,
|
||||||
|
category,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
category: "get-all" | "get-one"
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/admin/donation/${id}/disbursement?category=${category}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
113
service/api-admin/api-admin-investment.ts
Normal file
113
service/api-admin/api-admin-investment.ts
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -255,3 +255,16 @@ export async function apiDonationDeleteNews({ id }: { id: string }) {
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function apiDonationDisbursementOfFundsListById({
|
||||||
|
id,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/donation/${id}/disbursement`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -13,19 +13,28 @@ export interface IFileData {
|
|||||||
|
|
||||||
export type AllowedFileType = "image" | "pdf" | undefined;
|
export type AllowedFileType = "image" | "pdf" | undefined;
|
||||||
|
|
||||||
|
export type AspectRatio = [number, number];
|
||||||
|
|
||||||
export interface PickFileOptions {
|
export interface PickFileOptions {
|
||||||
setImageUri?: (file: IFileData) => void;
|
setImageUri?: (file: IFileData) => void;
|
||||||
setPdfUri?: (file: IFileData) => void;
|
setPdfUri?: (file: IFileData) => void;
|
||||||
allowedType?: AllowedFileType; // <-- Tambahkan prop ini
|
allowedType?: AllowedFileType; // <-- Tambahkan prop ini
|
||||||
|
aspectRatio?: AspectRatio;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function pickFile({
|
export default async function pickFile({
|
||||||
setImageUri,
|
setImageUri,
|
||||||
setPdfUri,
|
setPdfUri,
|
||||||
allowedType,
|
allowedType,
|
||||||
|
aspectRatio,
|
||||||
}: PickFileOptions): Promise<void> {
|
}: PickFileOptions): Promise<void> {
|
||||||
if (allowedType === "image") {
|
if (allowedType === "image") {
|
||||||
await pickImage(setImageUri);
|
if (aspectRatio) {
|
||||||
|
await pickImage(setImageUri, aspectRatio);
|
||||||
|
} else {
|
||||||
|
// Jika tidak, tawarkan pilihan rasio (default [4,3])
|
||||||
|
showAspectRatioChoice(setImageUri);
|
||||||
|
}
|
||||||
} else if (allowedType === "pdf") {
|
} else if (allowedType === "pdf") {
|
||||||
await pickPdf(setPdfUri);
|
await pickPdf(setPdfUri);
|
||||||
} else {
|
} else {
|
||||||
@@ -36,15 +45,45 @@ export default async function pickFile({
|
|||||||
[
|
[
|
||||||
{ text: "Batal", style: "cancel" },
|
{ text: "Batal", style: "cancel" },
|
||||||
{ text: "Dokumen (PDF)", onPress: () => pickPdf(setPdfUri) },
|
{ text: "Dokumen (PDF)", onPress: () => pickPdf(setPdfUri) },
|
||||||
{ text: "Gambar", onPress: () => pickImage(setImageUri) },
|
{ text: "Gambar", onPress: () => pickImage(setImageUri, aspectRatio) },
|
||||||
],
|
],
|
||||||
{ cancelable: true }
|
{ cancelable: true }
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function showAspectRatioChoice(setImageUri?: (file: IFileData) => void) {
|
||||||
|
Alert.alert(
|
||||||
|
"Pilih Rasio Gambar",
|
||||||
|
"Pilih rasio crop yang diinginkan:",
|
||||||
|
[
|
||||||
|
{ text: "Batal", style: "cancel" },
|
||||||
|
{
|
||||||
|
text: "1:1 (Kotak)",
|
||||||
|
onPress: () => pickImage(setImageUri, [1, 1]),
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// text: "4:3 (Default)",
|
||||||
|
// onPress: () => pickImage(setImageUri, [4, 3]),
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// text: "9:16 (Landscape)",
|
||||||
|
// onPress: () => pickImage(setImageUri, [9, 16]),
|
||||||
|
// },
|
||||||
|
{
|
||||||
|
text: "3:4 (Potret)",
|
||||||
|
onPress: () => pickImage(setImageUri, [3, 4]),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
{ cancelable: true }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// --- Fungsi internal: pickImage ---
|
// --- Fungsi internal: pickImage ---
|
||||||
async function pickImage(setImageUri?: (file: IFileData) => void) {
|
async function pickImage(
|
||||||
|
setImageUri?: (file: IFileData) => void,
|
||||||
|
aspectRatio: AspectRatio = [4, 3] // Default [4, 3]
|
||||||
|
) {
|
||||||
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
const { status } = await ImagePicker.requestMediaLibraryPermissionsAsync();
|
||||||
if (status !== "granted") {
|
if (status !== "granted") {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
@@ -57,7 +96,7 @@ async function pickImage(setImageUri?: (file: IFileData) => void) {
|
|||||||
const result = await ImagePicker.launchImageLibraryAsync({
|
const result = await ImagePicker.launchImageLibraryAsync({
|
||||||
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
mediaTypes: ImagePicker.MediaTypeOptions.Images,
|
||||||
allowsEditing: true,
|
allowsEditing: true,
|
||||||
aspect: [4, 3],
|
aspect: aspectRatio, // 🎯 Gunakan rasio dinamis
|
||||||
quality: 1,
|
quality: 1,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user