Compare commits
2 Commits
api-admin/
...
api-admin/
| Author | SHA1 | Date | |
|---|---|---|---|
| b3209dc7ee | |||
| 1e1b18f860 |
@@ -122,7 +122,7 @@ export default function DonationInvoice() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TextCustom size="xlarge" bold color="yellow">
|
<TextCustom size="xlarge" bold color="yellow">
|
||||||
{data?.DonasiMaster_Bank?.norek}
|
{data?.MasterBank?.norek}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col
|
<Grid.Col
|
||||||
@@ -131,7 +131,7 @@ export default function DonationInvoice() {
|
|||||||
alignItems: "flex-end",
|
alignItems: "flex-end",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<CopyButton textToCopy={data?.DonasiMaster_Bank?.norek} />
|
<CopyButton textToCopy={data?.MasterBank?.norek} />
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|||||||
@@ -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>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ export default function DonasiDetailBeranda() {
|
|||||||
sisaHari={value.sisa}
|
sisaHari={value.sisa}
|
||||||
reminder={value.reminder}
|
reminder={value.reminder}
|
||||||
data={data}
|
data={data}
|
||||||
bottomSection={<Donation_ProgressSection id={id as string} />}
|
bottomSection={<Donation_ProgressSection id={id as string} progres={Number(data?.progres) || 0} />}
|
||||||
/>
|
/>
|
||||||
<Donation_ComponentInfoFundrising dataAuthor={data?.Author} />
|
<Donation_ComponentInfoFundrising dataAuthor={data?.Author} />
|
||||||
<Donation_ComponentStoryFunrising
|
<Donation_ComponentStoryFunrising
|
||||||
|
|||||||
@@ -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>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ export default function AdminDonationDetail() {
|
|||||||
const [openDrawer, setOpenDrawer] = React.useState(false);
|
const [openDrawer, setOpenDrawer] = React.useState(false);
|
||||||
|
|
||||||
const [data, setData] = React.useState<any | null>(null);
|
const [data, setData] = React.useState<any | null>(null);
|
||||||
|
const [countDonatur, setCountDonatur] = React.useState(0);
|
||||||
const [isLoading, setIsLoading] = React.useState(false);
|
const [isLoading, setIsLoading] = React.useState(false);
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
@@ -52,10 +53,9 @@ 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);
|
setData(response.data.donasi);
|
||||||
|
setCountDonatur(response.data.donatur);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
@@ -77,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>
|
||||||
@@ -105,15 +107,19 @@ 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",
|
label: "Sisa Dana Masuk",
|
||||||
value: `Rp ${(data && data?.terkumpul - data?.totalPencairan) || 0}`,
|
value: `Rp ${
|
||||||
|
(data &&
|
||||||
|
formatCurrencyDisplay(data?.terkumpul - data?.totalPencairan)) ||
|
||||||
|
0
|
||||||
|
}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Akumulasi Pencairan",
|
label: "Akumulasi Pencairan",
|
||||||
value: `${(data && data?.totalPencairan) || 0} kali`,
|
value: `${(data && data?.akumulasiPencairan) || 0} kali`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Bank Tujuan",
|
label: "Bank Tujuan",
|
||||||
@@ -196,12 +202,20 @@ export default function AdminDonationDetail() {
|
|||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
|
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
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`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -211,16 +225,32 @@ export default function AdminDonationDetail() {
|
|||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<ProgressCustom size="lg" />
|
<ProgressCustom
|
||||||
|
size="lg"
|
||||||
|
value={Number(data?.progres) || 0}
|
||||||
|
showLabel={true}
|
||||||
|
label={data?.progres + "%"}
|
||||||
|
animated
|
||||||
|
color="primary"
|
||||||
|
/>
|
||||||
<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>}
|
||||||
value={<TextCustom>0 orang</TextCustom>}
|
value={
|
||||||
|
<TextCustom>
|
||||||
|
{countDonatur ? countDonatur : 0} orang
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<GridDetail_4_8
|
<GridDetail_4_8
|
||||||
label={<TextCustom bold>Dana Terkumpul</TextCustom>}
|
label={<TextCustom bold>Dana Terkumpul</TextCustom>}
|
||||||
value={<TextCustom>Rp 0</TextCustom>}
|
value={
|
||||||
|
<TextCustom>
|
||||||
|
Rp {formatCurrencyDisplay(data?.terkumpul || 0)}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|||||||
@@ -9,51 +9,162 @@ 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 { MainColor } from "@/constants/color-palet";
|
import {
|
||||||
import dayjs from "dayjs";
|
apiAdminDonationInvoiceDetailById,
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
apiAdminDonationInvoiceUpdateById,
|
||||||
|
} from "@/service/api-admin/api-admin-donation";
|
||||||
|
import { colorBadgeTransaction } from "@/utils/colorBadge";
|
||||||
|
import { dateTimeView } from "@/utils/dateTimeView";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function AdminDonasiTransactionDetail() {
|
export default function AdminDonasiTransactionDetail() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id, status } = useLocalSearchParams();
|
||||||
|
console.log("[STATUS]", id, status);
|
||||||
|
|
||||||
const buttonAction = (
|
const [data, setData] = useState<any | null>(null);
|
||||||
<BoxButtonOnFooter>
|
const [isLoading, setLoading] = useState(false);
|
||||||
<ButtonCustom onPress={() => router.back()}>Terima</ButtonCustom>
|
|
||||||
</BoxButtonOnFooter>
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [id])
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminDonationInvoiceDetailById({
|
||||||
|
id: id as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[GET INVOICE BY ID]", JSON.stringify(response, null, 2));
|
||||||
|
if (response.success) {
|
||||||
|
setData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const newData = {
|
||||||
|
donationId: data?.donasiId,
|
||||||
|
nominal: data?.nominal,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await apiAdminDonationInvoiceUpdateById({
|
||||||
|
id: id as string,
|
||||||
|
data: newData,
|
||||||
|
status: "berhasil",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[UPDATE INVOICE]", JSON.stringify(response, null, 2));
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const buttonAction = () => {
|
||||||
|
if (data && data?.DonasiMaster_StatusInvoice?.name === "Menunggu") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data && data?.DonasiMaster_StatusInvoice?.name === "Proses") {
|
||||||
|
return (
|
||||||
|
<BoxButtonOnFooter>
|
||||||
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
|
onPress={() => {
|
||||||
|
handlerSubmit();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Terima donasi
|
||||||
|
</ButtonCustom>
|
||||||
|
</BoxButtonOnFooter>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<BoxButtonOnFooter>
|
||||||
|
<ButtonCustom disabled>
|
||||||
|
{data?.DonasiMaster_StatusInvoice?.name}
|
||||||
|
</ButtonCustom>
|
||||||
|
</BoxButtonOnFooter>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const listData = [
|
const listData = [
|
||||||
{
|
{
|
||||||
label: "Donatur",
|
label: "Donatur",
|
||||||
value: "Bagas Banuna",
|
value: (data && data?.Author?.username) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Bank",
|
label: "Bank",
|
||||||
value: "BCA",
|
value: (data && data?.MasterBank?.namaBank) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Jumlah Donasi",
|
label: "Jumlah Donasi",
|
||||||
value: "Rp. 1.000.000",
|
value: `Rp. ${
|
||||||
|
(data && data?.nominal && formatCurrencyDisplay(data?.nominal)) || "-"
|
||||||
|
}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Status",
|
label: "Status",
|
||||||
value: <BadgeCustom color={MainColor.green}>Berhasil</BadgeCustom>,
|
value:
|
||||||
|
(data && data?.DonasiMaster_StatusInvoice?.name && (
|
||||||
|
<BadgeCustom
|
||||||
|
color={colorBadgeTransaction({
|
||||||
|
status: data?.DonasiMaster_StatusInvoice?.name as any,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{_.startCase(
|
||||||
|
(data?.DonasiMaster_StatusInvoice?.name as any) || "-"
|
||||||
|
)}
|
||||||
|
</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>
|
||||||
|
)) ||
|
||||||
|
"-",
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -61,7 +172,7 @@ export default function AdminDonasiTransactionDetail() {
|
|||||||
<>
|
<>
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
headerComponent={<AdminBackButtonAntTitle title="Detail Transaksi" />}
|
headerComponent={<AdminBackButtonAntTitle title="Detail Transaksi" />}
|
||||||
footerComponent={buttonAction}
|
footerComponent={buttonAction()}
|
||||||
>
|
>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
|
|||||||
@@ -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>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {
|
|||||||
ActionIcon,
|
ActionIcon,
|
||||||
BadgeCustom,
|
BadgeCustom,
|
||||||
CenterCustom,
|
CenterCustom,
|
||||||
|
LoaderCustom,
|
||||||
SelectCustom,
|
SelectCustom,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
@@ -23,30 +24,29 @@ import { Divider } from "react-native-paper";
|
|||||||
|
|
||||||
export default function AdminDonasiListOfDonatur() {
|
export default function AdminDonasiListOfDonatur() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
console.log("[ID >>]", id);
|
|
||||||
const [listData, setListData] = React.useState<any[] | null>(null);
|
const [listData, setListData] = React.useState<any[] | null>(null);
|
||||||
|
const [loadData, setLoadData] = React.useState(false);
|
||||||
const [master, setMaster] = React.useState<any[]>([]);
|
const [master, setMaster] = React.useState<any[]>([]);
|
||||||
|
|
||||||
const [selectStatus, setSelectStatus] = React.useState<
|
const [selectValue, setSelectValue] = React.useState<string | null>(null);
|
||||||
"berhasil" | "gagal" | "proses" | "menunggu" | ""
|
const [selectedStatus, setSelectedStatus] = React.useState<string | null>(
|
||||||
>("");
|
null
|
||||||
|
);
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
React.useCallback(() => {
|
React.useCallback(() => {
|
||||||
onLoadData();
|
onLoadData();
|
||||||
}, [id, selectStatus])
|
}, [id, selectValue])
|
||||||
);
|
);
|
||||||
|
|
||||||
const onLoadData = async () => {
|
const onLoadData = async () => {
|
||||||
try {
|
try {
|
||||||
|
setLoadData(true);
|
||||||
const response = await apiAdminDonationListOfDonatur({
|
const response = await apiAdminDonationListOfDonatur({
|
||||||
id: id as string,
|
id: id as string,
|
||||||
status: "" as any,
|
status: selectedStatus as any,
|
||||||
});
|
});
|
||||||
console.log(
|
// console.log("[LIST OF DONATUR]", JSON.stringify(response, null, 2));
|
||||||
"[LIST OF DONATUR]",
|
|
||||||
JSON.stringify(response, null, 2)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setListData(response.data);
|
setListData(response.data);
|
||||||
@@ -54,6 +54,8 @@ export default function AdminDonasiListOfDonatur() {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
setListData([]);
|
setListData([]);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -64,7 +66,7 @@ export default function AdminDonasiListOfDonatur() {
|
|||||||
const onLoadMaster = async () => {
|
const onLoadMaster = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await apiMasterTransaction();
|
const response = await apiMasterTransaction();
|
||||||
|
|
||||||
if (response.success) {
|
if (response.success) {
|
||||||
setMaster(response.data);
|
setMaster(response.data);
|
||||||
}
|
}
|
||||||
@@ -83,15 +85,18 @@ export default function AdminDonasiListOfDonatur() {
|
|||||||
? []
|
? []
|
||||||
: master?.map((item: any) => ({
|
: master?.map((item: any) => ({
|
||||||
label: item.name,
|
label: item.name,
|
||||||
value: item.name
|
value: item.id,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
value={selectValue}
|
||||||
onChange={(value: any) => {
|
onChange={(value: any) => {
|
||||||
console.log("[SELECT STATUS]", value);
|
setSelectValue(value);
|
||||||
const statusChooses = _.lowerCase(value);
|
const nameSelected = master.find((item: any) => item.id === value);
|
||||||
setSelectStatus(statusChooses as any);
|
const statusChooses = _.lowerCase(nameSelected?.name);
|
||||||
|
setSelectedStatus(statusChooses);
|
||||||
}}
|
}}
|
||||||
styleContainer={{ width: "100%", marginBottom: 0 }}
|
styleContainer={{ width: "100%", marginBottom: 0 }}
|
||||||
|
allowClear
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
@@ -102,63 +107,78 @@ export default function AdminDonasiListOfDonatur() {
|
|||||||
<AdminBackButtonAntTitle newComponent={searchComponent} />
|
<AdminBackButtonAntTitle newComponent={searchComponent} />
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<GridViewCustomSpan
|
|
||||||
span1={3}
|
|
||||||
span2={5}
|
|
||||||
span3={4}
|
|
||||||
component1={
|
|
||||||
<TextCustom bold align="center">
|
|
||||||
Aksi
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
component2={
|
|
||||||
<TextCustom bold align="center">
|
|
||||||
Donatur
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
component3={
|
|
||||||
<TextCustom bold align="center">
|
|
||||||
Status
|
|
||||||
</TextCustom>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<Divider />
|
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
{listData?.map((item: any, index: number) => (
|
<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(
|
Donatur
|
||||||
`/admin/donation/${id}/berhasil/transaction-detail`
|
</TextCustom>
|
||||||
);
|
}
|
||||||
}}
|
component3={
|
||||||
/>
|
<TextCustom bold align="center">
|
||||||
</CenterCustom>
|
Status
|
||||||
}
|
</TextCustom>
|
||||||
component2={
|
}
|
||||||
<TextCustom bold align="center" truncate>
|
/>
|
||||||
{item?.Author?.username || "-"}
|
<Divider />
|
||||||
</TextCustom>
|
<StackCustom>
|
||||||
}
|
{loadData ? (
|
||||||
component3={
|
<LoaderCustom />
|
||||||
<BadgeCustom
|
) : _.isEmpty(listData) ? (
|
||||||
style={{ alignSelf: "center" }}
|
<TextCustom align="center" color="gray">
|
||||||
color={colorBadgeTransaction({status: item?.DonasiMaster_StatusInvoice?.name})}
|
Belum ada data
|
||||||
>
|
</TextCustom>
|
||||||
{item?.DonasiMaster_StatusInvoice?.name}
|
) : (
|
||||||
</BadgeCustom>
|
listData?.map((item: any, index: number) => (
|
||||||
}
|
<View key={index}>
|
||||||
/>
|
<GridViewCustomSpan
|
||||||
<Divider />
|
span1={3}
|
||||||
</View>
|
span2={5}
|
||||||
))}
|
span3={4}
|
||||||
|
component1={
|
||||||
|
<CenterCustom>
|
||||||
|
<ActionIcon
|
||||||
|
icon={
|
||||||
|
<IconView size={ICON_SIZE_BUTTON} color="black" />
|
||||||
|
}
|
||||||
|
onPress={() => {
|
||||||
|
router.push(
|
||||||
|
`/admin/donation/${item?.id}/${_.lowerCase(
|
||||||
|
item?.DonasiMaster_StatusInvoice?.name
|
||||||
|
)}/transaction-detail`
|
||||||
|
);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</CenterCustom>
|
||||||
|
}
|
||||||
|
component2={
|
||||||
|
<TextCustom bold align="center" truncate>
|
||||||
|
{item?.Author?.username || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
component3={
|
||||||
|
<BadgeCustom
|
||||||
|
style={{ alignSelf: "center" }}
|
||||||
|
color={colorBadgeTransaction({
|
||||||
|
status: item?.DonasiMaster_StatusInvoice?.name,
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
{item?.DonasiMaster_StatusInvoice?.name}
|
||||||
|
</BadgeCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ type SelectProps = {
|
|||||||
onChange: (value: string | number) => void;
|
onChange: (value: string | number) => void;
|
||||||
borderRadius?: number;
|
borderRadius?: number;
|
||||||
styleContainer?: StyleProp<ViewStyle>;
|
styleContainer?: StyleProp<ViewStyle>;
|
||||||
|
allowClear?: boolean; // <-- new prop
|
||||||
|
clearLabel?: string; // default: "Kosongkan"
|
||||||
};
|
};
|
||||||
|
|
||||||
const SelectCustom: React.FC<SelectProps> = ({
|
const SelectCustom: React.FC<SelectProps> = ({
|
||||||
@@ -39,13 +41,21 @@ const SelectCustom: React.FC<SelectProps> = ({
|
|||||||
onChange,
|
onChange,
|
||||||
borderRadius = 8,
|
borderRadius = 8,
|
||||||
styleContainer,
|
styleContainer,
|
||||||
|
allowClear = true, // bisa dimatikan jika tidak perlu
|
||||||
|
clearLabel = "Hapus Pilihan",
|
||||||
}) => {
|
}) => {
|
||||||
const [modalVisible, setModalVisible] = useState(false);
|
const [modalVisible, setModalVisible] = useState(false);
|
||||||
|
|
||||||
const selectedItem = data.find((item) => item.value === value);
|
const selectedItem = data.find((item) => item.value === value);
|
||||||
|
|
||||||
const hasError = required && value === null; // <-- check if empty and required
|
const hasError = required && value === null; // <-- check if empty and required
|
||||||
|
|
||||||
|
// Gabungkan opsi clear di atas daftar
|
||||||
|
const renderData = allowClear
|
||||||
|
? [...data,
|
||||||
|
// { label: clearLabel, value: "__clear__" }
|
||||||
|
]
|
||||||
|
: data;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[GStyles.inputContainerArea, styleContainer]}>
|
<View style={[GStyles.inputContainerArea, styleContainer]}>
|
||||||
{label && (
|
{label && (
|
||||||
@@ -54,29 +64,64 @@ const SelectCustom: React.FC<SelectProps> = ({
|
|||||||
{required && <Text style={GStyles.inputRequired}> *</Text>}
|
{required && <Text style={GStyles.inputRequired}> *</Text>}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
<Pressable
|
|
||||||
|
{/* Input Container */}
|
||||||
|
<View
|
||||||
style={[
|
style={[
|
||||||
{ borderRadius, },
|
{
|
||||||
hasError ? GStyles.inputErrorBorder : null,
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
// backgroundColor: "red",
|
||||||
|
// flex: 1,
|
||||||
|
borderRadius,
|
||||||
|
},
|
||||||
GStyles.inputContainerInput,
|
GStyles.inputContainerInput,
|
||||||
|
hasError ? GStyles.inputErrorBorder : null,
|
||||||
disabled && GStyles.disabledBox,
|
disabled && GStyles.disabledBox,
|
||||||
]} // <-- add error style
|
]}
|
||||||
onPress={() => !disabled && setModalVisible(true)}
|
|
||||||
>
|
>
|
||||||
<Text
|
<Pressable
|
||||||
style={
|
style={[
|
||||||
selectedItem
|
{
|
||||||
? disabled
|
flex: 1,
|
||||||
? GStyles.inputTextDisabled
|
borderRadius,
|
||||||
: GStyles.inputText
|
flexDirection: "row",
|
||||||
: disabled
|
alignItems: "center",
|
||||||
? GStyles.inputPlaceholderDisabled
|
paddingHorizontal: 10,
|
||||||
: GStyles.inputPlaceholder
|
height: 50,
|
||||||
}
|
},
|
||||||
|
|
||||||
|
// GStyles.inputContainerInput,
|
||||||
|
// hasError ? GStyles.inputErrorBorder : null,
|
||||||
|
// disabled && GStyles.disabledBox,
|
||||||
|
]}
|
||||||
|
onPress={() => !disabled && setModalVisible(true)}
|
||||||
>
|
>
|
||||||
{selectedItem?.label || placeholder}
|
<Text
|
||||||
</Text>
|
style={
|
||||||
</Pressable>
|
selectedItem
|
||||||
|
? disabled
|
||||||
|
? GStyles.inputTextDisabled
|
||||||
|
: GStyles.inputText
|
||||||
|
: disabled
|
||||||
|
? GStyles.inputPlaceholderDisabled
|
||||||
|
: GStyles.inputPlaceholder
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{selectedItem?.label || placeholder}
|
||||||
|
</Text>
|
||||||
|
</Pressable>
|
||||||
|
|
||||||
|
{/* Tombol Clear (Hanya muncul jika ada nilai terpilih & allowClear aktif) */}
|
||||||
|
{!disabled && allowClear && value !== null && value !== undefined && (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{ paddingHorizontal: 10 }}
|
||||||
|
onPress={() => onChange(null as any)} // null dikirim sebagai value
|
||||||
|
>
|
||||||
|
<Text style={{ fontSize: 18, color: "#999" }}>×</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
|
||||||
<Modal visible={modalVisible} transparent animationType="fade">
|
<Modal visible={modalVisible} transparent animationType="fade">
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
@@ -86,19 +131,38 @@ const SelectCustom: React.FC<SelectProps> = ({
|
|||||||
>
|
>
|
||||||
<View style={GStyles.selectModalContent}>
|
<View style={GStyles.selectModalContent}>
|
||||||
<FlatList
|
<FlatList
|
||||||
data={data}
|
data={renderData}
|
||||||
keyExtractor={(item) => String(item.value)}
|
keyExtractor={(item) => String(item.value)}
|
||||||
renderItem={({ item }) => (
|
renderItem={({ item }) => {
|
||||||
<TouchableOpacity
|
if (item.value === "__clear__") {
|
||||||
style={GStyles.selectOption}
|
return (
|
||||||
onPress={() => {
|
<TouchableOpacity
|
||||||
onChange(item.value);
|
style={[
|
||||||
setModalVisible(false);
|
GStyles.selectOption,
|
||||||
}}
|
{ backgroundColor: "#fdd" },
|
||||||
>
|
]}
|
||||||
<Text>{item.label}</Text>
|
onPress={() => {
|
||||||
</TouchableOpacity>
|
onChange(null as any); // kosongkan nilai
|
||||||
)}
|
setModalVisible(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text>{item.label}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={GStyles.selectOption}
|
||||||
|
onPress={() => {
|
||||||
|
onChange(item.value);
|
||||||
|
setModalVisible(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Text>{item.label}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|||||||
@@ -91,14 +91,11 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
setToken(token);
|
setToken(token);
|
||||||
await AsyncStorage.setItem("authToken", token);
|
await AsyncStorage.setItem("authToken", token);
|
||||||
|
|
||||||
const responseUser = await apiConfig.get(
|
const responseUser = await apiConfig.get(`/mobile?token=${token}`, {
|
||||||
`/mobile?token=${token}`,
|
headers: {
|
||||||
{
|
Authorization: `Bearer ${token}`,
|
||||||
headers: {
|
},
|
||||||
Authorization: `Bearer ${token}`,
|
});
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
const dataUser = responseUser.data.data;
|
const dataUser = responseUser.data.data;
|
||||||
|
|
||||||
setUser(dataUser);
|
setUser(dataUser);
|
||||||
@@ -147,9 +144,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
await AsyncStorage.setItem("userData", JSON.stringify(dataUser));
|
await AsyncStorage.setItem("userData", JSON.stringify(dataUser));
|
||||||
return dataUser;
|
return dataUser;
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
throw new Error(
|
console.log(error.response?.data?.message + "user" || "Gagal mengambil data user");
|
||||||
error.response?.data?.message || "Gagal mengambil data user"
|
|
||||||
);
|
|
||||||
} finally {
|
} finally {
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -70,9 +70,12 @@ export default function Donation_BoxPublish({
|
|||||||
</TextCustom>
|
</TextCustom>
|
||||||
</View>
|
</View>
|
||||||
<ProgressCustom
|
<ProgressCustom
|
||||||
label={data?.progres + "%" || "0%"}
|
|
||||||
value={data?.progres || 0}
|
|
||||||
size="lg"
|
size="lg"
|
||||||
|
value={Number(data?.progres) || 0}
|
||||||
|
showLabel={true}
|
||||||
|
label={data?.progres + "%"}
|
||||||
|
animated
|
||||||
|
color="primary"
|
||||||
/>
|
/>
|
||||||
{/* <TextCustom>
|
{/* <TextCustom>
|
||||||
Terkumpul : Rp 300.000
|
Terkumpul : Rp 300.000
|
||||||
|
|||||||
@@ -11,11 +11,23 @@ import { Ionicons, MaterialIcons } from "@expo/vector-icons";
|
|||||||
import { router } from "expo-router";
|
import { router } from "expo-router";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function Donation_ProgressSection({ id }: { id: string }) {
|
export default function Donation_ProgressSection({
|
||||||
|
id,
|
||||||
|
progres,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
progres: number;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<View>
|
<View>
|
||||||
<ProgressCustom size="lg" />
|
<ProgressCustom
|
||||||
|
size="lg"
|
||||||
|
value={progres}
|
||||||
|
label={progres + "%"}
|
||||||
|
animated
|
||||||
|
color="primary"
|
||||||
|
/>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={4}>
|
<Grid.Col span={4}>
|
||||||
|
|||||||
@@ -53,14 +53,102 @@ export async function apiAdminDonationListOfDonatur({
|
|||||||
status,
|
status,
|
||||||
}: {
|
}: {
|
||||||
id: string;
|
id: string;
|
||||||
status: "berhasil" | "gagal" | "proses" | "menunggu" | "";
|
status: "berhasil" | "gagal" | "proses" | "menunggu" | null;
|
||||||
}) {
|
}) {
|
||||||
|
const query = status && status !== null ? `?status=${status}` : "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await apiConfig.get(
|
const response = await apiConfig.get(
|
||||||
`/mobile/admin/donation/${id}/donatur?status=${status}`
|
`/mobile/admin/donation/${id}/donatur${query}`
|
||||||
);
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationInvoiceDetailById({
|
||||||
|
id,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/admin/donation/${id}/invoice`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiAdminDonationInvoiceUpdateById({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
status,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
status: "berhasil" | "gagal" | "proses" | "menunggu";
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(
|
||||||
|
`/mobile/admin/donation/${id}/invoice?status=${status}`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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