Compare commits

...

3 Commits

Author SHA1 Message Date
ba878d4d08 Donasi
Fix: tampilan status dan detail status sudah terintegrasi API
- create dan buntton status sudah terintegrasi

### No Issue
2025-10-06 16:11:56 +08:00
f3a3acc747 Donation:
Add:
- service/api-client/api-donation.ts

Fix:
- service/api-client/api-master.ts : tambah master donasi
- app/(application)/(user)/donation/create.tsx
- app/(application)/(user)/donation/create-story.tsx

### No issue
2025-10-03 17:37:29 +08:00
a6389174d7 git add . && git commit -m 2025-10-03 14:09:31 +08:00
19 changed files with 974 additions and 161 deletions

View File

@@ -186,7 +186,7 @@ export default function UserLayout() {
name="crowdfunding/index"
options={{
title: "Crowdfunding",
headerLeft: () => <BackButton />,
headerLeft: () => <BackButton path="/home" />,
}}
/>

View File

@@ -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 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() {
const { user } = useAuth();
const [activeCategory, setActiveCategory] = useState<string | null>(
"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) => {
setActiveCategory(item.value);
@@ -26,13 +62,19 @@ export default function DonationStatus() {
);
return (
<ViewWrapper hideFooter headerComponent={scrollComponent}>
{Array.from({ length: 10 }).map((_, index) => (
<Donasi_BoxStatus
key={index}
id={index.toString()}
status={activeCategory as string}
/>
))}
{loadList ? (
<LoaderCustom />
) : _.isEmpty(listData) ? (
<TextCustom align="center">Tidak ada data {activeCategory}</TextCustom>
) : (
listData?.map((item: any, index: number) => (
<Donasi_BoxStatus
key={index}
data={item}
status={activeCategory as string}
/>
))
)}
</ViewWrapper>
);
}

View File

@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
BackButton,
DotButton,
@@ -14,16 +15,43 @@ import Donation_ButtonStatusSection from "@/screens/Donation/ButtonStatusSection
import Donation_ComponentBoxDetailData from "@/screens/Donation/ComponentBoxDetailData";
import Donation_ComponentStoryFunrising from "@/screens/Donation/ComponentStoryFunrising";
import Donation_ProgressSection from "@/screens/Donation/ProgressSection";
import { apiDonationGetOne } from "@/service/api-client/api-donation";
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 { useState } from "react";
import { useCallback, useState } from "react";
export default function DonasiDetailStatus() {
const { id, status } = useLocalSearchParams();
const [openDrawer, setOpenDrawer] = 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) => {
console.log("PATH ", item.path);
router.navigate(item.path as any);
@@ -46,13 +74,22 @@ export default function DonasiDetailStatus() {
/>
<ViewWrapper>
<Donation_ComponentBoxDetailData
data={data}
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 />
<Donation_ButtonStatusSection status={status as string} />
<Donation_ButtonStatusSection
id={id as string}
status={status as string}
/>
<Spacing />
</ViewWrapper>

View File

@@ -1,27 +1,42 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
DummyLandscapeImage,
StackCustom,
TextCustom,
ViewWrapper,
} 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() {
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 (
<ViewWrapper>
<StackCustom>
<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>
<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>
<TextCustom>{data?.pembukaan || "-"}</TextCustom>
<DummyLandscapeImage imageId={data?.imageId} />
<TextCustom>{data?.cerita || "-"}</TextCustom>
</StackCustom>
</ViewWrapper>
);

View File

@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
ButtonCenteredOnly,
ButtonCustom,
@@ -9,9 +10,107 @@ import {
TextInputCustom,
ViewWrapper,
} from "@/components";
import { router } from "expo-router";
import DIRECTORY_ID from "@/constants/directory-id";
import { useAuth } from "@/hooks/use-auth";
import {
apiDonationCreate,
apiDonationGetOne,
} from "@/service/api-client/api-donation";
import { uploadFileService } from "@/service/upload-service";
import pickFile from "@/utils/pickFile";
import { router, useLocalSearchParams } from "expo-router";
import _ from "lodash";
import { useEffect, useState } from "react";
import Toast from "react-native-toast-message";
export default function DonationCreateStory() {
const { user } = useAuth();
const { id } = useLocalSearchParams();
const [temporary, setTemporary] = useState<any>();
const [data, setData] = useState({
pembukaan: "",
cerita: "",
namaBank: "",
rekening: "",
});
const [imageStory, setImageStory] = useState<string | null>(null);
const [isLoading, setLoading] = useState(false);
useEffect(() => {
onLoadData();
}, [id]);
const onLoadData = async () => {
try {
const response = await apiDonationGetOne({
id: id as string,
category: "temporary",
});
setTemporary(response.data);
} catch (error) {
console.log("[ERROR]", error);
}
};
const handlerSubmit = async () => {
if (_.values(data).includes("")) {
Toast.show({
type: "error",
text1: "Harap isi semua data",
});
return;
}
try {
setLoading(true);
const responseUploadImageDonasi = await uploadFileService({
imageUri: imageStory,
dirId: DIRECTORY_ID.donasi_cerita_image,
});
const newData = {
// Data Donasi
temporaryId: temporary?.id,
authorId: user?.id,
title: temporary?.title,
target: temporary?.target,
donasiMaster_KategoriId: temporary?.donasiMaster_KategoriId,
donasiMaster_DurasiId: temporary?.donasiMaster_DurasiId,
imageId: temporary?.imageId,
// Data Bank
namaBank: data.namaBank,
rekening: data.rekening,
// Data Cerita
imageCeritaId: responseUploadImageDonasi.data.id,
pembukaan: data.pembukaan,
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) {
console.log("[ERROR]", error);
} finally {
setLoading(false);
}
};
return (
<ViewWrapper>
<StackCustom gap={"xs"}>
@@ -22,6 +121,8 @@ export default function DonationCreateStory() {
required
showCount
maxLength={1000}
value={data.pembukaan}
onChangeText={(value) => setData({ ...data, pembukaan: value })}
/>
<TextAreaCustom
label="Tujuan Donasi"
@@ -29,12 +130,19 @@ export default function DonationCreateStory() {
required
showCount
maxLength={1000}
value={data.cerita}
onChangeText={(value) => setData({ ...data, cerita: value })}
/>
<LandscapeFrameUploaded />
<LandscapeFrameUploaded image={imageStory || ""} />
<ButtonCenteredOnly
onPress={() => {
router.push("/(application)/(image)/take-picture/123");
pickFile({
allowedType: "image",
setImageUri: ({ uri }) => {
setImageStory(uri);
},
});
}}
icon="upload"
>
@@ -47,17 +155,23 @@ export default function DonationCreateStory() {
label="Nama Bank"
placeholder="Masukkan nama bank"
required
value={data.namaBank}
onChangeText={(value) => setData({ ...data, namaBank: value })}
/>
<TextInputCustom
label="Nomor Rekening"
placeholder="Masukkan nomor rekening"
required
keyboardType="numeric"
value={data.rekening}
onChangeText={(value) => setData({ ...data, rekening: value })}
/>
<Spacing />
<ButtonCustom
isLoading={isLoading}
onPress={() => {
router.replace(`/donation/(tabs)/status`);
handlerSubmit();
}}
>
Simpan

View File

@@ -3,17 +3,127 @@ import {
ButtonCustom,
InformationBox,
LandscapeFrameUploaded,
LoaderCustom,
SelectCustom,
Spacing,
StackCustom,
TextInputCustom,
ViewWrapper,
} from "@/components";
import { dummyDonasiDurasi } from "@/lib/dummy-data/donasi/durasi";
import { dummyDonasiKategori } from "@/lib/dummy-data/donasi/kategori";
import { router } from "expo-router";
import DIRECTORY_ID from "@/constants/directory-id";
import { apiDonationCreate } from "@/service/api-client/api-donation";
import { apiMasterDonation } from "@/service/api-client/api-master";
import { uploadFileService } from "@/service/upload-service";
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
import pickFile from "@/utils/pickFile";
import { router, useFocusEffect } from "expo-router";
import _ from "lodash";
import { useCallback, useState } from "react";
import Toast from "react-native-toast-message";
export default function DonationCreate() {
const [listCategory, setListCategory] = useState<any[]>([]);
const [listDuration, setListDuration] = useState<any[]>([]);
const [loadList, setLoadList] = useState<boolean>(false);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [image, setImage] = useState<string | null>(null);
const [data, setData] = useState({
kategoriId: "",
title: "",
target: "",
durasiId: "",
});
const displayTarget = formatCurrencyDisplay(data.target);
const handleChangeCurrency = (field: keyof typeof data) => (text: string) => {
const numeric = text.replace(/\D/g, "");
setData((prev) => ({ ...prev, [field]: numeric }));
};
useFocusEffect(
useCallback(() => {
onLoadList();
}, [])
);
const onLoadList = async () => {
try {
setLoadList(true);
const response = await apiMasterDonation({ category: "" });
setListCategory(response.data.category);
setListDuration(response.data.duration);
} catch (error) {
console.log(["ERROR"], error);
setListCategory([]);
setListDuration([]);
} finally {
setLoadList(false);
}
};
const validateData = () => {
if (!data.title || !data.target || !data.durasiId || !data.kategoriId) {
Toast.show({
type: "error",
text1: "Harap isi semua data",
});
return false;
}
return true;
};
const handlerSubmit = async () => {
if (!validateData()) {
return;
}
try {
setIsLoading(true);
const responseUploadImage = await uploadFileService({
imageUri: image,
dirId: DIRECTORY_ID.donasi_image,
});
if (!responseUploadImage.success) {
Toast.show({
type: "error",
text1: "Gagal mengunggah gambar",
});
return;
}
const imageId = responseUploadImage.data.id;
const newData = {
title: data.title,
target: data.target,
durasiId: data.durasiId,
kategoriId: data.kategoriId,
imageId: imageId,
};
const response = await apiDonationCreate({
data: newData,
category: "temporary",
});
if (!response.success) {
Toast.show({
type: "error",
text1: "Gagal membuat donasi",
});
return;
}
router.push(`/donation/create-story?id=${response.data.id}`);
} catch (error) {
console.log("[ERROR]", error);
} finally {
setIsLoading(false);
}
};
return (
<ViewWrapper>
<StackCustom gap={"xs"}>
@@ -23,18 +133,28 @@ export default function DonationCreate() {
label="Judul Donasi"
placeholder="Masukkan Judul Donasi"
required
value={data.title}
onChangeText={(value) => setData({ ...data, title: value })}
/>
<TextInputCustom
iconLeft="Rp."
label="Target Donasi"
placeholder="Masukkan Target Donasi"
required
keyboardType="numeric"
value={displayTarget}
onChangeText={handleChangeCurrency("target")}
/>
<LandscapeFrameUploaded />
<LandscapeFrameUploaded image={image || ""} />
<ButtonCenteredOnly
onPress={() => {
router.push("/(application)/(image)/take-picture/123");
pickFile({
allowedType: "image",
setImageUri: ({ uri }) => {
setImage(uri);
},
});
}}
icon="upload"
>
@@ -42,31 +162,52 @@ export default function DonationCreate() {
</ButtonCenteredOnly>
<Spacing />
<SelectCustom
data={dummyDonasiKategori.map((item) => ({
label: item.label,
value: item.value,
}))}
onChange={(value) => console.log(value)}
label="Pilih Kategori Donasi"
placeholder="Pilih Kategori Donasi"
required
/>
{loadList ? (
<LoaderCustom />
) : (
<SelectCustom
data={
_.isEmpty(listCategory)
? []
: listCategory?.map((item: any) => ({
label: item.name,
value: item.id,
}))
}
label="Pilih Kategori Donasi"
placeholder="Pilih Kategori Donasi"
required
value={data.kategoriId}
onChange={(value: any) => setData({ ...data, kategoriId: value })}
/>
)}
{loadList ? (
<LoaderCustom />
) : (
<SelectCustom
data={
_.isEmpty(listDuration)
? []
: listDuration?.map((item: any) => ({
label: item.name + `${" hari"}`,
value: item.id,
}))
}
label="Pilih Durasi Donasi"
placeholder="Pilih Durasi Donasi"
required
value={data.durasiId}
onChange={(value: any) => setData({ ...data, durasiId: value })}
/>
)}
<SelectCustom
data={dummyDonasiDurasi.map((item) => ({
label: item.label,
value: item.value,
}))}
onChange={(value) => console.log(value)}
label="Pilih Durasi Donasi"
placeholder="Pilih Durasi Donasi"
required
/>
<Spacing />
<ButtonCustom
isLoading={isLoading}
onPress={() => {
router.replace("/donation/create-story");
handlerSubmit();
// router.push(`/donation/create-story?id=${"dasdsadsa"}`);
}}
>
Selanjutnya

View File

@@ -1,3 +1,4 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
AlertDefaultSystem,
BackButton,
@@ -8,37 +9,71 @@ import {
MenuDrawerDynamicGrid,
StackCustom,
TextCustom,
ViewWrapper
ViewWrapper,
} from "@/components";
import { IconTrash } from "@/components/_Icon/IconTrash";
import { router, Stack, useLocalSearchParams } from "expo-router";
import { useState } from "react";
import { useAuth } from "@/hooks/use-auth";
import {
apiInvestmentDeleteNews,
apiInvestmentGetNews,
} from "@/service/api-client/api-investment";
import {
router,
Stack,
useFocusEffect,
useLocalSearchParams,
} from "expo-router";
import { useCallback, useState } from "react";
import Toast from "react-native-toast-message";
export default function InvestmentNews() {
const { id, news } = useLocalSearchParams();
const { user } = useAuth();
const { news } = useLocalSearchParams();
const id = news as string;
const [openDrawer, setOpenDrawer] = useState(false);
const [data, setData] = useState<any | null>(null);
useFocusEffect(
useCallback(() => {
onLoadData();
}, [id])
);
const onLoadData = async () => {
try {
const response = await apiInvestmentGetNews({
id: id,
category: "one-news",
});
setData(response.data);
} catch (error) {
console.log("[ERROR]", error);
}
};
return (
<>
<Stack.Screen
options={{
title: "Detail Berita",
headerLeft: () => <BackButton />,
headerRight: () => <DotButton onPress={() => setOpenDrawer(true)} />,
headerRight: () =>
user?.id === data?.authorId && (
<DotButton onPress={() => setOpenDrawer(true)} />
),
}}
/>
<ViewWrapper>
<BaseBox>
<StackCustom>
<DummyLandscapeImage />
{data && data?.imageId && (
<DummyLandscapeImage imageId={data?.imageId || ""} />
)}
<TextCustom bold align="center" size="large">
Judul Berita {news} Terbaru
</TextCustom>
<TextCustom>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Laborum
fuga mollitia laboriosam voluptatibus quos molestias, illo fugiat
esse repellat, ad officia earum numquam? Aliquid corrupti quam
tempora cum harum est!
{(data && data?.title) || "-"}
</TextCustom>
<TextCustom>{(data && data?.deskripsi) || "-"}</TextCustom>
</StackCustom>
</BaseBox>
</ViewWrapper>
@@ -52,7 +87,7 @@ export default function InvestmentNews() {
data={[
{
label: "Hapus Berita",
path: `/investment/${id}/add-news`,
path: ``,
icon: <IconTrash />,
color: "red",
},
@@ -63,9 +98,26 @@ export default function InvestmentNews() {
message: "Apakah Anda yakin ingin menghapus berita ini?",
textLeft: "Batal",
textRight: "Hapus",
onPressRight: () => {
router.back();
setOpenDrawer(false);
onPressRight: async () => {
try {
const response = await apiInvestmentDeleteNews({ id });
if (response.success) {
Toast.show({
type: "success",
text1: "Berita berhasil dihapus",
});
router.back();
setOpenDrawer(false);
} else {
Toast.show({
type: "error",
text1: "Gagal menghapus berita",
});
}
} catch (error) {
console.log("[ERROR]", error);
}
},
});
}}

View File

@@ -9,17 +9,89 @@ import {
TextInputCustom,
ViewWrapper,
} from "@/components";
import { router } from "expo-router";
import DIRECTORY_ID from "@/constants/directory-id";
import { apiInvestmentCreateNews } from "@/service/api-client/api-investment";
import { uploadFileService } from "@/service/upload-service";
import pickFile, { IFileData } from "@/utils/pickFile";
import { router, useLocalSearchParams } from "expo-router";
import { useState } from "react";
import Toast from "react-native-toast-message";
export default function InvestmentAddNews() {
const { id } = useLocalSearchParams();
const [image, setImage] = useState<IFileData | null>(null);
const [data, setData] = useState({
title: "",
deskripsi: "",
});
const [isLoading, setIsLoading] = useState(false);
const handlerSubmit = async () => {
let imageId = "";
if (!data.title || !data.deskripsi) {
Toast.show({
type: "error",
text1: "Judul dan deskripsi harus diisi",
});
return;
}
try {
setIsLoading(true);
if (image) {
const uploadImage = await uploadFileService({
dirId: DIRECTORY_ID.investasi_berita,
imageUri: image.uri,
});
imageId = uploadImage.data.id;
}
const newData = {
id: id as string,
title: data.title,
deskripsi: data.deskripsi,
imageId: imageId,
};
const response = await apiInvestmentCreateNews({
id: id as string,
data: newData,
});
if (response.success) {
Toast.show({
type: "success",
text1: "Berita berhasil disimpan",
});
router.back();
} else {
Toast.show({
type: "error",
text1: "Gagal menyimpan berita",
});
}
} catch (error) {
console.log("[ERROR]", error);
} finally {
setIsLoading(false);
}
};
return (
<ViewWrapper>
<StackCustom gap={"xs"}>
<InformationBox text="Pengunggahan foto ke aplikasi bersifat opsional dan tidak diwajibkan, Anda dapat menyimpan berita tanpa mengunggah foto." />
<LandscapeFrameUploaded />
<LandscapeFrameUploaded image={image?.uri} />
<ButtonCenteredOnly
onPress={() => {
router.push("/(application)/(image)/take-picture/123");
pickFile({
allowedType: "image",
setImageUri(file) {
setImage(file);
},
});
}}
icon="upload"
>
@@ -30,6 +102,8 @@ export default function InvestmentAddNews() {
label="Judul Berita"
placeholder="Masukan judul berita"
required
value={data.title}
onChangeText={(value) => setData({ ...data, title: value })}
/>
<TextAreaCustom
label="Deskripsi Berita"
@@ -37,13 +111,11 @@ export default function InvestmentAddNews() {
required
showCount
maxLength={1000}
value={data.deskripsi}
onChangeText={(value) => setData({ ...data, deskripsi: value })}
/>
<ButtonCustom
onPress={() => {
router.back();
}}
>
<ButtonCustom isLoading={isLoading} onPress={handlerSubmit}>
Simpan
</ButtonCustom>
</StackCustom>

View File

@@ -1,18 +1,51 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
BackButton,
BaseBox,
DrawerCustom,
MenuDrawerDynamicGrid,
TextCustom,
ViewWrapper
BackButton,
BaseBox,
DrawerCustom,
LoaderCustom,
MenuDrawerDynamicGrid,
TextCustom,
ViewWrapper,
} from "@/components";
import { IconPlus } from "@/components/_Icon";
import { router, Stack, useLocalSearchParams } from "expo-router";
import { useState } from "react";
import { apiInvestmentGetNews } from "@/service/api-client/api-investment";
import {
router,
Stack,
useFocusEffect,
useLocalSearchParams,
} from "expo-router";
import _ from "lodash";
import { useCallback, useState } from "react";
export default function InvestmentListOfNews() {
const { id } = useLocalSearchParams();
const [openDrawer, setOpenDrawer] = useState(false);
const [list, setList] = useState<any[] | null>(null);
const [loadList, setLoadList] = useState(false);
useFocusEffect(
useCallback(() => {
onLoadList();
}, [id])
);
const onLoadList = async () => {
try {
setLoadList(true);
const response = await apiInvestmentGetNews({
id: id as string,
category: "all-news",
});
setList(response.data);
} catch (error) {
console.log("[ERROR]", error);
} finally {
setLoadList(false);
}
};
return (
<>
<Stack.Screen
@@ -22,16 +55,25 @@ export default function InvestmentListOfNews() {
// headerRight: () => <DotButton onPress={() => setOpenDrawer(true)} />,
}}
/>
<ViewWrapper>
{Array.from({ length: 15 }).map((_, index) => (
<BaseBox
key={index}
paddingBlock={5}
href={`/investment/${id}/(news)/${index + 1}`}
>
<TextCustom bold>Berita Terbaru {index + 1}</TextCustom>
</BaseBox>
))}
{loadList ? (
<LoaderCustom />
) : _.isEmpty(list) ? (
<TextCustom align="center" color="gray">
Tidak ada data
</TextCustom>
) : (
list?.map((item: any, index: number) => (
<BaseBox
key={index}
paddingBlock={5}
href={`/investment/[id]/(news)/${item.id}`}
>
<TextCustom bold>{item.title}</TextCustom>
</BaseBox>
))
)}
</ViewWrapper>
<DrawerCustom

View File

@@ -1,19 +1,53 @@
/* eslint-disable react-hooks/exhaustive-deps */
import {
BackButton,
BaseBox,
DotButton,
DrawerCustom,
LoaderCustom,
MenuDrawerDynamicGrid,
TextCustom,
ViewWrapper,
} from "@/components";
import { IconPlus } from "@/components/_Icon";
import { router, Stack, useLocalSearchParams } from "expo-router";
import { useState } from "react";
import { apiInvestmentGetNews } from "@/service/api-client/api-investment";
import {
router,
Stack,
useFocusEffect,
useLocalSearchParams,
} from "expo-router";
import _ from "lodash";
import { useCallback, useState } from "react";
export default function InvestmentRecapOfNews() {
const { id } = useLocalSearchParams();
const [openDrawer, setOpenDrawer] = useState(false);
const [list, setList] = useState<any[] | null>(null);
const [loadList, setLoadList] = useState(false);
useFocusEffect(
useCallback(() => {
onLoadList();
}, [id])
);
const onLoadList = async () => {
try {
setLoadList(true);
const response = await apiInvestmentGetNews({
id: id as string,
category: "all-news",
});
setList(response.data);
} catch (error) {
console.log("[ERROR]", error);
} finally {
setLoadList(false);
}
};
return (
<>
<Stack.Screen
@@ -24,15 +58,23 @@ export default function InvestmentRecapOfNews() {
}}
/>
<ViewWrapper>
{Array.from({ length: 15 }).map((_, index) => (
<BaseBox
key={index}
paddingBlock={5}
href={`/investment/${id}/(news)/${index + 1}`}
>
<TextCustom bold>Berita Terbaru {index + 1}</TextCustom>
</BaseBox>
))}
{loadList ? (
<LoaderCustom />
) : _.isEmpty(list) ? (
<TextCustom align="center" color="gray">
Tidak ada data
</TextCustom>
) : (
list?.map((item: any, index: number) => (
<BaseBox
key={index}
paddingBlock={5}
href={`/investment/[id]/(news)/${item.id}`}
>
<TextCustom bold>{item.title}</TextCustom>
</BaseBox>
))
)}
</ViewWrapper>
<DrawerCustom

View File

@@ -1,6 +1,6 @@
// PdfViewer.tsx
import React, { useState } from "react";
import { ActivityIndicator, StyleSheet, View } from "react-native";
import { ActivityIndicator, Platform, StyleSheet, View } from "react-native";
import WebView from "react-native-webview";
interface PdfViewerProps {
@@ -10,6 +10,13 @@ interface PdfViewerProps {
const PdfViewer: React.FC<PdfViewerProps> = ({ uri }) => {
const [loading, setLoading] = useState(true);
// ✅ Bungkus dengan Google Docs Viewer
const viewerUrl = `https://docs.google.com/gview?embedded=true&url=${encodeURIComponent(
uri
)}`;
const selectedDivice = Platform.OS === "ios" ? uri : viewerUrl;
return (
<>
{loading && (
@@ -18,7 +25,9 @@ const PdfViewer: React.FC<PdfViewerProps> = ({ uri }) => {
</View>
)}
<WebView
source={{ uri }}
source={{
uri: selectedDivice,
}}
style={styles.webView}
onLoadEnd={() => setLoading(false)}
onError={(syntheticEvent) => {
@@ -26,10 +35,10 @@ const PdfViewer: React.FC<PdfViewerProps> = ({ uri }) => {
console.warn("WebView error:", nativeEvent);
setLoading(false);
}}
scalesPageToFit={true}
javaScriptEnabled={true}
domStorageEnabled={true}
originWhitelist={["*"]}
// scalesPageToFit={true}
// javaScriptEnabled={true}
// domStorageEnabled={true}
// originWhitelist={["*"]}
/>
</>
);

View File

@@ -5,13 +5,14 @@ import {
StackCustom,
TextCustom,
} from "@/components";
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
import { View } from "react-native";
export default function Donasi_BoxStatus({
id,
data,
status,
}: {
id: string;
data: any;
status: string;
}) {
return (
@@ -19,26 +20,30 @@ export default function Donasi_BoxStatus({
<BaseBox
paddingTop={7}
paddingBottom={7}
href={`/donation/${id}/${status}/detail`}
href={`/donation/${data.id}/${status}/detail`}
>
<Grid>
<Grid.Col span={5}>
<DummyLandscapeImage unClickPath height={100} />
<DummyLandscapeImage
unClickPath
height={100}
imageId={data.imageId}
/>
</Grid.Col>
<Grid.Col span={1}>
<View />
</Grid.Col>
<Grid.Col span={6}>
<StackCustom>
<TextCustom truncate>
Judul Donasi: {status} Lorem ipsum dolor sit amet consectetur
adipisicing elit.
</TextCustom>
<TextCustom truncate={2} bold>{data.title || "-"}</TextCustom>
<View>
<TextCustom>Target Dana</TextCustom>
<TextCustom bold color="yellow">
Rp. 7.500.000
Rp.
{data && data?.target
? formatCurrencyDisplay(data.target)
: "-"}
</TextCustom>
</View>
</StackCustom>

View File

@@ -1,20 +1,54 @@
import { AlertDefaultSystem, ButtonCustom, Grid } from "@/components";
import {
apiDonationDelete,
apiDonationUpdateStatus,
} from "@/service/api-client/api-donation";
import { router } from "expo-router";
import { useState } from "react";
import Toast from "react-native-toast-message";
export default function Donation_ButtonStatusSection({
id,
status,
}: {
id: string;
status: string;
}) {
const handleBatalkanReview = () => {
const [isLoading, setLoading] = useState(false);
const [isLoadingDelete, setLoadingDelete] = useState(false);
const handleBatalkanReview = async () => {
AlertDefaultSystem({
title: "Batalkan Review",
message: "Apakah Anda yakin ingin batalkan review ini?",
textLeft: "Batal",
textRight: "Ya",
onPressRight: () => {
console.log("Hapus");
router.back();
onPressRight: async () => {
try {
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?",
textLeft: "Batal",
textRight: "Ya",
onPressRight: () => {
console.log("Hapus");
router.back();
onPressRight: async () => {
try {
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?",
textLeft: "Batal",
textRight: "Ya",
onPressRight: () => {
console.log("Hapus");
router.back();
onPressRight: async () => {
try {
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?",
textLeft: "Batal",
textRight: "Hapus",
onPressRight: () => {
console.log("Hapus");
router.back();
onPressRight: async () => {
try {
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 (
<>
<ButtonCustom
isLoading={isLoadingDelete}
backgroundColor="red"
textColor="white"
onPress={handleOpenDeleteAlert}
@@ -78,7 +182,7 @@ export default function Donation_ButtonStatusSection({
case "review":
return (
<ButtonCustom onPress={handleBatalkanReview}>
<ButtonCustom isLoading={isLoading} onPress={handleBatalkanReview}>
Batalkan Review
</ButtonCustom>
);
@@ -88,7 +192,7 @@ export default function Donation_ButtonStatusSection({
<>
<Grid>
<Grid.Col span={6} style={{ paddingRight: 10 }}>
<ButtonCustom onPress={handleAjukanReview}>
<ButtonCustom isLoading={isLoading} onPress={handleAjukanReview}>
Ajukan Review
</ButtonCustom>
</Grid.Col>
@@ -104,7 +208,7 @@ export default function Donation_ButtonStatusSection({
<>
<Grid>
<Grid.Col span={6} style={{ paddingRight: 10 }}>
<ButtonCustom onPress={handleEditKembali}>
<ButtonCustom isLoading={isLoading} onPress={handleEditKembali}>
Edit Kembali
</ButtonCustom>
</Grid.Col>

View File

@@ -5,25 +5,29 @@ import {
TextCustom,
Grid,
} from "@/components";
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
import React from "react";
import { View } from "react-native";
export default function Donation_ComponentBoxDetailData({
bottomSection,
data,
}: {
bottomSection?: React.ReactNode;
data: any;
}) {
return (
<>
<BaseBox>
<StackCustom>
<DummyLandscapeImage />
<DummyLandscapeImage imageId={data?.imageId} />
<View>
<TextCustom bold size="large">
Judul Donasi: Lorem, ipsum dolor sit amet consectetur adipisicing
elit.
{data?.title || "-"}
</TextCustom>
<TextCustom size="small">
Durasi: {data?.DonasiMaster_Durasi?.name || "-"}
</TextCustom>
<TextCustom size="small">Durasi: 30 hari</TextCustom>
</View>
<Grid>
@@ -31,7 +35,7 @@ export default function Donation_ComponentBoxDetailData({
<View>
<TextCustom size="small">Target Dana</TextCustom>
<TextCustom truncate={2} size="large" bold color="yellow">
Rp. 7.500.000
Rp. {formatCurrencyDisplay(data?.target) || "-"}
</TextCustom>
</View>
</Grid.Col>
@@ -39,7 +43,7 @@ export default function Donation_ComponentBoxDetailData({
<View>
<TextCustom size="small">Kategori</TextCustom>
<TextCustom size="large" bold color="yellow">
Kegiatan Sosial
{data?.DonasiMaster_Ketegori?.name || "-"}
</TextCustom>
</View>
</Grid.Col>

View File

@@ -5,8 +5,10 @@ import { Ionicons } from "@expo/vector-icons";
export default function Donation_ComponentStoryFunrising({
id,
dataStory,
}: {
id: string;
dataStory: any;
}) {
return (
<>
@@ -29,12 +31,7 @@ export default function Donation_ComponentStoryFunrising({
/>
</Grid.Col>
</Grid>
<TextCustom truncate={3}>
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>
<TextCustom truncate={3}>{dataStory?.pembukaan || "-"}</TextCustom>
</StackCustom>
</BaseBox>
</>

View File

@@ -8,11 +8,10 @@ export default function Investment_ButtonInvestasiSection({
id: string;
isMine: boolean;
}) {
console.log("[IS MINE]", isMine);
return (
<>
{isMine ? (
<ButtonCustom disabled>Investasi Ini Milik Anda</ButtonCustom>
<ButtonCustom disabled>Investasi ini milik Anda</ButtonCustom>
) : (
<ButtonCustom
onPress={() => {

View File

@@ -0,0 +1,82 @@
import { apiConfig } from "../api-config";
export async function apiDonationCreate({
data,
category,
}: {
data: any;
category: "temporary" | "permanent";
}) {
try {
const response = await apiConfig.post(
`/mobile/donation?category=${category}`,
{
data: data,
}
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiDonationGetOne({
id,
category,
}: {
id: string;
category: "temporary" | "permanent";
}) {
try {
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;
} catch (error) {
throw error;
}
}

View File

@@ -145,12 +145,9 @@ export async function apiInvestmentCreateInvoice({
data: any;
}) {
try {
const response = await apiConfig.post(
`/mobile/investment/${id}/invoice`,
{
data: data,
}
);
const response = await apiConfig.post(`/mobile/investment/${id}/invoice`, {
data: data,
});
return response.data;
} catch (error) {
throw error;
@@ -201,3 +198,46 @@ export async function apiInvestmentUpdateInvoice({
throw error;
}
}
export async function apiInvestmentCreateNews({
id,
data,
}: {
id: string;
data: any;
}) {
try {
const response = await apiConfig.post(`/mobile/investment/${id}/news`, {
data: data,
});
return response.data;
} catch (error) {
throw error;
}
}
export async function apiInvestmentGetNews({
id,
category,
}: {
id: string;
category: "all-news" | "one-news";
}) {
try {
const response = await apiConfig.get(
`/mobile/investment/${id}/news?category=${category}`
);
return response.data;
} catch (error) {
throw error;
}
}
export async function apiInvestmentDeleteNews({ id }: { id: string }) {
try {
const response = await apiConfig.delete(`/mobile/investment/${id}/news`);
return response.data;
} catch (error) {
throw error;
}
}

View File

@@ -135,3 +135,19 @@ export async function apiMasterBank() {
throw error;
}
}
export async function apiMasterDonation({
category,
}: {
category: "category" | "duration" | "";
}) {
const selectCategory = category ? `?category=${category}` : "";
try {
const response = await apiConfig.get(
`/mobile/master/donation${selectCategory}`
);
return response.data;
} catch (error) {
throw error;
}
}