Donasi
Fix: tampilan status dan detail status sudah terintegrasi API - create dan buntton status sudah terintegrasi ### No Issue
This commit is contained in:
@@ -186,7 +186,7 @@ export default function UserLayout() {
|
|||||||
name="crowdfunding/index"
|
name="crowdfunding/index"
|
||||||
options={{
|
options={{
|
||||||
title: "Crowdfunding",
|
title: "Crowdfunding",
|
||||||
headerLeft: () => <BackButton />,
|
headerLeft: () => <BackButton path="/home" />,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,48 @@
|
|||||||
import { ScrollableCustom, ViewWrapper } from "@/components";
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import {
|
||||||
|
LoaderCustom,
|
||||||
|
ScrollableCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import { dummyMasterStatus } from "@/lib/dummy-data/_master/status";
|
import { dummyMasterStatus } from "@/lib/dummy-data/_master/status";
|
||||||
import Donasi_BoxStatus from "@/screens/Donation/BoxStatus";
|
import Donasi_BoxStatus from "@/screens/Donation/BoxStatus";
|
||||||
import { useState } from "react";
|
import { apiDonationGetByStatus } from "@/service/api-client/api-donation";
|
||||||
|
import { useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function DonationStatus() {
|
export default function DonationStatus() {
|
||||||
|
const { user } = useAuth();
|
||||||
const [activeCategory, setActiveCategory] = useState<string | null>(
|
const [activeCategory, setActiveCategory] = useState<string | null>(
|
||||||
"publish"
|
"publish"
|
||||||
);
|
);
|
||||||
|
const [listData, setListData] = useState<any[] | null>(null);
|
||||||
|
const [loadList, setLoadList] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadList();
|
||||||
|
}, [activeCategory])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadList = async () => {
|
||||||
|
try {
|
||||||
|
setLoadList(true);
|
||||||
|
const response = await apiDonationGetByStatus({
|
||||||
|
authorId: user?.id as string,
|
||||||
|
status: activeCategory as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
setListData(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setListData(null);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handlePress = (item: any) => {
|
const handlePress = (item: any) => {
|
||||||
setActiveCategory(item.value);
|
setActiveCategory(item.value);
|
||||||
@@ -26,13 +62,19 @@ export default function DonationStatus() {
|
|||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<ViewWrapper hideFooter headerComponent={scrollComponent}>
|
<ViewWrapper hideFooter headerComponent={scrollComponent}>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadList ? (
|
||||||
<Donasi_BoxStatus
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(listData) ? (
|
||||||
id={index.toString()}
|
<TextCustom align="center">Tidak ada data {activeCategory}</TextCustom>
|
||||||
status={activeCategory as string}
|
) : (
|
||||||
/>
|
listData?.map((item: any, index: number) => (
|
||||||
))}
|
<Donasi_BoxStatus
|
||||||
|
key={index}
|
||||||
|
data={item}
|
||||||
|
status={activeCategory as string}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BackButton,
|
BackButton,
|
||||||
DotButton,
|
DotButton,
|
||||||
@@ -14,16 +15,43 @@ import Donation_ButtonStatusSection from "@/screens/Donation/ButtonStatusSection
|
|||||||
import Donation_ComponentBoxDetailData from "@/screens/Donation/ComponentBoxDetailData";
|
import Donation_ComponentBoxDetailData from "@/screens/Donation/ComponentBoxDetailData";
|
||||||
import Donation_ComponentStoryFunrising from "@/screens/Donation/ComponentStoryFunrising";
|
import Donation_ComponentStoryFunrising from "@/screens/Donation/ComponentStoryFunrising";
|
||||||
import Donation_ProgressSection from "@/screens/Donation/ProgressSection";
|
import Donation_ProgressSection from "@/screens/Donation/ProgressSection";
|
||||||
|
import { apiDonationGetOne } from "@/service/api-client/api-donation";
|
||||||
import { FontAwesome6 } from "@expo/vector-icons";
|
import { FontAwesome6 } from "@expo/vector-icons";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import {
|
||||||
|
router,
|
||||||
|
Stack,
|
||||||
|
useFocusEffect,
|
||||||
|
useLocalSearchParams,
|
||||||
|
} from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function DonasiDetailStatus() {
|
export default function DonasiDetailStatus() {
|
||||||
const { id, status } = useLocalSearchParams();
|
const { id, status } = useLocalSearchParams();
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
const [openDrawerPublish, setOpenDrawerPublish] = useState(false);
|
const [openDrawerPublish, setOpenDrawerPublish] = useState(false);
|
||||||
|
|
||||||
|
const [data, setData] = useState<any>();
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiDonationGetOne({
|
||||||
|
id: id as string,
|
||||||
|
category: "permanent",
|
||||||
|
});
|
||||||
|
|
||||||
|
setData(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handlePress = (item: IMenuDrawerItem) => {
|
const handlePress = (item: IMenuDrawerItem) => {
|
||||||
console.log("PATH ", item.path);
|
console.log("PATH ", item.path);
|
||||||
router.navigate(item.path as any);
|
router.navigate(item.path as any);
|
||||||
@@ -46,13 +74,22 @@ export default function DonasiDetailStatus() {
|
|||||||
/>
|
/>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<Donation_ComponentBoxDetailData
|
<Donation_ComponentBoxDetailData
|
||||||
|
data={data}
|
||||||
bottomSection={
|
bottomSection={
|
||||||
status === "publish" && <Donation_ProgressSection id={id as string} />
|
status === "publish" && (
|
||||||
|
<Donation_ProgressSection id={id as string} />
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Donation_ComponentStoryFunrising id={id as string} />
|
<Donation_ComponentStoryFunrising
|
||||||
|
id={id as string}
|
||||||
|
dataStory={data?.CeritaDonasi}
|
||||||
|
/>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
<Donation_ButtonStatusSection status={status as string} />
|
<Donation_ButtonStatusSection
|
||||||
|
id={id as string}
|
||||||
|
status={status as string}
|
||||||
|
/>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
|
|||||||
@@ -1,27 +1,42 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
DummyLandscapeImage,
|
DummyLandscapeImage,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { useLocalSearchParams } from "expo-router";
|
import { apiDonationGetOne } from "@/service/api-client/api-donation";
|
||||||
|
import { useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function DonationDetailStory() {
|
export default function DonationDetailStory() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState<any>();
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiDonationGetOne({
|
||||||
|
id: id as string,
|
||||||
|
category: "permanent",
|
||||||
|
});
|
||||||
|
|
||||||
|
setData(response.data.CeritaDonasi);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<TextCustom>
|
<TextCustom>{data?.pembukaan || "-"}</TextCustom>
|
||||||
Lorem {id} ipsum dolor, sit amet consectetur adipisicing elit. Fuga
|
<DummyLandscapeImage imageId={data?.imageId} />
|
||||||
quasi nam nesciunt nisi corporis alias modi, pariatur sit totam rem
|
<TextCustom>{data?.cerita || "-"}</TextCustom>
|
||||||
fugiat ex similique magni, aliquam maiores officiis iure at adipisci.
|
|
||||||
</TextCustom>
|
|
||||||
<DummyLandscapeImage />
|
|
||||||
<TextCustom>
|
|
||||||
Lorem {id} ipsum dolor, sit amet consectetur adipisicing elit. Fuga
|
|
||||||
quasi nam nesciunt nisi corporis alias modi, pariatur sit totam rem
|
|
||||||
fugiat ex similique magni, aliquam maiores officiis iure at adipisci.
|
|
||||||
</TextCustom>
|
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -12,8 +12,12 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import DIRECTORY_ID from "@/constants/directory-id";
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
import { useAuth } from "@/hooks/use-auth";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import { apiDonationGetOne } from "@/service/api-client/api-donation";
|
import {
|
||||||
|
apiDonationCreate,
|
||||||
|
apiDonationGetOne,
|
||||||
|
} from "@/service/api-client/api-donation";
|
||||||
import { uploadFileService } from "@/service/upload-service";
|
import { uploadFileService } from "@/service/upload-service";
|
||||||
|
import pickFile from "@/utils/pickFile";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
@@ -22,7 +26,6 @@ import Toast from "react-native-toast-message";
|
|||||||
export default function DonationCreateStory() {
|
export default function DonationCreateStory() {
|
||||||
const { user } = useAuth();
|
const { user } = useAuth();
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
console.log("[ID]", id);
|
|
||||||
const [temporary, setTemporary] = useState<any>();
|
const [temporary, setTemporary] = useState<any>();
|
||||||
const [data, setData] = useState({
|
const [data, setData] = useState({
|
||||||
pembukaan: "",
|
pembukaan: "",
|
||||||
@@ -30,7 +33,8 @@ export default function DonationCreateStory() {
|
|||||||
namaBank: "",
|
namaBank: "",
|
||||||
rekening: "",
|
rekening: "",
|
||||||
});
|
});
|
||||||
const [imageDonasi, setImageDonasi] = useState<string | null>(null);
|
const [imageStory, setImageStory] = useState<string | null>(null);
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
onLoadData();
|
onLoadData();
|
||||||
@@ -38,11 +42,12 @@ export default function DonationCreateStory() {
|
|||||||
|
|
||||||
const onLoadData = async () => {
|
const onLoadData = async () => {
|
||||||
try {
|
try {
|
||||||
// const response = await apiDonationGetOne({
|
const response = await apiDonationGetOne({
|
||||||
// id: id as string,
|
id: id as string,
|
||||||
// category: "temporary",
|
category: "temporary",
|
||||||
// });
|
});
|
||||||
// console.log("[RES GET ONE]", JSON.stringify(response, null, 2));
|
|
||||||
|
setTemporary(response.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
}
|
}
|
||||||
@@ -58,28 +63,51 @@ export default function DonationCreateStory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
setLoading(true);
|
||||||
const responseUploadImageDonasi = await uploadFileService({
|
const responseUploadImageDonasi = await uploadFileService({
|
||||||
imageUri: imageDonasi,
|
imageUri: imageStory,
|
||||||
dirId: DIRECTORY_ID.donasi_cerita_image,
|
dirId: DIRECTORY_ID.donasi_cerita_image,
|
||||||
});
|
});
|
||||||
|
|
||||||
const newData = {
|
const newData = {
|
||||||
id: temporary?.id,
|
// Data Donasi
|
||||||
|
temporaryId: temporary?.id,
|
||||||
|
authorId: user?.id,
|
||||||
title: temporary?.title,
|
title: temporary?.title,
|
||||||
target: temporary?.target,
|
target: temporary?.target,
|
||||||
donasiMaster_KategoriId: temporary?.donasiMaster_KategoriId,
|
donasiMaster_KategoriId: temporary?.donasiMaster_KategoriId,
|
||||||
donasiMaster_DurasiId: temporary?.donasiMaster_DurasiId,
|
donasiMaster_DurasiId: temporary?.donasiMaster_DurasiId,
|
||||||
authorId: user?.id,
|
imageId: temporary?.imageId,
|
||||||
|
// Data Bank
|
||||||
namaBank: data.namaBank,
|
namaBank: data.namaBank,
|
||||||
rekening: data.rekening,
|
rekening: data.rekening,
|
||||||
imageId: temporary?.imageId,
|
// Data Cerita
|
||||||
CeritaDonasi: {
|
imageCeritaId: responseUploadImageDonasi.data.id,
|
||||||
pembukaan: data.pembukaan,
|
pembukaan: data.pembukaan,
|
||||||
cerita: data.cerita,
|
cerita: data.cerita,
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const response = await apiDonationCreate({
|
||||||
|
data: newData,
|
||||||
|
category: "permanent",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal membuat donasi",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Donasi berhasil disimpan",
|
||||||
|
});
|
||||||
|
router.replace("/donation/status");
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log("[ERROR]", error);
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -106,10 +134,15 @@ export default function DonationCreateStory() {
|
|||||||
onChangeText={(value) => setData({ ...data, cerita: value })}
|
onChangeText={(value) => setData({ ...data, cerita: value })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<LandscapeFrameUploaded />
|
<LandscapeFrameUploaded image={imageStory || ""} />
|
||||||
<ButtonCenteredOnly
|
<ButtonCenteredOnly
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.push("/(application)/(image)/take-picture/123");
|
pickFile({
|
||||||
|
allowedType: "image",
|
||||||
|
setImageUri: ({ uri }) => {
|
||||||
|
setImageStory(uri);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
icon="upload"
|
icon="upload"
|
||||||
>
|
>
|
||||||
@@ -122,17 +155,23 @@ export default function DonationCreateStory() {
|
|||||||
label="Nama Bank"
|
label="Nama Bank"
|
||||||
placeholder="Masukkan nama bank"
|
placeholder="Masukkan nama bank"
|
||||||
required
|
required
|
||||||
|
value={data.namaBank}
|
||||||
|
onChangeText={(value) => setData({ ...data, namaBank: value })}
|
||||||
/>
|
/>
|
||||||
<TextInputCustom
|
<TextInputCustom
|
||||||
label="Nomor Rekening"
|
label="Nomor Rekening"
|
||||||
placeholder="Masukkan nomor rekening"
|
placeholder="Masukkan nomor rekening"
|
||||||
required
|
required
|
||||||
|
keyboardType="numeric"
|
||||||
|
value={data.rekening}
|
||||||
|
onChangeText={(value) => setData({ ...data, rekening: value })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Spacing />
|
<Spacing />
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.replace(`/donation/(tabs)/status`);
|
handlerSubmit();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import {
|
|||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import DIRECTORY_ID from "@/constants/directory-id";
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
import { dummyDonasiDurasi } from "@/lib/dummy-data/donasi/durasi";
|
|
||||||
import { dummyDonasiKategori } from "@/lib/dummy-data/donasi/kategori";
|
|
||||||
import { apiDonationCreate } from "@/service/api-client/api-donation";
|
import { apiDonationCreate } from "@/service/api-client/api-donation";
|
||||||
import { apiMasterDonation } from "@/service/api-client/api-master";
|
import { apiMasterDonation } from "@/service/api-client/api-master";
|
||||||
import { uploadFileService } from "@/service/upload-service";
|
import { uploadFileService } from "@/service/upload-service";
|
||||||
@@ -110,8 +108,6 @@ export default function DonationCreate() {
|
|||||||
category: "temporary",
|
category: "temporary",
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log("[RESPONSE]", JSON.stringify(response, null, 2));
|
|
||||||
|
|
||||||
if (!response.success) {
|
if (!response.success) {
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "error",
|
type: "error",
|
||||||
@@ -210,8 +206,8 @@ export default function DonationCreate() {
|
|||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
// handlerSubmit();
|
handlerSubmit();
|
||||||
router.push(`/donation/create-story?id=${"dasdsadsa"}`);
|
// router.push(`/donation/create-story?id=${"dasdsadsa"}`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Selanjutnya
|
Selanjutnya
|
||||||
|
|||||||
@@ -5,13 +5,14 @@ import {
|
|||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function Donasi_BoxStatus({
|
export default function Donasi_BoxStatus({
|
||||||
id,
|
data,
|
||||||
status,
|
status,
|
||||||
}: {
|
}: {
|
||||||
id: string;
|
data: any;
|
||||||
status: string;
|
status: string;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
@@ -19,26 +20,30 @@ export default function Donasi_BoxStatus({
|
|||||||
<BaseBox
|
<BaseBox
|
||||||
paddingTop={7}
|
paddingTop={7}
|
||||||
paddingBottom={7}
|
paddingBottom={7}
|
||||||
href={`/donation/${id}/${status}/detail`}
|
href={`/donation/${data.id}/${status}/detail`}
|
||||||
>
|
>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={5}>
|
<Grid.Col span={5}>
|
||||||
<DummyLandscapeImage unClickPath height={100} />
|
<DummyLandscapeImage
|
||||||
|
unClickPath
|
||||||
|
height={100}
|
||||||
|
imageId={data.imageId}
|
||||||
|
/>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={1}>
|
<Grid.Col span={1}>
|
||||||
<View />
|
<View />
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={6}>
|
<Grid.Col span={6}>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<TextCustom truncate>
|
<TextCustom truncate={2} bold>{data.title || "-"}</TextCustom>
|
||||||
Judul Donasi: {status} Lorem ipsum dolor sit amet consectetur
|
|
||||||
adipisicing elit.
|
|
||||||
</TextCustom>
|
|
||||||
|
|
||||||
<View>
|
<View>
|
||||||
<TextCustom>Target Dana</TextCustom>
|
<TextCustom>Target Dana</TextCustom>
|
||||||
<TextCustom bold color="yellow">
|
<TextCustom bold color="yellow">
|
||||||
Rp. 7.500.000
|
Rp.
|
||||||
|
{data && data?.target
|
||||||
|
? formatCurrencyDisplay(data.target)
|
||||||
|
: "-"}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</View>
|
</View>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
|
|||||||
@@ -1,20 +1,54 @@
|
|||||||
import { AlertDefaultSystem, ButtonCustom, Grid } from "@/components";
|
import { AlertDefaultSystem, ButtonCustom, Grid } from "@/components";
|
||||||
|
import {
|
||||||
|
apiDonationDelete,
|
||||||
|
apiDonationUpdateStatus,
|
||||||
|
} from "@/service/api-client/api-donation";
|
||||||
import { router } from "expo-router";
|
import { router } from "expo-router";
|
||||||
|
import { useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function Donation_ButtonStatusSection({
|
export default function Donation_ButtonStatusSection({
|
||||||
|
id,
|
||||||
status,
|
status,
|
||||||
}: {
|
}: {
|
||||||
|
id: string;
|
||||||
status: string;
|
status: string;
|
||||||
}) {
|
}) {
|
||||||
const handleBatalkanReview = () => {
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
const [isLoadingDelete, setLoadingDelete] = useState(false);
|
||||||
|
const handleBatalkanReview = async () => {
|
||||||
AlertDefaultSystem({
|
AlertDefaultSystem({
|
||||||
title: "Batalkan Review",
|
title: "Batalkan Review",
|
||||||
message: "Apakah Anda yakin ingin batalkan review ini?",
|
message: "Apakah Anda yakin ingin batalkan review ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Ya",
|
textRight: "Ya",
|
||||||
onPressRight: () => {
|
onPressRight: async () => {
|
||||||
console.log("Hapus");
|
try {
|
||||||
router.back();
|
setLoading(true);
|
||||||
|
const response = await apiDonationUpdateStatus({
|
||||||
|
id: id,
|
||||||
|
status: "draft",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "info",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -25,9 +59,33 @@ export default function Donation_ButtonStatusSection({
|
|||||||
message: "Apakah Anda yakin ingin ajukan review ini?",
|
message: "Apakah Anda yakin ingin ajukan review ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Ya",
|
textRight: "Ya",
|
||||||
onPressRight: () => {
|
onPressRight: async () => {
|
||||||
console.log("Hapus");
|
try {
|
||||||
router.back();
|
setLoading(true);
|
||||||
|
const response = await apiDonationUpdateStatus({
|
||||||
|
id: id,
|
||||||
|
status: "review",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "info",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -38,9 +96,33 @@ export default function Donation_ButtonStatusSection({
|
|||||||
message: "Apakah Anda yakin ingin edit kembali ini?",
|
message: "Apakah Anda yakin ingin edit kembali ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Ya",
|
textRight: "Ya",
|
||||||
onPressRight: () => {
|
onPressRight: async () => {
|
||||||
console.log("Hapus");
|
try {
|
||||||
router.back();
|
setLoading(true);
|
||||||
|
const response = await apiDonationUpdateStatus({
|
||||||
|
id: id,
|
||||||
|
status: "draft",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "info",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -51,9 +133,30 @@ export default function Donation_ButtonStatusSection({
|
|||||||
message: "Apakah Anda yakin ingin menghapus data ini?",
|
message: "Apakah Anda yakin ingin menghapus data ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Hapus",
|
textRight: "Hapus",
|
||||||
onPressRight: () => {
|
onPressRight: async () => {
|
||||||
console.log("Hapus");
|
try {
|
||||||
router.back();
|
setLoadingDelete(true);
|
||||||
|
const response = await apiDonationDelete({ id: id });
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "info",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadingDelete(false);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -62,6 +165,7 @@ export default function Donation_ButtonStatusSection({
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
isLoading={isLoadingDelete}
|
||||||
backgroundColor="red"
|
backgroundColor="red"
|
||||||
textColor="white"
|
textColor="white"
|
||||||
onPress={handleOpenDeleteAlert}
|
onPress={handleOpenDeleteAlert}
|
||||||
@@ -78,7 +182,7 @@ export default function Donation_ButtonStatusSection({
|
|||||||
|
|
||||||
case "review":
|
case "review":
|
||||||
return (
|
return (
|
||||||
<ButtonCustom onPress={handleBatalkanReview}>
|
<ButtonCustom isLoading={isLoading} onPress={handleBatalkanReview}>
|
||||||
Batalkan Review
|
Batalkan Review
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
);
|
);
|
||||||
@@ -88,7 +192,7 @@ export default function Donation_ButtonStatusSection({
|
|||||||
<>
|
<>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={6} style={{ paddingRight: 10 }}>
|
<Grid.Col span={6} style={{ paddingRight: 10 }}>
|
||||||
<ButtonCustom onPress={handleAjukanReview}>
|
<ButtonCustom isLoading={isLoading} onPress={handleAjukanReview}>
|
||||||
Ajukan Review
|
Ajukan Review
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
@@ -104,7 +208,7 @@ export default function Donation_ButtonStatusSection({
|
|||||||
<>
|
<>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={6} style={{ paddingRight: 10 }}>
|
<Grid.Col span={6} style={{ paddingRight: 10 }}>
|
||||||
<ButtonCustom onPress={handleEditKembali}>
|
<ButtonCustom isLoading={isLoading} onPress={handleEditKembali}>
|
||||||
Edit Kembali
|
Edit Kembali
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
|
|||||||
@@ -5,25 +5,29 @@ import {
|
|||||||
TextCustom,
|
TextCustom,
|
||||||
Grid,
|
Grid,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function Donation_ComponentBoxDetailData({
|
export default function Donation_ComponentBoxDetailData({
|
||||||
bottomSection,
|
bottomSection,
|
||||||
|
data,
|
||||||
}: {
|
}: {
|
||||||
bottomSection?: React.ReactNode;
|
bottomSection?: React.ReactNode;
|
||||||
|
data: any;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<DummyLandscapeImage />
|
<DummyLandscapeImage imageId={data?.imageId} />
|
||||||
<View>
|
<View>
|
||||||
<TextCustom bold size="large">
|
<TextCustom bold size="large">
|
||||||
Judul Donasi: Lorem, ipsum dolor sit amet consectetur adipisicing
|
{data?.title || "-"}
|
||||||
elit.
|
</TextCustom>
|
||||||
|
<TextCustom size="small">
|
||||||
|
Durasi: {data?.DonasiMaster_Durasi?.name || "-"}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom size="small">Durasi: 30 hari</TextCustom>
|
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<Grid>
|
<Grid>
|
||||||
@@ -31,7 +35,7 @@ export default function Donation_ComponentBoxDetailData({
|
|||||||
<View>
|
<View>
|
||||||
<TextCustom size="small">Target Dana</TextCustom>
|
<TextCustom size="small">Target Dana</TextCustom>
|
||||||
<TextCustom truncate={2} size="large" bold color="yellow">
|
<TextCustom truncate={2} size="large" bold color="yellow">
|
||||||
Rp. 7.500.000
|
Rp. {formatCurrencyDisplay(data?.target) || "-"}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</View>
|
</View>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
@@ -39,7 +43,7 @@ export default function Donation_ComponentBoxDetailData({
|
|||||||
<View>
|
<View>
|
||||||
<TextCustom size="small">Kategori</TextCustom>
|
<TextCustom size="small">Kategori</TextCustom>
|
||||||
<TextCustom size="large" bold color="yellow">
|
<TextCustom size="large" bold color="yellow">
|
||||||
Kegiatan Sosial
|
{data?.DonasiMaster_Ketegori?.name || "-"}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</View>
|
</View>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ import { Ionicons } from "@expo/vector-icons";
|
|||||||
|
|
||||||
export default function Donation_ComponentStoryFunrising({
|
export default function Donation_ComponentStoryFunrising({
|
||||||
id,
|
id,
|
||||||
|
dataStory,
|
||||||
}: {
|
}: {
|
||||||
id: string;
|
id: string;
|
||||||
|
dataStory: any;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -29,12 +31,7 @@ export default function Donation_ComponentStoryFunrising({
|
|||||||
/>
|
/>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
<TextCustom truncate={3}>
|
<TextCustom truncate={3}>{dataStory?.pembukaan || "-"}</TextCustom>
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Totam,
|
|
||||||
iusto porro quae optio accusantium amet minima deleniti temporibus
|
|
||||||
cum voluptatem vel veniam doloribus blanditiis sapiente deserunt
|
|
||||||
distinctio eaque aliquid laboriosam?
|
|
||||||
</TextCustom>
|
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -1,22 +1,82 @@
|
|||||||
import { apiConfig } from "../api-config";
|
import { apiConfig } from "../api-config";
|
||||||
|
|
||||||
export async function apiDonationCreate({ data , category}: { data: any , category: "temporary" | "permanent"}) {
|
export async function apiDonationCreate({
|
||||||
|
data,
|
||||||
|
category,
|
||||||
|
}: {
|
||||||
|
data: any;
|
||||||
|
category: "temporary" | "permanent";
|
||||||
|
}) {
|
||||||
try {
|
try {
|
||||||
const response = await apiConfig.post(`/mobile/donation?category=${category}`, {
|
const response = await apiConfig.post(
|
||||||
data: data,
|
`/mobile/donation?category=${category}`,
|
||||||
});
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function apiDonationGetOne({ id, category }: { id: string , category: "temporary" | "permanent"}) {
|
export async function apiDonationGetOne({
|
||||||
|
id,
|
||||||
|
category,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
category: "temporary" | "permanent";
|
||||||
|
}) {
|
||||||
try {
|
try {
|
||||||
const response = await apiConfig.get(`/mobile/donation/${id}?category=${category}`);
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/donation/${id}?category=${category}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationGetByStatus({
|
||||||
|
authorId,
|
||||||
|
status,
|
||||||
|
}: {
|
||||||
|
authorId: string;
|
||||||
|
status: string;
|
||||||
|
}) {
|
||||||
|
const authorQuery = `/${authorId}`;
|
||||||
|
const statusQuery = `/${status}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/donation${authorQuery}${statusQuery}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationUpdateStatus({
|
||||||
|
id,
|
||||||
|
status,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
status: "draft" | "review" | "publish" | "reject";
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(`/mobile/donation/${id}/${status}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationDelete({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.delete(`/mobile/donation/${id}`);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user