Compare commits
11 Commits
api-invest
...
api-admin/
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f36620988 | |||
| f750d158be | |||
| 0e7b29bb15 | |||
| b293310969 | |||
| a980397640 | |||
| 7c82e8b588 | |||
| 53cdca21fc | |||
| ba878d4d08 | |||
| f3a3acc747 | |||
| a6389174d7 | |||
| 2be4afdcb1 |
@@ -10,7 +10,6 @@ export default function UserLayout() {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack screenOptions={HeaderStyles}>
|
<Stack screenOptions={HeaderStyles}>
|
||||||
|
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="waiting-room"
|
name="waiting-room"
|
||||||
options={{
|
options={{
|
||||||
@@ -186,7 +185,7 @@ export default function UserLayout() {
|
|||||||
name="crowdfunding/index"
|
name="crowdfunding/index"
|
||||||
options={{
|
options={{
|
||||||
title: "Crowdfunding",
|
title: "Crowdfunding",
|
||||||
headerLeft: () => <BackButton />,
|
headerLeft: () => <BackButton path="/home" />,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -449,7 +448,7 @@ export default function UserLayout() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="donation/[id]/(transaction-flow)/[transaction]/invoice"
|
name="donation/[id]/(transaction-flow)/[invoiceId]/invoice"
|
||||||
options={{
|
options={{
|
||||||
title: "Invoice",
|
title: "Invoice",
|
||||||
headerLeft: () => (
|
headerLeft: () => (
|
||||||
@@ -463,7 +462,7 @@ export default function UserLayout() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="donation/[id]/(transaction-flow)/[transaction]/process"
|
name="donation/[id]/(transaction-flow)/[invoiceId]/process"
|
||||||
options={{
|
options={{
|
||||||
title: "Proses",
|
title: "Proses",
|
||||||
headerLeft: () => (
|
headerLeft: () => (
|
||||||
@@ -477,14 +476,14 @@ export default function UserLayout() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="donation/[id]/(transaction-flow)/[transaction]/success"
|
name="donation/[id]/(transaction-flow)/[invoiceId]/success"
|
||||||
options={{
|
options={{
|
||||||
title: "Donasi Berhasil",
|
title: "Donasi Berhasil",
|
||||||
headerLeft: () => <BackButton />,
|
headerLeft: () => <BackButton />,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="donation/[id]/(transaction-flow)/[transaction]/failed"
|
name="donation/[id]/(transaction-flow)/[invoiceId]/failed"
|
||||||
options={{
|
options={{
|
||||||
title: "Donasi Gagal",
|
title: "Donasi Gagal",
|
||||||
headerLeft: () => <BackButton />,
|
headerLeft: () => <BackButton />,
|
||||||
|
|||||||
@@ -1,11 +1,41 @@
|
|||||||
import {
|
import {
|
||||||
FloatingButton,
|
FloatingButton,
|
||||||
ViewWrapper
|
LoaderCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import Donation_BoxPublish from "@/screens/Donation/BoxPublish";
|
import Donation_BoxPublish from "@/screens/Donation/BoxPublish";
|
||||||
import { router } from "expo-router";
|
import { apiDonationGetAll } from "@/service/api-client/api-donation";
|
||||||
|
import { router, useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function DonationBeranda() {
|
export default function DonationBeranda() {
|
||||||
|
const [list, setList] = useState<any[] | null>(null);
|
||||||
|
const [loadList, setLoadList] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadList(true);
|
||||||
|
const response = await apiDonationGetAll({
|
||||||
|
category: "beranda"
|
||||||
|
});
|
||||||
|
console.log("[RES GET ALL]", JSON.stringify(response.data, null, 2));
|
||||||
|
|
||||||
|
setList(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper
|
<ViewWrapper
|
||||||
hideFooter
|
hideFooter
|
||||||
@@ -13,9 +43,15 @@ export default function DonationBeranda() {
|
|||||||
<FloatingButton onPress={() => router.push("/donation/create")} />
|
<FloatingButton onPress={() => router.push("/donation/create")} />
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadList ? (
|
||||||
<Donation_BoxPublish key={index} id={index.toString()}/>
|
<LoaderCustom />
|
||||||
))}
|
) : _.isEmpty(list) ? (
|
||||||
|
<TextCustom align="center" color="gray">Belum ada donasi</TextCustom>
|
||||||
|
) : (
|
||||||
|
list?.map((item: any, index: number) => (
|
||||||
|
<Donation_BoxPublish data={item} key={index} id={item.id} />
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,76 +1,142 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BadgeCustom,
|
BadgeCustom,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
DummyLandscapeImage,
|
DummyLandscapeImage,
|
||||||
Grid,
|
Grid,
|
||||||
|
LoaderCustom,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { dummyMasterStatusTransaction } from "@/lib/dummy-data/_master/status-transaction";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import { router } from "expo-router";
|
import { apiDonationGetAll } from "@/service/api-client/api-donation";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
|
import { Href, router, useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function DonationMyDonation() {
|
export default function DonationMyDonation() {
|
||||||
const randomStatusData = Array.from({ length: 10 }, () => {
|
const { user } = useAuth();
|
||||||
const randomIndex = Math.floor(
|
const [list, setList] = useState<any[] | null>(null);
|
||||||
Math.random() * dummyMasterStatusTransaction.length
|
const [loadList, setLoadList] = useState(false);
|
||||||
);
|
|
||||||
return dummyMasterStatusTransaction[randomIndex];
|
|
||||||
});
|
|
||||||
|
|
||||||
const handlePress = (value: string) => {
|
useFocusEffect(
|
||||||
if (value === "menunggu") {
|
useCallback(() => {
|
||||||
router.push(`/donation/${value}/(transaction-flow)/123/invoice`);
|
onLoadData();
|
||||||
} else if (value === "proses") {
|
}, [user?.id])
|
||||||
router.push(`/donation/${value}/(transaction-flow)/123/process`);
|
);
|
||||||
} else if (value === "berhasil") {
|
|
||||||
router.push(`/donation/${value}/(transaction-flow)/123/success`);
|
const onLoadData = async () => {
|
||||||
} else if (value === "gagal") {
|
try {
|
||||||
router.push(`/donation/${value}/(transaction-flow)/123/failed`);
|
setLoadList(true);
|
||||||
|
const response = await apiDonationGetAll({
|
||||||
|
category: "my-donation",
|
||||||
|
authorId: user?.id,
|
||||||
|
});
|
||||||
|
console.log(
|
||||||
|
"[RES GET MY DONATION]",
|
||||||
|
JSON.stringify(response.data, null, 2)
|
||||||
|
);
|
||||||
|
|
||||||
|
setList(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerColor = (status: string) => {
|
||||||
|
if (status === "menunggu") {
|
||||||
|
return "orange";
|
||||||
|
} else if (status === "proses") {
|
||||||
|
return "white";
|
||||||
|
} else if (status === "berhasil") {
|
||||||
|
return "green";
|
||||||
|
} else if (status === "gagal") {
|
||||||
|
return "red";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePress = ({
|
||||||
|
invoiceId,
|
||||||
|
donationId,
|
||||||
|
status,
|
||||||
|
}: {
|
||||||
|
invoiceId: string;
|
||||||
|
donationId: string;
|
||||||
|
status: string;
|
||||||
|
}) => {
|
||||||
|
const url: Href = `../${donationId}/(transaction-flow)/${invoiceId}`;
|
||||||
|
if (status === "menunggu") {
|
||||||
|
router.push(`${url}/invoice`);
|
||||||
|
} else if (status === "proses") {
|
||||||
|
router.push(`${url}/process`);
|
||||||
|
} else if (status === "berhasil") {
|
||||||
|
router.push(`${url}/success`);
|
||||||
|
} else if (status === "gagal") {
|
||||||
|
router.push(`${url}/failed`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper hideFooter>
|
<ViewWrapper hideFooter>
|
||||||
{randomStatusData.map((item, index) => (
|
{loadList ? (
|
||||||
<BaseBox
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(list) ? (
|
||||||
paddingTop={7}
|
<TextCustom align="center" color="gray">
|
||||||
paddingBottom={7}
|
Belum ada transaksi
|
||||||
onPress={() => {
|
</TextCustom>
|
||||||
handlePress(item.value);
|
) : (
|
||||||
}}
|
list?.map((item, index) => (
|
||||||
>
|
<BaseBox
|
||||||
<Grid>
|
key={index}
|
||||||
<Grid.Col span={5}>
|
paddingTop={7}
|
||||||
<DummyLandscapeImage height={100} unClickPath />
|
paddingBottom={7}
|
||||||
</Grid.Col>
|
onPress={() => {
|
||||||
<Grid.Col span={1}>
|
handlePress({
|
||||||
<View />
|
status: _.lowerCase(item.statusInvoice),
|
||||||
</Grid.Col>
|
invoiceId: item.id,
|
||||||
<Grid.Col span={6}>
|
donationId: item.donasiId,
|
||||||
<StackCustom gap={"sm"}>
|
});
|
||||||
<View>
|
}}
|
||||||
<TextCustom truncate>
|
>
|
||||||
Judul Donasi: Lorem ipsum dolor sit amet consectetur
|
<Grid>
|
||||||
adipisicing elit.
|
<Grid.Col span={5}>
|
||||||
|
<DummyLandscapeImage
|
||||||
|
height={100}
|
||||||
|
unClickPath
|
||||||
|
imageId={item.imageId}
|
||||||
|
/>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={1}>
|
||||||
|
<View />
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={6}>
|
||||||
|
<StackCustom>
|
||||||
|
<TextCustom truncate={2} bold>
|
||||||
|
{item.title || "-"}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</View>
|
|
||||||
<View>
|
|
||||||
<TextCustom>Donasi Saya</TextCustom>
|
|
||||||
<TextCustom bold color="yellow">
|
<TextCustom bold color="yellow">
|
||||||
Rp. 7.500.000
|
Rp. {formatCurrencyDisplay(item.nominal)}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</View>
|
|
||||||
<BadgeCustom variant="light" color={item.color} fullWidth>
|
<BadgeCustom
|
||||||
{item.label}
|
variant="light"
|
||||||
</BadgeCustom>
|
color={handlerColor(_.lowerCase(item.statusInvoice))}
|
||||||
</StackCustom>
|
fullWidth
|
||||||
</Grid.Col>
|
>
|
||||||
</Grid>
|
{item.statusInvoice}
|
||||||
</BaseBox>
|
</BadgeCustom>
|
||||||
))}
|
</StackCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
ButtonCenteredOnly,
|
ButtonCenteredOnly,
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
@@ -9,17 +10,120 @@ import {
|
|||||||
TextInputCustom,
|
TextInputCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { router } from "expo-router";
|
import API_STRORAGE from "@/constants/base-url-api-strorage";
|
||||||
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
|
import {
|
||||||
|
apiDonationGetNewsById,
|
||||||
|
apiDonationUpdateNews,
|
||||||
|
} from "@/service/api-client/api-donation";
|
||||||
|
import { uploadFileService } from "@/service/upload-service";
|
||||||
|
import pickFile, { IFileData } from "@/utils/pickFile";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function DonationEditNews() {
|
export default function DonationEditNews() {
|
||||||
|
const { news } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState<any>(null);
|
||||||
|
const [image, setImage] = useState<IFileData | null>(null);
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [news])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiDonationGetNewsById({
|
||||||
|
id: news as string,
|
||||||
|
category: "get-one",
|
||||||
|
});
|
||||||
|
|
||||||
|
setData(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmitUpdate = async () => {
|
||||||
|
let newData;
|
||||||
|
if (!data.title || !data.deskripsi) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Judul dan deskripsi harus diisi",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
|
newData = {
|
||||||
|
title: data?.title,
|
||||||
|
deskripsi: data?.deskripsi,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (image && image?.uri) {
|
||||||
|
const uploadNewImage = await uploadFileService({
|
||||||
|
dirId: DIRECTORY_ID.donasi_kabar,
|
||||||
|
imageUri: image?.uri,
|
||||||
|
});
|
||||||
|
|
||||||
|
newData = {
|
||||||
|
title: data?.title,
|
||||||
|
deskripsi: data?.deskripsi,
|
||||||
|
newImageId: uploadNewImage.data.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await apiDonationUpdateNews({
|
||||||
|
id: news as string,
|
||||||
|
data: newData,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengupdate berita",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Berita berhasil diperbarui",
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
<InformationBox text="Upload gambar bersifat opsional untuk melengkapi kabar terkait donasi Anda." />
|
<InformationBox text="Upload gambar bersifat opsional untuk melengkapi kabar terkait donasi Anda." />
|
||||||
<LandscapeFrameUploaded />
|
<LandscapeFrameUploaded
|
||||||
|
image={
|
||||||
|
image
|
||||||
|
? image.uri
|
||||||
|
: data && data.imageId
|
||||||
|
? API_STRORAGE.GET({ fileId: data.imageId })
|
||||||
|
: undefined
|
||||||
|
}
|
||||||
|
/>
|
||||||
<ButtonCenteredOnly
|
<ButtonCenteredOnly
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.push("/(application)/(image)/take-picture/123");
|
pickFile({
|
||||||
|
allowedType: "image",
|
||||||
|
setImageUri(file) {
|
||||||
|
setImage(file);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
icon="upload"
|
icon="upload"
|
||||||
>
|
>
|
||||||
@@ -30,6 +134,8 @@ export default function DonationEditNews() {
|
|||||||
label="Judul Berita"
|
label="Judul Berita"
|
||||||
placeholder="Masukan judul berita"
|
placeholder="Masukan judul berita"
|
||||||
required
|
required
|
||||||
|
value={data?.title}
|
||||||
|
onChangeText={(value) => setData({ ...data, title: value })}
|
||||||
/>
|
/>
|
||||||
<TextAreaCustom
|
<TextAreaCustom
|
||||||
label="Deskripsi Berita"
|
label="Deskripsi Berita"
|
||||||
@@ -37,12 +143,16 @@ export default function DonationEditNews() {
|
|||||||
required
|
required
|
||||||
showCount
|
showCount
|
||||||
maxLength={1000}
|
maxLength={1000}
|
||||||
|
value={data?.deskripsi}
|
||||||
|
onChangeText={(value) => setData({ ...data, deskripsi: value })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Spacing />
|
<Spacing />
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
disabled={!data?.title || !data?.deskripsi}
|
||||||
|
isLoading={isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.back();
|
handlerSubmitUpdate();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Update
|
Update
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
BackButton,
|
BackButton,
|
||||||
@@ -12,13 +13,45 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconEdit } from "@/components/_Icon";
|
import { IconEdit } from "@/components/_Icon";
|
||||||
import { IconTrash } from "@/components/_Icon/IconTrash";
|
import { IconTrash } from "@/components/_Icon/IconTrash";
|
||||||
import dayjs from "dayjs";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import {
|
||||||
import { useState } from "react";
|
apiDonationDeleteNews,
|
||||||
|
apiDonationGetNewsById,
|
||||||
|
} from "@/service/api-client/api-donation";
|
||||||
|
import { formatChatTime } from "@/utils/formatChatTime";
|
||||||
|
import {
|
||||||
|
router,
|
||||||
|
Stack,
|
||||||
|
useFocusEffect,
|
||||||
|
useLocalSearchParams,
|
||||||
|
} from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function DonationNews() {
|
export default function DonationNews() {
|
||||||
const { id, news } = useLocalSearchParams();
|
const { user } = useAuth();
|
||||||
|
const { news } = useLocalSearchParams();
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
|
const [data, setData] = useState<any>(null);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [news])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiDonationGetNewsById({
|
||||||
|
id: news as string,
|
||||||
|
category: "get-one",
|
||||||
|
});
|
||||||
|
|
||||||
|
setData(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -26,28 +59,28 @@ export default function DonationNews() {
|
|||||||
options={{
|
options={{
|
||||||
title: "Detail Kabar",
|
title: "Detail Kabar",
|
||||||
headerLeft: () => <BackButton />,
|
headerLeft: () => <BackButton />,
|
||||||
headerRight: () => <DotButton onPress={() => setOpenDrawer(true)} />,
|
headerRight: () =>
|
||||||
|
user?.id === data?.authorId && (
|
||||||
|
<DotButton onPress={() => setOpenDrawer(true)} />
|
||||||
|
),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<TextCustom style={{ alignSelf: "flex-end" }}>
|
<TextCustom style={{ alignSelf: "flex-end" }}>
|
||||||
{dayjs().format("DD MMM YYYY")}
|
{formatChatTime(data?.createdAt)}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
|
|
||||||
<DummyLandscapeImage />
|
{data && data.imageId && (
|
||||||
|
<DummyLandscapeImage imageId={data.imageId} />
|
||||||
|
)}
|
||||||
|
|
||||||
<TextCustom bold size="large" align="center">
|
<TextCustom bold size="large" align="center">
|
||||||
Judul Berita
|
{data?.title || "-"}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
|
|
||||||
<TextCustom>
|
<TextCustom>{data?.deskripsi || "-"}</TextCustom>
|
||||||
Lorem ipsum dolor sit amet consectetur adipisicing elit. Sapiente
|
|
||||||
est id temporibus perferendis eos reiciendis reprehenderit tempora
|
|
||||||
ut quibusdam dolores facilis rerum exercitationem recusandae quis
|
|
||||||
neque, adipisci dolorum, aspernatur labore?
|
|
||||||
</TextCustom>
|
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
@@ -62,12 +95,12 @@ export default function DonationNews() {
|
|||||||
{
|
{
|
||||||
icon: <IconEdit />,
|
icon: <IconEdit />,
|
||||||
label: "Edit Berita",
|
label: "Edit Berita",
|
||||||
path: `/donation/${id}/(news)/${news}/edit-news` as any,
|
path: `/donation/[id]/(news)/${news}/edit-news` as any,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: <IconTrash />,
|
icon: <IconTrash />,
|
||||||
label: "Hapus Berita",
|
label: "Hapus Berita",
|
||||||
path: `` as any,
|
path: "",
|
||||||
color: "red",
|
color: "red",
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
@@ -79,7 +112,23 @@ export default function DonationNews() {
|
|||||||
message: "Apakah Anda yakin ingin menghapus berita ini?",
|
message: "Apakah Anda yakin ingin menghapus berita ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Hapus",
|
textRight: "Hapus",
|
||||||
onPressRight: () => {
|
onPressRight: async () => {
|
||||||
|
const response = await apiDonationDeleteNews({
|
||||||
|
id: news as string,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal menghapus berita",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Berita berhasil dihapus",
|
||||||
|
});
|
||||||
router.back();
|
router.back();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,17 +9,79 @@ import {
|
|||||||
TextInputCustom,
|
TextInputCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { router } from "expo-router";
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
|
import { apiDonationCreateNews } from "@/service/api-client/api-donation";
|
||||||
|
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 DonationAddNews() {
|
export default function DonationAddNews() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState({
|
||||||
|
title: "",
|
||||||
|
deskripsi: "",
|
||||||
|
});
|
||||||
|
const [image, setImage] = useState<IFileData | null>(null);
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
let newData: any = { ...data };
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
if (image) {
|
||||||
|
const responseUploadImage = await uploadFileService({
|
||||||
|
dirId: DIRECTORY_ID.donasi_kabar,
|
||||||
|
imageUri: image?.uri,
|
||||||
|
});
|
||||||
|
|
||||||
|
newData = {
|
||||||
|
...newData,
|
||||||
|
imageId: responseUploadImage.data.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await apiDonationCreateNews({
|
||||||
|
id: id as string,
|
||||||
|
data: newData,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal menambah berita",
|
||||||
|
});
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Berita berhasil ditambahkan",
|
||||||
|
});
|
||||||
|
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
<InformationBox text="Upload gambar bersifat opsional untuk melengkapi kabar terkait donasi Anda." />
|
<InformationBox text="Upload gambar bersifat opsional untuk melengkapi kabar terkait donasi Anda." />
|
||||||
<LandscapeFrameUploaded />
|
<LandscapeFrameUploaded image={image?.uri} />
|
||||||
<ButtonCenteredOnly
|
<ButtonCenteredOnly
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.push("/(application)/(image)/take-picture/123");
|
pickFile({
|
||||||
|
allowedType: "image",
|
||||||
|
setImageUri(file) {
|
||||||
|
setImage(file);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
icon="upload"
|
icon="upload"
|
||||||
>
|
>
|
||||||
@@ -30,6 +92,13 @@ export default function DonationAddNews() {
|
|||||||
label="Judul Berita"
|
label="Judul Berita"
|
||||||
placeholder="Masukan judul berita"
|
placeholder="Masukan judul berita"
|
||||||
required
|
required
|
||||||
|
value={data.title}
|
||||||
|
onChangeText={(value) => {
|
||||||
|
setData({
|
||||||
|
...data,
|
||||||
|
title: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<TextAreaCustom
|
<TextAreaCustom
|
||||||
label="Deskripsi Berita"
|
label="Deskripsi Berita"
|
||||||
@@ -37,12 +106,21 @@ export default function DonationAddNews() {
|
|||||||
required
|
required
|
||||||
showCount
|
showCount
|
||||||
maxLength={1000}
|
maxLength={1000}
|
||||||
|
value={data.deskripsi}
|
||||||
|
onChangeText={(value) => {
|
||||||
|
setData({
|
||||||
|
...data,
|
||||||
|
deskripsi: value,
|
||||||
|
});
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Spacing />
|
<Spacing />
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
disabled={!data.title || !data.deskripsi}
|
||||||
|
isLoading={isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.back();
|
handlerSubmit();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
|
|||||||
@@ -1,45 +1,88 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BackButton,
|
BackButton,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
Grid,
|
Grid,
|
||||||
MenuDrawerDynamicGrid,
|
LoaderCustom,
|
||||||
TextCustom,
|
MenuDrawerDynamicGrid,
|
||||||
ViewWrapper
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconPlus } from "@/components/_Icon";
|
import { IconPlus } from "@/components/_Icon";
|
||||||
import dayjs from "dayjs";
|
import { apiDonationGetNewsById } from "@/service/api-client/api-donation";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import { formatChatTime } from "@/utils/formatChatTime";
|
||||||
import { useState } from "react";
|
import {
|
||||||
|
router,
|
||||||
|
Stack,
|
||||||
|
useFocusEffect,
|
||||||
|
useLocalSearchParams,
|
||||||
|
} from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function DonationRecapOfNews() {
|
export default function DonationRecapOfNews() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
|
const [list, setList] = useState<any[] | null>(null);
|
||||||
|
const [loadList, setLoadList] = useState<boolean>(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadList();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadList = async () => {
|
||||||
|
try {
|
||||||
|
setLoadList(true);
|
||||||
|
const response = await apiDonationGetNewsById({
|
||||||
|
id: id as string,
|
||||||
|
category: "get-all",
|
||||||
|
});
|
||||||
|
|
||||||
|
setList(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setList([]);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
options={{
|
options={{
|
||||||
title: "Daftar Kabar",
|
title: "Daftar Kabar",
|
||||||
headerLeft: () => <BackButton />, }}
|
headerLeft: () => <BackButton />,
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
{Array.from({ length: 15 }).map((_, index) => (
|
{loadList ? (
|
||||||
<BaseBox key={index} href={`/donation/${id}/(news)/${index}`}>
|
<LoaderCustom />
|
||||||
<Grid>
|
) : _.isEmpty(list) ? (
|
||||||
<Grid.Col span={8}>
|
<TextCustom align="center" color="gray">
|
||||||
<TextCustom truncate bold>
|
Tidak ada kabar
|
||||||
Lorem ipsum dolor, sit amet consectetur adipisicing elit.
|
</TextCustom>
|
||||||
</TextCustom>
|
) : (
|
||||||
</Grid.Col>
|
list?.map((item: any, index: number) => (
|
||||||
<Grid.Col span={4} style={{ alignItems: "flex-end" }}>
|
<BaseBox key={index} href={`/donation/[id]/(news)/${item.id}`}>
|
||||||
<TextCustom size="small">
|
<Grid>
|
||||||
{dayjs().format("DD MMM YYYY")}
|
<Grid.Col span={8}>
|
||||||
</TextCustom>
|
<TextCustom truncate bold>
|
||||||
</Grid.Col>
|
{item?.title || "-"}
|
||||||
</Grid>
|
</TextCustom>
|
||||||
</BaseBox>
|
</Grid.Col>
|
||||||
))}
|
<Grid.Col span={4} style={{ alignItems: "flex-end" }}>
|
||||||
|
<TextCustom size="small">
|
||||||
|
{formatChatTime(item?.createdAt)}
|
||||||
|
</TextCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
<DrawerCustom
|
<DrawerCustom
|
||||||
|
|||||||
@@ -1,21 +1,55 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BackButton,
|
BackButton,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
DotButton,
|
DotButton,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
Grid,
|
Grid,
|
||||||
|
LoaderCustom,
|
||||||
MenuDrawerDynamicGrid,
|
MenuDrawerDynamicGrid,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconPlus } from "@/components/_Icon";
|
import { IconPlus } from "@/components/_Icon";
|
||||||
import dayjs from "dayjs";
|
import { apiDonationGetNewsById } from "@/service/api-client/api-donation";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import { formatChatTime } from "@/utils/formatChatTime";
|
||||||
import { useState } from "react";
|
import {
|
||||||
|
router,
|
||||||
|
Stack,
|
||||||
|
useFocusEffect,
|
||||||
|
useLocalSearchParams,
|
||||||
|
} from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function DonationRecapOfNews() {
|
export default function DonationRecapOfNews() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
|
const [list, setList] = useState<any[] | null>(null);
|
||||||
|
const [loadList, setLoadList] = useState<boolean>(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadList();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadList = async () => {
|
||||||
|
try {
|
||||||
|
setLoadList(true);
|
||||||
|
const response = await apiDonationGetNewsById({
|
||||||
|
id: id as string,
|
||||||
|
category: "get-all",
|
||||||
|
});
|
||||||
|
|
||||||
|
setList(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setList([]);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -27,20 +61,30 @@ export default function DonationRecapOfNews() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
{Array.from({ length: 15 }).map((_, index) => (
|
{loadList ? (
|
||||||
<BaseBox key={index} href={`/donation/${id}/(news)/${index}`}>
|
<LoaderCustom />
|
||||||
<Grid>
|
) : _.isEmpty(list) ? (
|
||||||
<Grid.Col span={8}>
|
<TextCustom align="center" color="gray">
|
||||||
<TextCustom truncate bold>
|
Tidak ada kabar
|
||||||
Lorem ipsum dolor, sit amet consectetur adipisicing elit.
|
</TextCustom>
|
||||||
</TextCustom>
|
) : (
|
||||||
</Grid.Col>
|
list?.map((item: any, index: number) => (
|
||||||
<Grid.Col span={4} style={{ alignItems: "flex-end" }}>
|
<BaseBox key={index} href={`/donation/[id]/(news)/${item.id}`}>
|
||||||
<TextCustom size="small">{dayjs().format("DD MMM YYYY")}</TextCustom>
|
<Grid>
|
||||||
</Grid.Col>
|
<Grid.Col span={8}>
|
||||||
</Grid>
|
<TextCustom truncate bold>
|
||||||
</BaseBox>
|
{item?.title || "-"}
|
||||||
))}
|
</TextCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={4} style={{ alignItems: "flex-end" }}>
|
||||||
|
<TextCustom size="small">
|
||||||
|
{formatChatTime(item?.createdAt)}
|
||||||
|
</TextCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
<DrawerCustom
|
<DrawerCustom
|
||||||
|
|||||||
@@ -0,0 +1,222 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import {
|
||||||
|
BaseBox,
|
||||||
|
ButtonCenteredOnly,
|
||||||
|
ButtonCustom,
|
||||||
|
Grid,
|
||||||
|
InformationBox,
|
||||||
|
Spacing,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
|
import CopyButton from "@/components/Button/CoyButton";
|
||||||
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
|
import {
|
||||||
|
apiDonationGetInvoiceById,
|
||||||
|
apiDonationUpdateInvoice,
|
||||||
|
} from "@/service/api-client/api-donation";
|
||||||
|
import { uploadFileService } from "@/service/upload-service";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
|
import pickFile from "@/utils/pickFile";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import { View } from "react-native";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
|
export default function DonationInvoice() {
|
||||||
|
const { invoiceId } = useLocalSearchParams();
|
||||||
|
console.log("invoiceId", invoiceId);
|
||||||
|
const [data, setData] = useState<any>(null);
|
||||||
|
const [image, setImage] = useState<any>(null);
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [invoiceId])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiDonationGetInvoiceById({
|
||||||
|
id: invoiceId as string,
|
||||||
|
});
|
||||||
|
console.log("[RESPONSE]", JSON.stringify(response, null, 2));
|
||||||
|
setData(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerUpdateInvoice = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const responseUploadImage = await uploadFileService({
|
||||||
|
dirId: DIRECTORY_ID.donasi_bukti_transfer,
|
||||||
|
imageUri: image?.uri,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[RESPONSE UPLOAD IMAGE]", responseUploadImage);
|
||||||
|
|
||||||
|
if (!responseUploadImage?.data?.id) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengunggah bukti transfer",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileId = responseUploadImage?.data?.id;
|
||||||
|
|
||||||
|
const response = await apiDonationUpdateInvoice({
|
||||||
|
id: invoiceId as string,
|
||||||
|
fileId: fileId,
|
||||||
|
status: "proses",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[RESPONSE UPDATE]", JSON.stringify(response, null, 2));
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengunggah bukti transfer",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Berhasil mengunggah bukti transfer",
|
||||||
|
});
|
||||||
|
router.replace(`/donation/[id]/(transaction-flow)/${invoiceId}/process`);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ViewWrapper>
|
||||||
|
<StackCustom>
|
||||||
|
<InformationBox
|
||||||
|
text={`Mohon transfer donasi anda ke rekening dibawah`}
|
||||||
|
/>
|
||||||
|
<BaseBox>
|
||||||
|
<StackCustom gap={"xs"}>
|
||||||
|
<TextCustom bold>
|
||||||
|
BANK: {data?.DonasiMaster_Bank?.name}
|
||||||
|
</TextCustom>
|
||||||
|
{/* <TextCustom>{data?.DonasiMaster_Bank?.accountName}</TextCustom> */}
|
||||||
|
<Spacing height={10} />
|
||||||
|
|
||||||
|
<BaseBox backgroundColor={MainColor.soft_darkblue}>
|
||||||
|
<Grid containerStyle={{ justifyContent: "center" }}>
|
||||||
|
<Grid.Col
|
||||||
|
span={8}
|
||||||
|
style={{
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextCustom size="xlarge" bold color="yellow">
|
||||||
|
{data?.DonasiMaster_Bank?.norek}
|
||||||
|
</TextCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col
|
||||||
|
span={4}
|
||||||
|
style={{
|
||||||
|
alignItems: "flex-end",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CopyButton textToCopy={data?.DonasiMaster_Bank?.norek} />
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</BaseBox>
|
||||||
|
</StackCustom>
|
||||||
|
</BaseBox>
|
||||||
|
|
||||||
|
<BaseBox>
|
||||||
|
<StackCustom gap={"xs"}>
|
||||||
|
<TextCustom>Jumlah Transaksi</TextCustom>
|
||||||
|
|
||||||
|
<Spacing height={10} />
|
||||||
|
|
||||||
|
<BaseBox backgroundColor={MainColor.soft_darkblue}>
|
||||||
|
<Grid containerStyle={{ justifyContent: "center" }}>
|
||||||
|
<Grid.Col
|
||||||
|
span={8}
|
||||||
|
style={{
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextCustom size="xlarge" bold color="yellow">
|
||||||
|
Rp. {formatCurrencyDisplay(data?.nominal) || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col
|
||||||
|
span={4}
|
||||||
|
style={{
|
||||||
|
alignItems: "flex-end",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<CopyButton textToCopy={data?.nominal} />
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</BaseBox>
|
||||||
|
</StackCustom>
|
||||||
|
</BaseBox>
|
||||||
|
|
||||||
|
<BaseBox>
|
||||||
|
<StackCustom>
|
||||||
|
<TextCustom bold align="center" size={"small"} color="gray">
|
||||||
|
Upload bukti transfer anda.
|
||||||
|
</TextCustom>
|
||||||
|
{image ? (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
gap: 10,
|
||||||
|
paddingInline: 20,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextCustom bold align="center" truncate>
|
||||||
|
{image?.name}
|
||||||
|
</TextCustom>
|
||||||
|
</View>
|
||||||
|
) : null}
|
||||||
|
<ButtonCenteredOnly
|
||||||
|
onPress={() => {
|
||||||
|
pickFile({
|
||||||
|
allowedType: "image",
|
||||||
|
setImageUri(file) {
|
||||||
|
setImage(file);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
icon="upload"
|
||||||
|
>
|
||||||
|
Upload
|
||||||
|
</ButtonCenteredOnly>
|
||||||
|
</StackCustom>
|
||||||
|
</BaseBox>
|
||||||
|
|
||||||
|
<ButtonCustom
|
||||||
|
disabled={!image}
|
||||||
|
isLoading={isLoading}
|
||||||
|
onPress={() => {
|
||||||
|
handlerUpdateInvoice();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Simpan
|
||||||
|
</ButtonCustom>
|
||||||
|
</StackCustom>
|
||||||
|
<Spacing />
|
||||||
|
</ViewWrapper>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,13 +1,6 @@
|
|||||||
import {
|
import { BaseBox, StackCustom, TextCustom, ViewWrapper } from "@/components";
|
||||||
BaseBox,
|
import MoneyTransferAnimation from "@/components/_ShareComponent/MoneyTransferAnimation";
|
||||||
Grid,
|
import { View } from "react-native";
|
||||||
StackCustom,
|
|
||||||
TextCustom,
|
|
||||||
ViewWrapper,
|
|
||||||
} from "@/components";
|
|
||||||
import { MainColor } from "@/constants/color-palet";
|
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
|
||||||
import { ActivityIndicator } from "react-native";
|
|
||||||
|
|
||||||
export default function DonationProcess() {
|
export default function DonationProcess() {
|
||||||
return (
|
return (
|
||||||
@@ -16,13 +9,16 @@ export default function DonationProcess() {
|
|||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<TextCustom align="center" bold>
|
<TextCustom align="center" bold>
|
||||||
Admin sedang memproses transaksi donasimu
|
Admin sedang memvalidasi data dan bukti transfer anda. Mohon
|
||||||
|
tunggu proses ini selesai.
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<ActivityIndicator size="large" color={MainColor.yellow} />
|
<View style={{ alignItems: "center", justifyContent: "center" }}>
|
||||||
|
<MoneyTransferAnimation />
|
||||||
|
</View>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
<BaseBox>
|
{/* <BaseBox>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={10} style={{ justifyContent: "center" }}>
|
<Grid.Col span={10} style={{ justifyContent: "center" }}>
|
||||||
<TextCustom size="small">
|
<TextCustom size="small">
|
||||||
@@ -38,7 +34,7 @@ export default function DonationProcess() {
|
|||||||
/>
|
/>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</BaseBox>
|
</BaseBox> */}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
@@ -1,110 +0,0 @@
|
|||||||
import {
|
|
||||||
BaseBox,
|
|
||||||
ButtonCenteredOnly,
|
|
||||||
ButtonCustom,
|
|
||||||
Grid,
|
|
||||||
InformationBox,
|
|
||||||
Spacing,
|
|
||||||
StackCustom,
|
|
||||||
TextCustom,
|
|
||||||
ViewWrapper,
|
|
||||||
} from "@/components";
|
|
||||||
import { MainColor } from "@/constants/color-palet";
|
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
|
||||||
|
|
||||||
export default function DonationInvoice() {
|
|
||||||
const { id, transaction } = useLocalSearchParams();
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<ViewWrapper>
|
|
||||||
<StackCustom>
|
|
||||||
<InformationBox text={`Mohon transfer donasi anda ke rekening dibawah dengan Id: ${transaction}`} />
|
|
||||||
<BaseBox>
|
|
||||||
<StackCustom gap={"xs"}>
|
|
||||||
<TextCustom>Nama BANK</TextCustom>
|
|
||||||
<TextCustom>Nama Penerima</TextCustom>
|
|
||||||
<Spacing height={10} />
|
|
||||||
|
|
||||||
<BaseBox backgroundColor={MainColor.soft_darkblue}>
|
|
||||||
<Grid containerStyle={{ justifyContent: "center" }}>
|
|
||||||
<Grid.Col
|
|
||||||
span={8}
|
|
||||||
style={{
|
|
||||||
justifyContent: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TextCustom size="xlarge" bold color="yellow">
|
|
||||||
4567898765433567
|
|
||||||
</TextCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col
|
|
||||||
span={4}
|
|
||||||
style={{
|
|
||||||
alignItems: "flex-end",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ButtonCustom>Salin</ButtonCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
</Grid>
|
|
||||||
</BaseBox>
|
|
||||||
</StackCustom>
|
|
||||||
</BaseBox>
|
|
||||||
|
|
||||||
<BaseBox>
|
|
||||||
<StackCustom gap={"xs"}>
|
|
||||||
<TextCustom>Jumlah Transaksi</TextCustom>
|
|
||||||
|
|
||||||
<Spacing height={10} />
|
|
||||||
|
|
||||||
<BaseBox backgroundColor={MainColor.soft_darkblue}>
|
|
||||||
<Grid containerStyle={{ justifyContent: "center" }}>
|
|
||||||
<Grid.Col
|
|
||||||
span={8}
|
|
||||||
style={{
|
|
||||||
justifyContent: "center",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TextCustom size="xlarge" bold color="yellow">
|
|
||||||
Rp. 1.000.000
|
|
||||||
</TextCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col
|
|
||||||
span={4}
|
|
||||||
style={{
|
|
||||||
alignItems: "flex-end",
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<ButtonCustom>Salin</ButtonCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
</Grid>
|
|
||||||
</BaseBox>
|
|
||||||
</StackCustom>
|
|
||||||
</BaseBox>
|
|
||||||
|
|
||||||
<BaseBox>
|
|
||||||
<StackCustom>
|
|
||||||
<TextCustom>Upload bukti transfer anda.</TextCustom>
|
|
||||||
<ButtonCenteredOnly
|
|
||||||
onPress={() => {
|
|
||||||
router.push("/(application)/(image)/take-picture/123");
|
|
||||||
}}
|
|
||||||
icon="upload"
|
|
||||||
>
|
|
||||||
Upload
|
|
||||||
</ButtonCenteredOnly>
|
|
||||||
</StackCustom>
|
|
||||||
</BaseBox>
|
|
||||||
|
|
||||||
<ButtonCustom
|
|
||||||
onPress={() => {
|
|
||||||
router.push(`/donation/${id}/(transaction-flow)/process`);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Saya Sudah Transfer
|
|
||||||
</ButtonCustom>
|
|
||||||
</StackCustom>
|
|
||||||
<Spacing />
|
|
||||||
</ViewWrapper>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -9,15 +9,43 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
||||||
|
import { LOCAL_STORAGE_KEY } from "@/constants/local-storage-key";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useState } from "react";
|
||||||
|
|
||||||
export default function InvestmentInputDonation() {
|
export default function InvestmentInputDonation() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
const [nominal, setNominal] = useState<number>(0);
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
await AsyncStorage.setItem(
|
||||||
|
LOCAL_STORAGE_KEY.transactionDonation,
|
||||||
|
JSON.stringify({ nominal: nominal.toString() })
|
||||||
|
);
|
||||||
|
router.replace(`/donation/${id}/select-bank`);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const displayJumlah = formatCurrencyDisplay(nominal);
|
||||||
|
|
||||||
|
const handleChangeCurrency = (text: string) => {
|
||||||
|
const numeric = text.replace(/\D/g, "");
|
||||||
|
setNominal(Number(numeric));
|
||||||
|
};
|
||||||
|
|
||||||
const bottomComponent = (
|
const bottomComponent = (
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
onPress={() => router.replace(`/donation/${id}/select-bank`)}
|
disabled={nominal < 10000 || nominal === 0}
|
||||||
|
onPress={() => {
|
||||||
|
handlerSubmit();
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Lanjutan
|
Lanjutan
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
@@ -27,7 +55,7 @@ export default function InvestmentInputDonation() {
|
|||||||
<>
|
<>
|
||||||
<ViewWrapper footerComponent={bottomComponent}>
|
<ViewWrapper footerComponent={bottomComponent}>
|
||||||
{listData.map((item, i) => (
|
{listData.map((item, i) => (
|
||||||
<BaseBox key={i}>
|
<BaseBox key={i} onPress={() => setNominal(item.value)}>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={8}>
|
<Grid.Col span={8}>
|
||||||
<TextCustom bold size="large">
|
<TextCustom bold size="large">
|
||||||
@@ -48,9 +76,12 @@ export default function InvestmentInputDonation() {
|
|||||||
|
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<TextInputCustom
|
<TextInputCustom
|
||||||
|
keyboardType="numeric"
|
||||||
label="Nominal lainnya"
|
label="Nominal lainnya"
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
iconLeft="Rp."
|
iconLeft="Rp."
|
||||||
|
value={displayJumlah}
|
||||||
|
onChangeText={(value) => handleChangeCurrency(value)}
|
||||||
/>
|
/>
|
||||||
<TextCustom size="small" color="gray">
|
<TextCustom size="small" color="gray">
|
||||||
Minimal donasi Rp. 10.000
|
Minimal donasi Rp. 10.000
|
||||||
|
|||||||
@@ -5,24 +5,84 @@ import {
|
|||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { RadioCustom, RadioGroup } from "@/components/Radio/RadioCustom";
|
import { RadioCustom, RadioGroup } from "@/components/Radio/RadioCustom";
|
||||||
import { dummyMasterBank } from "@/lib/dummy-data/_master/bank";
|
import { LOCAL_STORAGE_KEY } from "@/constants/local-storage-key";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import { apiDonationCreateInvoice } from "@/service/api-client/api-donation";
|
||||||
|
import { apiMasterBank } from "@/service/api-client/api-master";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
import { useState } from "react";
|
import _ from "lodash";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
export default function DonationSelectBank() {
|
export default function DonationSelectBank() {
|
||||||
const { id, transaction } = useLocalSearchParams();
|
const { user } = useAuth();
|
||||||
const [value, setValue] = useState<any | number>("");
|
const { id } = useLocalSearchParams();
|
||||||
|
const [select, setSelect] = useState<any | number>("");
|
||||||
|
const [listBank, setListBank] = useState<any>([]);
|
||||||
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadListBank();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const loadListBank = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiMasterBank();
|
||||||
|
|
||||||
|
setListBank(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setListBank([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
const dataStorage = await AsyncStorage.getItem(
|
||||||
|
LOCAL_STORAGE_KEY.transactionDonation
|
||||||
|
);
|
||||||
|
|
||||||
|
if (dataStorage) {
|
||||||
|
const storage = JSON.parse(dataStorage);
|
||||||
|
const newData = {
|
||||||
|
...storage,
|
||||||
|
bankId: select,
|
||||||
|
authorId: user?.id,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await apiDonationCreateInvoice({
|
||||||
|
id: id as string,
|
||||||
|
data: newData,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
const invoiceId = response.data.id;
|
||||||
|
|
||||||
|
await AsyncStorage.removeItem(LOCAL_STORAGE_KEY.transactionDonation);
|
||||||
|
|
||||||
|
router.replace(
|
||||||
|
`/(application)/(user)/donation/[id]/(transaction-flow)/${invoiceId}/invoice`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log("[FAILED]", response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const buttonSubmit = () => {
|
const buttonSubmit = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
onPress={() =>
|
isLoading={isLoading}
|
||||||
router.replace(
|
disabled={!select}
|
||||||
`/(application)/(user)/donation/${id}/(transaction-flow)/${transaction}/invoice`
|
onPress={() => handlerSubmit()}
|
||||||
)
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
Pilih
|
Pilih
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
@@ -32,12 +92,14 @@ export default function DonationSelectBank() {
|
|||||||
};
|
};
|
||||||
return (
|
return (
|
||||||
<ViewWrapper footerComponent={buttonSubmit()}>
|
<ViewWrapper footerComponent={buttonSubmit()}>
|
||||||
<RadioGroup value={value} onChange={setValue}>
|
<RadioGroup value={select} onChange={setSelect}>
|
||||||
{dummyMasterBank.map((item) => (
|
{_.isEmpty(listBank)
|
||||||
<BaseBox key={item.name}>
|
? []
|
||||||
<RadioCustom label={item.name} value={item.code} />
|
: listBank?.map((item: any, index: number) => (
|
||||||
</BaseBox>
|
<BaseBox key={index}>
|
||||||
))}
|
<RadioCustom label={item.namaBank} value={item.id} />
|
||||||
|
</BaseBox>
|
||||||
|
))}
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</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>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,80 @@
|
|||||||
import { ViewWrapper, StackCustom, InformationBox, TextInputCustom, Spacing, ButtonCustom } from "@/components";
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import { router } from "expo-router";
|
import {
|
||||||
|
ViewWrapper,
|
||||||
|
StackCustom,
|
||||||
|
InformationBox,
|
||||||
|
TextInputCustom,
|
||||||
|
Spacing,
|
||||||
|
ButtonCustom,
|
||||||
|
} from "@/components";
|
||||||
|
import {
|
||||||
|
apiDonationGetOne,
|
||||||
|
apiDonationUpdateData,
|
||||||
|
} from "@/service/api-client/api-donation";
|
||||||
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function DonationEditRekening() {
|
export default function DonationEditRekening() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState({
|
||||||
|
namaBank: "",
|
||||||
|
rekening: "",
|
||||||
|
});
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id]);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiDonationGetOne({
|
||||||
|
id: id as string,
|
||||||
|
category: "permanent",
|
||||||
|
});
|
||||||
|
|
||||||
|
const resData = response.data;
|
||||||
|
console.log("[RESPONSE]", JSON.stringify(resData, null, 2));
|
||||||
|
|
||||||
|
setData({
|
||||||
|
namaBank: resData.namaBank,
|
||||||
|
rekening: resData.rekening,
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmitUpdate = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
|
const response = await apiDonationUpdateData({
|
||||||
|
id: id as string,
|
||||||
|
data: data,
|
||||||
|
category: "edit-bank-account",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengupdate data bank",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Data bank berhasil diupdate",
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
@@ -10,17 +83,22 @@ export default function DonationEditRekening() {
|
|||||||
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
|
||||||
|
value={data.rekening}
|
||||||
|
onChangeText={(value) => setData({ ...data, rekening: value })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Spacing />
|
<Spacing />
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.back();
|
handlerSubmitUpdate();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Update
|
Update
|
||||||
@@ -29,4 +107,4 @@ export default function DonationEditRekening() {
|
|||||||
<Spacing />
|
<Spacing />
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,97 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ButtonCenteredOnly,
|
ButtonCenteredOnly,
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
InformationBox,
|
InformationBox,
|
||||||
LandscapeFrameUploaded,
|
LandscapeFrameUploaded,
|
||||||
Spacing,
|
Spacing,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextAreaCustom,
|
TextAreaCustom,
|
||||||
ViewWrapper
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { router } from "expo-router";
|
import API_IMAGE from "@/constants/api-storage";
|
||||||
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
|
import {
|
||||||
|
apiDonationGetOne,
|
||||||
|
apiDonationUpdateData,
|
||||||
|
} from "@/service/api-client/api-donation";
|
||||||
|
import { uploadFileService } from "@/service/upload-service";
|
||||||
|
import pickFile from "@/utils/pickFile";
|
||||||
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function DonationEditStory() {
|
export default function DonationEditStory() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState<any>();
|
||||||
|
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: "permanent",
|
||||||
|
});
|
||||||
|
|
||||||
|
setData(response.data.CeritaDonasi);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmitUpdate = async () => {
|
||||||
|
let newData;
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
|
newData = {
|
||||||
|
...data,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (imageStory) {
|
||||||
|
const responseUploadImageDonasi = await uploadFileService({
|
||||||
|
imageUri: imageStory,
|
||||||
|
dirId: DIRECTORY_ID.donasi_cerita_image,
|
||||||
|
});
|
||||||
|
|
||||||
|
newData = {
|
||||||
|
...data,
|
||||||
|
newImageId: responseUploadImageDonasi.data.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await apiDonationUpdateData({
|
||||||
|
id: id as string,
|
||||||
|
data: newData,
|
||||||
|
category: "edit-story",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[RESPONSE]", JSON.stringify(response, null, 2));
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal membuat donasi",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Donasi berhasil disimpan",
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
@@ -21,12 +102,23 @@ export default function DonationEditStory() {
|
|||||||
required
|
required
|
||||||
showCount
|
showCount
|
||||||
maxLength={1000}
|
maxLength={1000}
|
||||||
|
value={data?.pembukaan}
|
||||||
|
onChangeText={(value) => setData({ ...data, pembukaan: value })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<LandscapeFrameUploaded />
|
<LandscapeFrameUploaded
|
||||||
|
image={
|
||||||
|
imageStory ? imageStory : API_IMAGE.GET({ fileId: data?.imageId })
|
||||||
|
}
|
||||||
|
/>
|
||||||
<ButtonCenteredOnly
|
<ButtonCenteredOnly
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.push("/(application)/(image)/take-picture/123");
|
pickFile({
|
||||||
|
allowedType: "image",
|
||||||
|
setImageUri: ({ uri }) => {
|
||||||
|
setImageStory(uri);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
icon="upload"
|
icon="upload"
|
||||||
>
|
>
|
||||||
@@ -39,12 +131,15 @@ export default function DonationEditStory() {
|
|||||||
required
|
required
|
||||||
showCount
|
showCount
|
||||||
maxLength={1000}
|
maxLength={1000}
|
||||||
|
value={data?.cerita}
|
||||||
|
onChangeText={(value) => setData({ ...data, cerita: value })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Spacing height={40} />
|
<Spacing height={40} />
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.back();
|
handlerSubmitUpdate();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Update
|
Update
|
||||||
|
|||||||
@@ -1,78 +1,275 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ButtonCenteredOnly,
|
ButtonCenteredOnly,
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
InformationBox,
|
InformationBox,
|
||||||
LandscapeFrameUploaded,
|
LandscapeFrameUploaded,
|
||||||
SelectCustom,
|
LoaderCustom,
|
||||||
Spacing,
|
SelectCustom,
|
||||||
StackCustom,
|
Spacing,
|
||||||
TextInputCustom,
|
StackCustom,
|
||||||
ViewWrapper,
|
TextInputCustom,
|
||||||
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { dummyDonasiDurasi } from "@/lib/dummy-data/donasi/durasi";
|
import API_IMAGE from "@/constants/api-storage";
|
||||||
import { dummyDonasiKategori } from "@/lib/dummy-data/donasi/kategori";
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
import { router } from "expo-router";
|
import {
|
||||||
|
apiDonationGetOne,
|
||||||
|
apiDonationUpdateData,
|
||||||
|
} 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, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
|
interface IEditDonation {
|
||||||
|
donasiMaster_KategoriId: string;
|
||||||
|
donasiMaster_DurasiId: string;
|
||||||
|
title: string;
|
||||||
|
target: string;
|
||||||
|
imageId: string;
|
||||||
|
}
|
||||||
|
|
||||||
export default function DonationEdit() {
|
export default function DonationEdit() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState<IEditDonation>({
|
||||||
|
donasiMaster_DurasiId: "",
|
||||||
|
donasiMaster_KategoriId: "",
|
||||||
|
title: "",
|
||||||
|
target: "",
|
||||||
|
imageId: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
const [image, setImage] = useState<string | null>(null);
|
||||||
|
const [listCategory, setListCategory] = useState<any[]>([]);
|
||||||
|
const [listDuration, setListDuration] = useState<any[]>([]);
|
||||||
|
const [loadList, setLoadList] = useState<boolean>(false);
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const displayTarget = formatCurrencyDisplay(data?.target);
|
||||||
|
const handleChangeCurrency = (field: keyof typeof data) => (text: string) => {
|
||||||
|
const numeric = text.replace(/\D/g, "");
|
||||||
|
setData((prev: any) => ({ ...prev, [field]: numeric }));
|
||||||
|
};
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
onLoadList();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiDonationGetOne({
|
||||||
|
id: id as string,
|
||||||
|
category: "permanent",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData({
|
||||||
|
donasiMaster_DurasiId: response.data.donasiMaster_DurasiId,
|
||||||
|
donasiMaster_KategoriId: response.data.donasiMaster_KategoriId,
|
||||||
|
title: response.data.title,
|
||||||
|
target: response.data.target,
|
||||||
|
imageId: response.data.imageId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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 = async () => {
|
||||||
|
if (
|
||||||
|
!data.donasiMaster_DurasiId ||
|
||||||
|
!data.donasiMaster_KategoriId ||
|
||||||
|
!data.title ||
|
||||||
|
!data.target ||
|
||||||
|
!data.imageId
|
||||||
|
) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Harap lengkapi data",
|
||||||
|
});
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmitUpdate = async () => {
|
||||||
|
const isValid = await validateData();
|
||||||
|
if (!isValid) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
let newData;
|
||||||
|
|
||||||
|
newData = {
|
||||||
|
...data,
|
||||||
|
};
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
|
if (image && image) {
|
||||||
|
const uploadNewImage = await uploadFileService({
|
||||||
|
dirId: DIRECTORY_ID.donasi_image,
|
||||||
|
imageUri: image,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!uploadFileService) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengunggah gambar",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
newData = {
|
||||||
|
...data,
|
||||||
|
newImageId: uploadNewImage.data.id,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await apiDonationUpdateData({
|
||||||
|
id: id as string,
|
||||||
|
data: newData,
|
||||||
|
category: "edit-donation",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: response.message,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Donasi berhasil diperbarui",
|
||||||
|
});
|
||||||
|
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR UPDATE DONASI]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<StackCustom gap={"xs"}>
|
<InformationBox text="Lengkapi semua data di bawah untuk selanjutnya mengisi cerita penggalangan dana." />
|
||||||
<InformationBox text="Lengkapi semua data di bawah untuk selanjutnya mengisi cerita penggalangan dana." />
|
{!data || loadList ? (
|
||||||
|
<LoaderCustom />
|
||||||
|
) : (
|
||||||
|
<StackCustom gap={"xs"}>
|
||||||
|
<TextInputCustom
|
||||||
|
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")}
|
||||||
|
/>
|
||||||
|
|
||||||
<TextInputCustom
|
<LandscapeFrameUploaded
|
||||||
label="Judul Donasi"
|
image={image ? image : API_IMAGE.GET({ fileId: data?.imageId })}
|
||||||
placeholder="Masukkan Judul Donasi"
|
/>
|
||||||
required
|
<ButtonCenteredOnly
|
||||||
/>
|
onPress={() => {
|
||||||
<TextInputCustom
|
pickFile({
|
||||||
label="Target Donasi"
|
setImageUri: ({ uri }) => {
|
||||||
placeholder="Masukkan Target Donasi"
|
setImage(uri);
|
||||||
required
|
},
|
||||||
keyboardType="numeric"
|
allowedType: "image",
|
||||||
/>
|
});
|
||||||
|
}}
|
||||||
|
icon="upload"
|
||||||
|
>
|
||||||
|
Upload
|
||||||
|
</ButtonCenteredOnly>
|
||||||
|
<Spacing />
|
||||||
|
|
||||||
<LandscapeFrameUploaded />
|
<SelectCustom
|
||||||
<ButtonCenteredOnly
|
data={
|
||||||
onPress={() => {
|
_.isEmpty(listCategory)
|
||||||
router.push("/(application)/(image)/take-picture/123");
|
? []
|
||||||
}}
|
: listCategory?.map((item) => ({
|
||||||
icon="upload"
|
label: item.name,
|
||||||
>
|
value: item.id,
|
||||||
Upload
|
}))
|
||||||
</ButtonCenteredOnly>
|
}
|
||||||
<Spacing />
|
label="Pilih Kategori Donasi"
|
||||||
|
placeholder="Pilih Kategori Donasi"
|
||||||
|
required
|
||||||
|
value={data?.donasiMaster_KategoriId}
|
||||||
|
onChange={(value: any) =>
|
||||||
|
setData({ ...data, donasiMaster_KategoriId: value })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
<SelectCustom
|
<SelectCustom
|
||||||
data={dummyDonasiKategori.map((item) => ({
|
data={
|
||||||
label: item.label,
|
_.isEmpty(listDuration)
|
||||||
value: item.value,
|
? []
|
||||||
}))}
|
: listDuration?.map((item) => ({
|
||||||
onChange={(value) => console.log(value)}
|
label: item.name + " hari",
|
||||||
label="Pilih Kategori Donasi"
|
value: item.id,
|
||||||
placeholder="Pilih Kategori Donasi"
|
}))
|
||||||
required
|
}
|
||||||
/>
|
label="Pilih Durasi Donasi"
|
||||||
|
placeholder="Pilih Durasi Donasi"
|
||||||
|
required
|
||||||
|
value={data?.donasiMaster_DurasiId}
|
||||||
|
onChange={(value: any) =>
|
||||||
|
setData({ ...data, donasiMaster_DurasiId: value })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
<SelectCustom
|
<Spacing />
|
||||||
data={dummyDonasiDurasi.map((item) => ({
|
<ButtonCustom
|
||||||
label: item.label,
|
isLoading={isLoading}
|
||||||
value: item.value,
|
onPress={() => {
|
||||||
}))}
|
handlerSubmitUpdate();
|
||||||
onChange={(value) => console.log(value)}
|
}}
|
||||||
label="Pilih Durasi Donasi"
|
>
|
||||||
placeholder="Pilih Durasi Donasi"
|
Update
|
||||||
required
|
</ButtonCustom>
|
||||||
/>
|
</StackCustom>
|
||||||
|
)}
|
||||||
<Spacing />
|
|
||||||
<ButtonCustom
|
|
||||||
onPress={() => {
|
|
||||||
router.back();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Update
|
|
||||||
</ButtonCustom>
|
|
||||||
</StackCustom>
|
|
||||||
<Spacing />
|
<Spacing />
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BackButton,
|
BackButton,
|
||||||
BoxButtonOnFooter,
|
BoxButtonOnFooter,
|
||||||
@@ -9,24 +10,54 @@ import {
|
|||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconNews } from "@/components/_Icon";
|
import { IconNews } from "@/components/_Icon";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import Donation_ComponentBoxDetailData from "@/screens/Donation/ComponentBoxDetailData";
|
import Donation_ComponentBoxDetailData from "@/screens/Donation/ComponentBoxDetailData";
|
||||||
import Donation_ComponentInfoFundrising from "@/screens/Donation/ComponentInfoFundrising";
|
import Donation_ComponentInfoFundrising from "@/screens/Donation/ComponentInfoFundrising";
|
||||||
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 { router, Stack, useLocalSearchParams } from "expo-router";
|
import { apiDonationGetOne } from "@/service/api-client/api-donation";
|
||||||
import { useState } from "react";
|
import {
|
||||||
|
router,
|
||||||
|
Stack,
|
||||||
|
useFocusEffect,
|
||||||
|
useLocalSearchParams,
|
||||||
|
} from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function DonasiDetailBeranda() {
|
export default function DonasiDetailBeranda() {
|
||||||
|
const { user } = useAuth();
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
console.log("ID ", id);
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
const [openDrawer, setOpenDrawer] = 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",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[RES GET ONE]", JSON.stringify(response.data, null, 2));
|
||||||
|
|
||||||
|
setData(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const buttonSection = (
|
const buttonSection = (
|
||||||
<>
|
<>
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
onPress={() =>
|
onPress={() => router.navigate(`/donation/${id}/(transaction-flow)`)}
|
||||||
router.navigate(`/donation/${id}/(transaction-flow)`)
|
|
||||||
}
|
|
||||||
>
|
>
|
||||||
Donasi
|
Donasi
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
@@ -40,16 +71,23 @@ export default function DonasiDetailBeranda() {
|
|||||||
options={{
|
options={{
|
||||||
title: `Detail Donasi`,
|
title: `Detail Donasi`,
|
||||||
headerLeft: () => <BackButton />,
|
headerLeft: () => <BackButton />,
|
||||||
headerRight: () => <DotButton onPress={() => setOpenDrawer(true)} />,
|
headerRight: () =>
|
||||||
|
user?.id === data?.Author?.id ? (
|
||||||
|
<DotButton onPress={() => setOpenDrawer(true)} />
|
||||||
|
) : null,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ViewWrapper footerComponent={buttonSection}>
|
<ViewWrapper footerComponent={buttonSection}>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<Donation_ComponentBoxDetailData
|
<Donation_ComponentBoxDetailData
|
||||||
|
data={data}
|
||||||
bottomSection={<Donation_ProgressSection id={id as string} />}
|
bottomSection={<Donation_ProgressSection id={id as string} />}
|
||||||
/>
|
/>
|
||||||
<Donation_ComponentInfoFundrising id={id as string} />
|
<Donation_ComponentInfoFundrising dataAuthor={data?.Author} />
|
||||||
<Donation_ComponentStoryFunrising id={id as string} />
|
<Donation_ComponentStoryFunrising
|
||||||
|
id={id as string}
|
||||||
|
dataStory={data?.CeritaDonasi}
|
||||||
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
|
|||||||
@@ -1,32 +1,68 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AvatarCustom,
|
AvatarComp,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
CenterCustom,
|
|
||||||
Grid,
|
Grid,
|
||||||
|
LoaderCustom,
|
||||||
Spacing,
|
Spacing,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper
|
ViewWrapper
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import Donation_BoxPublish from "@/screens/Donation/BoxPublish";
|
import Donation_BoxPublish from "@/screens/Donation/BoxPublish";
|
||||||
import React from "react";
|
import { apiDonationFundrising } from "@/service/api-client/api-donation";
|
||||||
|
import { useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import React, { useCallback, useState } from "react";
|
||||||
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function DonationInformationFunrising() {
|
export default function DonationInformationFunrising() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState<any>();
|
||||||
|
const [list, setList] = useState<any[] | null>(null);
|
||||||
|
const [loadList, setLoadList] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadList(true);
|
||||||
|
const response = await apiDonationFundrising({ id: id as string });
|
||||||
|
|
||||||
|
setData(response?.data?.user);
|
||||||
|
setList(response?.data?.donasi);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={6} style={{ justifyContent: "center" }}>
|
<Grid.Col span={6} style={{ justifyContent: "center" }}>
|
||||||
<CenterCustom>
|
<View
|
||||||
<AvatarCustom size="lg" />
|
style={{
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "center",
|
||||||
|
gap: 10,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<AvatarComp size="lg" fileId={data?.Profile?.imageId} />
|
||||||
<TextCustom bold size="large" truncate>
|
<TextCustom bold size="large" truncate>
|
||||||
@Username
|
@{data?.username}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</CenterCustom>
|
</View>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={6} style={{ justifyContent: "center" }}>
|
<Grid.Col span={6} style={{ justifyContent: "center" }}>
|
||||||
<ButtonCustom href={`/profile/1234`}>
|
<ButtonCustom href={`/profile/${data?.Profile?.id}`}>
|
||||||
Kunjungi Profile
|
Kunjungi Profile
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
@@ -35,9 +71,15 @@ export default function DonationInformationFunrising() {
|
|||||||
|
|
||||||
<Spacing />
|
<Spacing />
|
||||||
|
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
{loadList ? (
|
||||||
<Donation_BoxPublish key={index} id={index.toString()} />
|
<LoaderCustom />
|
||||||
))}
|
) : _.isEmpty(list) ? (
|
||||||
|
<TextCustom align="center" color="gray" size="small">Belum ada data</TextCustom>
|
||||||
|
) : (
|
||||||
|
list?.map((item: any, index: number) => (
|
||||||
|
<Donation_BoxPublish key={index} id={item?.id} data={item} />
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
ButtonCenteredOnly,
|
ButtonCenteredOnly,
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
@@ -9,9 +10,107 @@ import {
|
|||||||
TextInputCustom,
|
TextInputCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} 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() {
|
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 (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
@@ -22,6 +121,8 @@ export default function DonationCreateStory() {
|
|||||||
required
|
required
|
||||||
showCount
|
showCount
|
||||||
maxLength={1000}
|
maxLength={1000}
|
||||||
|
value={data.pembukaan}
|
||||||
|
onChangeText={(value) => setData({ ...data, pembukaan: value })}
|
||||||
/>
|
/>
|
||||||
<TextAreaCustom
|
<TextAreaCustom
|
||||||
label="Tujuan Donasi"
|
label="Tujuan Donasi"
|
||||||
@@ -29,12 +130,19 @@ export default function DonationCreateStory() {
|
|||||||
required
|
required
|
||||||
showCount
|
showCount
|
||||||
maxLength={1000}
|
maxLength={1000}
|
||||||
|
value={data.cerita}
|
||||||
|
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"
|
||||||
>
|
>
|
||||||
@@ -47,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
|
||||||
|
|||||||
@@ -3,17 +3,127 @@ import {
|
|||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
InformationBox,
|
InformationBox,
|
||||||
LandscapeFrameUploaded,
|
LandscapeFrameUploaded,
|
||||||
|
LoaderCustom,
|
||||||
SelectCustom,
|
SelectCustom,
|
||||||
Spacing,
|
Spacing,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextInputCustom,
|
TextInputCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { dummyDonasiDurasi } from "@/lib/dummy-data/donasi/durasi";
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
import { dummyDonasiKategori } from "@/lib/dummy-data/donasi/kategori";
|
import { apiDonationCreate } from "@/service/api-client/api-donation";
|
||||||
import { router } from "expo-router";
|
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() {
|
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 (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
@@ -23,18 +133,28 @@ export default function DonationCreate() {
|
|||||||
label="Judul Donasi"
|
label="Judul Donasi"
|
||||||
placeholder="Masukkan Judul Donasi"
|
placeholder="Masukkan Judul Donasi"
|
||||||
required
|
required
|
||||||
|
value={data.title}
|
||||||
|
onChangeText={(value) => setData({ ...data, title: value })}
|
||||||
/>
|
/>
|
||||||
<TextInputCustom
|
<TextInputCustom
|
||||||
|
iconLeft="Rp."
|
||||||
label="Target Donasi"
|
label="Target Donasi"
|
||||||
placeholder="Masukkan Target Donasi"
|
placeholder="Masukkan Target Donasi"
|
||||||
required
|
required
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
|
value={displayTarget}
|
||||||
|
onChangeText={handleChangeCurrency("target")}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<LandscapeFrameUploaded />
|
<LandscapeFrameUploaded image={image || ""} />
|
||||||
<ButtonCenteredOnly
|
<ButtonCenteredOnly
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.push("/(application)/(image)/take-picture/123");
|
pickFile({
|
||||||
|
allowedType: "image",
|
||||||
|
setImageUri: ({ uri }) => {
|
||||||
|
setImage(uri);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
icon="upload"
|
icon="upload"
|
||||||
>
|
>
|
||||||
@@ -42,31 +162,52 @@ export default function DonationCreate() {
|
|||||||
</ButtonCenteredOnly>
|
</ButtonCenteredOnly>
|
||||||
<Spacing />
|
<Spacing />
|
||||||
|
|
||||||
<SelectCustom
|
{loadList ? (
|
||||||
data={dummyDonasiKategori.map((item) => ({
|
<LoaderCustom />
|
||||||
label: item.label,
|
) : (
|
||||||
value: item.value,
|
<SelectCustom
|
||||||
}))}
|
data={
|
||||||
onChange={(value) => console.log(value)}
|
_.isEmpty(listCategory)
|
||||||
label="Pilih Kategori Donasi"
|
? []
|
||||||
placeholder="Pilih Kategori Donasi"
|
: listCategory?.map((item: any) => ({
|
||||||
required
|
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 />
|
<Spacing />
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.replace("/donation/create-story");
|
handlerSubmit();
|
||||||
|
// router.push(`/donation/create-story?id=${"dasdsadsa"}`);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Selanjutnya
|
Selanjutnya
|
||||||
|
|||||||
@@ -1,81 +1,123 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BadgeCustom,
|
BadgeCustom,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
Grid,
|
Grid,
|
||||||
|
LoaderCustom,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { dummyMasterStatusTransaction } from "@/lib/dummy-data/_master/status-transaction";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import { apiInvestmentGetInvoice } from "@/service/api-client/api-investment";
|
||||||
import { GStyles } from "@/styles/global-styles";
|
import { GStyles } from "@/styles/global-styles";
|
||||||
import dayjs from "dayjs";
|
import { formatChatTime } from "@/utils/formatChatTime";
|
||||||
import { router } from "expo-router";
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
|
import { router, useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function InvestmentTransaction() {
|
export default function InvestmentTransaction() {
|
||||||
const randomStatusData = Array.from({ length: 10 }, () => {
|
const { user } = useAuth();
|
||||||
const randomIndex = Math.floor(
|
const [list, setList] = useState<any>([]);
|
||||||
Math.random() * dummyMasterStatusTransaction.length
|
const [loadList, setLoadList] = useState<boolean>(false);
|
||||||
);
|
|
||||||
return dummyMasterStatusTransaction[randomIndex];
|
|
||||||
});
|
|
||||||
|
|
||||||
const handlePress = (value: string) => {
|
useFocusEffect(
|
||||||
if (value === "menunggu") {
|
useCallback(() => {
|
||||||
router.push(`/investment/${value}/(transaction-flow)/invoice`);
|
onLoadList();
|
||||||
} else if (value === "proses") {
|
}, [user?.id])
|
||||||
router.push(`/investment/${value}/(transaction-flow)/process`);
|
);
|
||||||
} else if (value === "berhasil") {
|
|
||||||
router.push(`/investment/${value}/(transaction-flow)/success`);
|
const onLoadList = async () => {
|
||||||
} else if (value === "gagal") {
|
try {
|
||||||
router.push(`/investment/${value}/(transaction-flow)/failed`);
|
setLoadList(true);
|
||||||
|
const response = await apiInvestmentGetInvoice({
|
||||||
|
authorId: user?.id as string,
|
||||||
|
category: "transaction",
|
||||||
|
});
|
||||||
|
console.log("[RESPONSE LIST]", JSON.stringify(response.data, null, 2));
|
||||||
|
setList(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerColor = (status: string) => {
|
||||||
|
if (status === "menunggu") {
|
||||||
|
return "orange";
|
||||||
|
} else if (status === "proses") {
|
||||||
|
return "white";
|
||||||
|
} else if (status === "berhasil") {
|
||||||
|
return "green";
|
||||||
|
} else if (status === "gagal") {
|
||||||
|
return "red";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlePress = ({ id, status }: { id: string; status: string }) => {
|
||||||
|
if (status === "menunggu") {
|
||||||
|
router.push(`/investment/${id}/(transaction-flow)/invoice`);
|
||||||
|
} else if (status === "proses") {
|
||||||
|
router.push(`/investment/${id}/(transaction-flow)/process`);
|
||||||
|
} else if (status === "berhasil") {
|
||||||
|
router.push(`/investment/${id}/(transaction-flow)/success`);
|
||||||
|
} else if (status === "gagal") {
|
||||||
|
router.push(`/investment/${id}/(transaction-flow)/failed`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper hideFooter>
|
<ViewWrapper hideFooter>
|
||||||
{randomStatusData.map((item, i) => (
|
{loadList ? (
|
||||||
<BaseBox
|
<LoaderCustom />
|
||||||
key={i}
|
) : _.isEmpty(list) ? (
|
||||||
paddingTop={7}
|
<TextCustom>Tidak ada data</TextCustom>
|
||||||
paddingBottom={7}
|
) : (
|
||||||
onPress={() => {
|
list.map((item: any, i: number) => (
|
||||||
handlePress(item.value);
|
<BaseBox
|
||||||
}}
|
key={i}
|
||||||
>
|
paddingTop={7}
|
||||||
<Grid>
|
paddingBottom={7}
|
||||||
<Grid.Col span={6}>
|
onPress={() => {
|
||||||
<StackCustom gap={"xs"}>
|
handlePress({
|
||||||
<TextCustom truncate>
|
id: item.id,
|
||||||
Title Investment: Lorem ipsum dolor sit amet consectetur
|
status: _.lowerCase(item.statusInvoice),
|
||||||
adipisicing elit. Am culpa excepturi deleniti soluta animi
|
});
|
||||||
porro amet ducimus.
|
}}
|
||||||
</TextCustom>
|
>
|
||||||
<TextCustom color="gray" size="small">
|
<Grid>
|
||||||
{dayjs().format("DD/MM/YYYY")}
|
<Grid.Col span={6}>
|
||||||
</TextCustom>
|
<StackCustom gap={"xs"}>
|
||||||
</StackCustom>
|
<TextCustom truncate>{item?.title || "-"}</TextCustom>
|
||||||
</Grid.Col>
|
<TextCustom color="gray" size="small">
|
||||||
<Grid.Col span={1}>
|
{formatChatTime(item?.createdAt)}
|
||||||
<View />
|
</TextCustom>
|
||||||
</Grid.Col>
|
</StackCustom>
|
||||||
<Grid.Col span={5} style={{ alignItems: "flex-end" }}>
|
</Grid.Col>
|
||||||
<StackCustom gap={"xs"}>
|
<Grid.Col span={1}>
|
||||||
<TextCustom bold truncate>
|
<View />
|
||||||
Rp. 7.500.000
|
</Grid.Col>
|
||||||
</TextCustom>
|
<Grid.Col span={5} style={{ alignItems: "flex-end" }}>
|
||||||
<BadgeCustom
|
<StackCustom gap={"xs"}>
|
||||||
variant="light"
|
<TextCustom bold truncate>
|
||||||
color={item.color}
|
Rp. {formatCurrencyDisplay(item?.nominal) || "-"}
|
||||||
style={GStyles.alignSelfFlexEnd}
|
</TextCustom>
|
||||||
>
|
<BadgeCustom
|
||||||
{item.label}
|
variant="light"
|
||||||
</BadgeCustom>
|
color={handlerColor(_.lowerCase(item.statusInvoice))}
|
||||||
</StackCustom>
|
style={GStyles.alignSelfFlexEnd}
|
||||||
</Grid.Col>
|
>
|
||||||
</Grid>
|
{item?.statusInvoice || "-"}
|
||||||
</BaseBox>
|
</BadgeCustom>
|
||||||
))}
|
</StackCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
AlertDefaultSystem,
|
AlertDefaultSystem,
|
||||||
BackButton,
|
BackButton,
|
||||||
@@ -8,37 +9,71 @@ import {
|
|||||||
MenuDrawerDynamicGrid,
|
MenuDrawerDynamicGrid,
|
||||||
StackCustom,
|
StackCustom,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconTrash } from "@/components/_Icon/IconTrash";
|
import { IconTrash } from "@/components/_Icon/IconTrash";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import { useState } from "react";
|
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() {
|
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 [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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
options={{
|
options={{
|
||||||
title: "Detail Berita",
|
title: "Detail Berita",
|
||||||
headerLeft: () => <BackButton />,
|
headerLeft: () => <BackButton />,
|
||||||
headerRight: () => <DotButton onPress={() => setOpenDrawer(true)} />,
|
headerRight: () =>
|
||||||
|
user?.id === data?.authorId && (
|
||||||
|
<DotButton onPress={() => setOpenDrawer(true)} />
|
||||||
|
),
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<DummyLandscapeImage />
|
{data && data?.imageId && (
|
||||||
|
<DummyLandscapeImage imageId={data?.imageId || ""} />
|
||||||
|
)}
|
||||||
<TextCustom bold align="center" size="large">
|
<TextCustom bold align="center" size="large">
|
||||||
Judul Berita {news} Terbaru
|
{(data && data?.title) || "-"}
|
||||||
</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!
|
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
|
<TextCustom>{(data && data?.deskripsi) || "-"}</TextCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
@@ -52,7 +87,7 @@ export default function InvestmentNews() {
|
|||||||
data={[
|
data={[
|
||||||
{
|
{
|
||||||
label: "Hapus Berita",
|
label: "Hapus Berita",
|
||||||
path: `/investment/${id}/add-news`,
|
path: ``,
|
||||||
icon: <IconTrash />,
|
icon: <IconTrash />,
|
||||||
color: "red",
|
color: "red",
|
||||||
},
|
},
|
||||||
@@ -63,9 +98,26 @@ export default function InvestmentNews() {
|
|||||||
message: "Apakah Anda yakin ingin menghapus berita ini?",
|
message: "Apakah Anda yakin ingin menghapus berita ini?",
|
||||||
textLeft: "Batal",
|
textLeft: "Batal",
|
||||||
textRight: "Hapus",
|
textRight: "Hapus",
|
||||||
onPressRight: () => {
|
onPressRight: async () => {
|
||||||
router.back();
|
try {
|
||||||
setOpenDrawer(false);
|
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);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -9,17 +9,89 @@ import {
|
|||||||
TextInputCustom,
|
TextInputCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} 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() {
|
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 (
|
return (
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
<InformationBox text="Pengunggahan foto ke aplikasi bersifat opsional dan tidak diwajibkan, Anda dapat menyimpan berita tanpa mengunggah foto." />
|
<InformationBox text="Pengunggahan foto ke aplikasi bersifat opsional dan tidak diwajibkan, Anda dapat menyimpan berita tanpa mengunggah foto." />
|
||||||
<LandscapeFrameUploaded />
|
<LandscapeFrameUploaded image={image?.uri} />
|
||||||
<ButtonCenteredOnly
|
<ButtonCenteredOnly
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.push("/(application)/(image)/take-picture/123");
|
pickFile({
|
||||||
|
allowedType: "image",
|
||||||
|
setImageUri(file) {
|
||||||
|
setImage(file);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
icon="upload"
|
icon="upload"
|
||||||
>
|
>
|
||||||
@@ -30,6 +102,8 @@ export default function InvestmentAddNews() {
|
|||||||
label="Judul Berita"
|
label="Judul Berita"
|
||||||
placeholder="Masukan judul berita"
|
placeholder="Masukan judul berita"
|
||||||
required
|
required
|
||||||
|
value={data.title}
|
||||||
|
onChangeText={(value) => setData({ ...data, title: value })}
|
||||||
/>
|
/>
|
||||||
<TextAreaCustom
|
<TextAreaCustom
|
||||||
label="Deskripsi Berita"
|
label="Deskripsi Berita"
|
||||||
@@ -37,13 +111,11 @@ export default function InvestmentAddNews() {
|
|||||||
required
|
required
|
||||||
showCount
|
showCount
|
||||||
maxLength={1000}
|
maxLength={1000}
|
||||||
|
value={data.deskripsi}
|
||||||
|
onChangeText={(value) => setData({ ...data, deskripsi: value })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ButtonCustom
|
<ButtonCustom isLoading={isLoading} onPress={handlerSubmit}>
|
||||||
onPress={() => {
|
|
||||||
router.back();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
Simpan
|
Simpan
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
|
|||||||
@@ -1,18 +1,51 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BackButton,
|
BackButton,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
MenuDrawerDynamicGrid,
|
LoaderCustom,
|
||||||
TextCustom,
|
MenuDrawerDynamicGrid,
|
||||||
ViewWrapper
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconPlus } from "@/components/_Icon";
|
import { IconPlus } from "@/components/_Icon";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import { apiInvestmentGetNews } from "@/service/api-client/api-investment";
|
||||||
import { useState } from "react";
|
import {
|
||||||
|
router,
|
||||||
|
Stack,
|
||||||
|
useFocusEffect,
|
||||||
|
useLocalSearchParams,
|
||||||
|
} from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function InvestmentListOfNews() {
|
export default function InvestmentListOfNews() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
@@ -22,16 +55,25 @@ export default function InvestmentListOfNews() {
|
|||||||
// headerRight: () => <DotButton onPress={() => setOpenDrawer(true)} />,
|
// headerRight: () => <DotButton onPress={() => setOpenDrawer(true)} />,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
{Array.from({ length: 15 }).map((_, index) => (
|
{loadList ? (
|
||||||
<BaseBox
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(list) ? (
|
||||||
paddingBlock={5}
|
<TextCustom align="center" color="gray">
|
||||||
href={`/investment/${id}/(news)/${index + 1}`}
|
Tidak ada data
|
||||||
>
|
</TextCustom>
|
||||||
<TextCustom bold>Berita Terbaru {index + 1}</TextCustom>
|
) : (
|
||||||
</BaseBox>
|
list?.map((item: any, index: number) => (
|
||||||
))}
|
<BaseBox
|
||||||
|
key={index}
|
||||||
|
paddingBlock={5}
|
||||||
|
href={`/investment/[id]/(news)/${item.id}`}
|
||||||
|
>
|
||||||
|
<TextCustom bold>{item.title}</TextCustom>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
<DrawerCustom
|
<DrawerCustom
|
||||||
|
|||||||
@@ -1,19 +1,53 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BackButton,
|
BackButton,
|
||||||
BaseBox,
|
BaseBox,
|
||||||
DotButton,
|
DotButton,
|
||||||
DrawerCustom,
|
DrawerCustom,
|
||||||
|
LoaderCustom,
|
||||||
MenuDrawerDynamicGrid,
|
MenuDrawerDynamicGrid,
|
||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { IconPlus } from "@/components/_Icon";
|
import { IconPlus } from "@/components/_Icon";
|
||||||
import { router, Stack, useLocalSearchParams } from "expo-router";
|
import { apiInvestmentGetNews } from "@/service/api-client/api-investment";
|
||||||
import { useState } from "react";
|
import {
|
||||||
|
router,
|
||||||
|
Stack,
|
||||||
|
useFocusEffect,
|
||||||
|
useLocalSearchParams,
|
||||||
|
} from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
export default function InvestmentRecapOfNews() {
|
export default function InvestmentRecapOfNews() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [openDrawer, setOpenDrawer] = useState(false);
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
@@ -24,15 +58,23 @@ export default function InvestmentRecapOfNews() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
{Array.from({ length: 15 }).map((_, index) => (
|
{loadList ? (
|
||||||
<BaseBox
|
<LoaderCustom />
|
||||||
key={index}
|
) : _.isEmpty(list) ? (
|
||||||
paddingBlock={5}
|
<TextCustom align="center" color="gray">
|
||||||
href={`/investment/${id}/(news)/${index + 1}`}
|
Tidak ada data
|
||||||
>
|
</TextCustom>
|
||||||
<TextCustom bold>Berita Terbaru {index + 1}</TextCustom>
|
) : (
|
||||||
</BaseBox>
|
list?.map((item: any, index: number) => (
|
||||||
))}
|
<BaseBox
|
||||||
|
key={index}
|
||||||
|
paddingBlock={5}
|
||||||
|
href={`/investment/[id]/(news)/${item.id}`}
|
||||||
|
>
|
||||||
|
<TextCustom bold>{item.title}</TextCustom>
|
||||||
|
</BaseBox>
|
||||||
|
))
|
||||||
|
)}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
|
|
||||||
<DrawerCustom
|
<DrawerCustom
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ import {
|
|||||||
TextInputCustom,
|
TextInputCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import { LOCAL_STORAGE_KEY } from "@/constants/local-storage-key";
|
||||||
import { apiInvestmentGetOne } from "@/service/api-client/api-investment";
|
import { apiInvestmentGetOne } from "@/service/api-client/api-investment";
|
||||||
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
@@ -19,9 +21,10 @@ export default function InvestmentInvest() {
|
|||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
// console.log("[ID]", id);
|
// console.log("[ID]", id);
|
||||||
const [data, setData] = useState<any>(null);
|
const [data, setData] = useState<any>(null);
|
||||||
const [value, setValue] = useState<number>(0);
|
const [jumlah, setJumlah] = useState<number>(0);
|
||||||
const [total, setTotal] = useState<number>(0);
|
const [total, setTotal] = useState<number>(0);
|
||||||
const [sisaLembar, setSisaLembar] = useState<number>(0);
|
const [sisaLembar, setSisaLembar] = useState<number>(0);
|
||||||
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
useCallback(() => {
|
useCallback(() => {
|
||||||
@@ -45,7 +48,7 @@ export default function InvestmentInvest() {
|
|||||||
const handleTextChange = (text: string) => {
|
const handleTextChange = (text: string) => {
|
||||||
// Izinkan input kosong → anggap sebagai 0 (atau abaikan, tergantung UX)
|
// Izinkan input kosong → anggap sebagai 0 (atau abaikan, tergantung UX)
|
||||||
if (text === "") {
|
if (text === "") {
|
||||||
setValue(0);
|
setJumlah(0);
|
||||||
setTotal(0);
|
setTotal(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -58,7 +61,7 @@ export default function InvestmentInvest() {
|
|||||||
// Karena regex sudah pastikan hanya angka, isNaN biasanya false
|
// Karena regex sudah pastikan hanya angka, isNaN biasanya false
|
||||||
// Tapi tetap aman untuk cek
|
// Tapi tetap aman untuk cek
|
||||||
if (!isNaN(numValue)) {
|
if (!isNaN(numValue)) {
|
||||||
setValue(numValue);
|
setJumlah(numValue);
|
||||||
setTotal(numValue * Number(data?.hargaLembar));
|
setTotal(numValue * Number(data?.hargaLembar));
|
||||||
console.log("[VALUE]", numValue);
|
console.log("[VALUE]", numValue);
|
||||||
}
|
}
|
||||||
@@ -71,10 +74,24 @@ export default function InvestmentInvest() {
|
|||||||
<>
|
<>
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
disabled={value < 10 || value >= sisaLembar}
|
isLoading={isLoading}
|
||||||
onPress={() => router.push(`/investment/${id}/select-bank`)}
|
disabled={jumlah < 10 || jumlah > sisaLembar}
|
||||||
|
onPress={async () => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
await AsyncStorage.setItem(
|
||||||
|
LOCAL_STORAGE_KEY.transactionInvestment,
|
||||||
|
JSON.stringify({ jumlah, total })
|
||||||
|
);
|
||||||
|
router.push(`/investment/${id}/select-bank`);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
Beli {value}, {sisaLembar}
|
Beli
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
</BoxButtonOnFooter>
|
</BoxButtonOnFooter>
|
||||||
</>
|
</>
|
||||||
@@ -126,7 +143,7 @@ export default function InvestmentInvest() {
|
|||||||
}}
|
}}
|
||||||
placeholder="0"
|
placeholder="0"
|
||||||
keyboardType="numeric"
|
keyboardType="numeric"
|
||||||
value={value.toString()}
|
value={jumlah.toString()}
|
||||||
onChangeText={(value) => {
|
onChangeText={(value) => {
|
||||||
handleTextChange(value);
|
handleTextChange(value);
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BaseBox,
|
BaseBox,
|
||||||
ButtonCenteredOnly,
|
ButtonCenteredOnly,
|
||||||
@@ -9,11 +10,96 @@ import {
|
|||||||
TextCustom,
|
TextCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import CopyButton from "@/components/Button/CoyButton";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
|
import {
|
||||||
|
apiInvestmentGetInvoice,
|
||||||
|
apiInvestmentUpdateInvoice,
|
||||||
|
} from "@/service/api-client/api-investment";
|
||||||
|
import { uploadFileService } from "@/service/upload-service";
|
||||||
|
import { formatCurrencyDisplay } from "@/utils/formatCurrencyDisplay";
|
||||||
|
import pickFile, { IFileData } from "@/utils/pickFile";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import { View } from "react-native";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function InvestmentInvoice() {
|
export default function InvestmentInvoice() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
console.log("[ID]", id);
|
||||||
|
const [data, setData] = useState<any>({});
|
||||||
|
const [image, setImage] = useState<IFileData>({
|
||||||
|
name: "",
|
||||||
|
uri: "",
|
||||||
|
size: 0,
|
||||||
|
});
|
||||||
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiInvestmentGetInvoice({
|
||||||
|
id: id as string,
|
||||||
|
category: "invoice",
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[RES INVOICE]", JSON.stringify(response.data, null, 2));
|
||||||
|
setData(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmitUpdate = async () => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
const responseUploadImage = await uploadFileService({
|
||||||
|
dirId: DIRECTORY_ID.investasi_bukti_transfer,
|
||||||
|
imageUri: image?.uri,
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log("[RESPONSE UPLOAD IMAGE]", responseUploadImage);
|
||||||
|
|
||||||
|
if (!responseUploadImage?.data?.id) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengunggah bukti transfer",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await apiInvestmentUpdateInvoice({
|
||||||
|
id: id as string,
|
||||||
|
data: {
|
||||||
|
imageId: responseUploadImage?.data?.id,
|
||||||
|
},
|
||||||
|
status: "proses",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
console.log(
|
||||||
|
"[RESPONSE UPDATE]",
|
||||||
|
JSON.stringify(response.data, null, 2)
|
||||||
|
);
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Berhasil mengunggah bukti transfer",
|
||||||
|
});
|
||||||
|
router.push(`/investment/${id}/(transaction-flow)/process`);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
@@ -21,9 +107,23 @@ export default function InvestmentInvoice() {
|
|||||||
<InformationBox text="Mohon transfer ke rekening dibawah" />
|
<InformationBox text="Mohon transfer ke rekening dibawah" />
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
<TextCustom>Nama BANK</TextCustom>
|
<Grid>
|
||||||
<TextCustom>Nama Penerima</TextCustom>
|
<Grid.Col span={4}>
|
||||||
|
<TextCustom>Bank</TextCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={8}>
|
||||||
|
<TextCustom>{data?.MasterBank?.namaBank}</TextCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
<Spacing height={10} />
|
<Spacing height={10} />
|
||||||
|
<Grid>
|
||||||
|
<Grid.Col span={4}>
|
||||||
|
<TextCustom>Nama Akun</TextCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={8}>
|
||||||
|
<TextCustom>{data?.MasterBank?.namaAkun}</TextCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
<BaseBox backgroundColor={MainColor.soft_darkblue}>
|
<BaseBox backgroundColor={MainColor.soft_darkblue}>
|
||||||
<Grid containerStyle={{ justifyContent: "center" }}>
|
<Grid containerStyle={{ justifyContent: "center" }}>
|
||||||
@@ -34,7 +134,7 @@ export default function InvestmentInvoice() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TextCustom size="xlarge" bold color="yellow">
|
<TextCustom size="xlarge" bold color="yellow">
|
||||||
4567898765433567
|
{data?.MasterBank?.norek}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col
|
<Grid.Col
|
||||||
@@ -43,7 +143,7 @@ export default function InvestmentInvoice() {
|
|||||||
alignItems: "flex-end",
|
alignItems: "flex-end",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ButtonCustom>Salin</ButtonCustom>
|
<CopyButton textToCopy={data?.MasterBank?.norek} />
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
@@ -65,7 +165,7 @@ export default function InvestmentInvoice() {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<TextCustom size="xlarge" bold color="yellow">
|
<TextCustom size="xlarge" bold color="yellow">
|
||||||
Rp. 1.000.000
|
Rp. {formatCurrencyDisplay(data?.nominal)}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col
|
<Grid.Col
|
||||||
@@ -74,7 +174,7 @@ export default function InvestmentInvoice() {
|
|||||||
alignItems: "flex-end",
|
alignItems: "flex-end",
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<ButtonCustom>Salin</ButtonCustom>
|
<CopyButton textToCopy={data?.nominal} />
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
@@ -83,10 +183,37 @@ export default function InvestmentInvoice() {
|
|||||||
|
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<TextCustom>Upload bukti transfer anda.</TextCustom>
|
<TextCustom align="center">
|
||||||
|
Upload bukti transfer anda.
|
||||||
|
</TextCustom>
|
||||||
|
{image ? (
|
||||||
|
<View
|
||||||
|
style={{
|
||||||
|
flexDirection: "row",
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
gap: 10,
|
||||||
|
paddingInline: 20,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<TextCustom bold align="center" truncate>
|
||||||
|
{image?.name}
|
||||||
|
</TextCustom>
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<TextCustom align="center">
|
||||||
|
Tidak ada gambar yang diunggah
|
||||||
|
</TextCustom>
|
||||||
|
)}
|
||||||
<ButtonCenteredOnly
|
<ButtonCenteredOnly
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.push("/(application)/(image)/take-picture/123");
|
pickFile({
|
||||||
|
allowedType: "image",
|
||||||
|
setImageUri(file: any) {
|
||||||
|
console.log("[IMAGE]", file);
|
||||||
|
setImage(file);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
icon="upload"
|
icon="upload"
|
||||||
>
|
>
|
||||||
@@ -96,14 +223,16 @@ export default function InvestmentInvoice() {
|
|||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
|
disabled={!image}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
router.push(`/investment/${id}/(transaction-flow)/process`);
|
handlerSubmitUpdate();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Saya Sudah Transfer
|
Saya Sudah Transfer
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
<Spacing/>
|
<Spacing />
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,13 +1,6 @@
|
|||||||
import {
|
import { BaseBox, StackCustom, TextCustom, ViewWrapper } from "@/components";
|
||||||
BaseBox,
|
import MoneyTransferAnimation from "@/components/_ShareComponent/MoneyTransferAnimation";
|
||||||
Grid,
|
import { View } from "react-native";
|
||||||
StackCustom,
|
|
||||||
TextCustom,
|
|
||||||
ViewWrapper,
|
|
||||||
} from "@/components";
|
|
||||||
import { MainColor } from "@/constants/color-palet";
|
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
|
||||||
import { ActivityIndicator } from "react-native";
|
|
||||||
|
|
||||||
export default function InvestmentProcess() {
|
export default function InvestmentProcess() {
|
||||||
return (
|
return (
|
||||||
@@ -16,21 +9,24 @@ export default function InvestmentProcess() {
|
|||||||
<BaseBox>
|
<BaseBox>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<TextCustom align="center" bold>
|
<TextCustom align="center" bold>
|
||||||
Admin sedang memproses transaksi investasimu
|
Admin sedang memvalidasi data dan bukti transfer anda. Mohon
|
||||||
|
tunggu proses ini selesai.
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<ActivityIndicator size="large" color={MainColor.yellow} />
|
<View style={{ alignItems: "center", justifyContent: "center" }}>
|
||||||
|
<MoneyTransferAnimation />
|
||||||
|
</View>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
<BaseBox>
|
{/* <BaseBox>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={10} style={{justifyContent: 'center'}}>
|
<Grid.Col span={10} style={{ justifyContent: "center" }}>
|
||||||
<TextCustom size="small">
|
<TextCustom size="small">
|
||||||
Hubungi admin jika tidak kunjung di proses! Klik pada logo
|
Hubungi admin jika tidak kunjung di proses! Klik pada logo
|
||||||
Whatsapp ini.
|
Whatsapp ini.
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col span={2} style={{alignItems: "flex-end"}}>
|
<Grid.Col span={2} style={{ alignItems: "flex-end" }}>
|
||||||
<Ionicons
|
<Ionicons
|
||||||
name="logo-whatsapp"
|
name="logo-whatsapp"
|
||||||
size={50}
|
size={50}
|
||||||
@@ -38,7 +34,7 @@ export default function InvestmentProcess() {
|
|||||||
/>
|
/>
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
</BaseBox>
|
</BaseBox> */}
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,35 +5,97 @@ import {
|
|||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { RadioCustom, RadioGroup } from "@/components/Radio/RadioCustom";
|
import { RadioCustom, RadioGroup } from "@/components/Radio/RadioCustom";
|
||||||
import { dummyMasterBank } from "@/lib/dummy-data/_master/bank";
|
import { LOCAL_STORAGE_KEY } from "@/constants/local-storage-key";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import { apiInvestmentCreateInvoice } from "@/service/api-client/api-investment";
|
||||||
|
import { apiMasterBank } from "@/service/api-client/api-master";
|
||||||
|
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
import { useState } from "react";
|
import _ from "lodash";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
export default function InvestmentSelectBank() {
|
export default function InvestmentSelectBank() {
|
||||||
|
const { user } = useAuth();
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [value, setValue] = useState<any | number>("");
|
const [select, setSelect] = useState<any | number>("");
|
||||||
|
const [listBank, setListBank] = useState<any>([]);
|
||||||
|
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
loadListBank();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const loadListBank = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiMasterBank();
|
||||||
|
|
||||||
|
setListBank(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
setListBank([]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setIsLoading(true);
|
||||||
|
const dataCheckout = await AsyncStorage.getItem(
|
||||||
|
LOCAL_STORAGE_KEY.transactionInvestment
|
||||||
|
);
|
||||||
|
if (dataCheckout) {
|
||||||
|
const storage = JSON.parse(dataCheckout);
|
||||||
|
const newData = {
|
||||||
|
...storage,
|
||||||
|
bankId: select,
|
||||||
|
authorId: user?.id,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await apiInvestmentCreateInvoice({
|
||||||
|
id: id as string,
|
||||||
|
data: newData,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
console.log("[RESPONSE >>]", response);
|
||||||
|
const invoiceId = response.data.id;
|
||||||
|
|
||||||
|
const delStorage = await AsyncStorage.removeItem(
|
||||||
|
LOCAL_STORAGE_KEY.transactionInvestment
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log("[DEL STORAGE]", delStorage);
|
||||||
|
router.replace(`/investment/${invoiceId}/invoice`);
|
||||||
|
} else {
|
||||||
|
console.log("[FAILED]", response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const buttonSubmit = () => {
|
const buttonSubmit = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom
|
<ButtonCustom isLoading={isLoading} onPress={() => handlerSubmit()}>Pilih</ButtonCustom>
|
||||||
onPress={() => router.replace(`/investment/${id}/invoice`)}
|
|
||||||
>
|
|
||||||
Pilih
|
|
||||||
</ButtonCustom>
|
|
||||||
</BoxButtonOnFooter>
|
</BoxButtonOnFooter>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper footerComponent={buttonSubmit()}>
|
<ViewWrapper footerComponent={buttonSubmit()}>
|
||||||
<RadioGroup value={value} onChange={setValue}>
|
<RadioGroup value={select} onChange={setSelect}>
|
||||||
{dummyMasterBank.map((item) => (
|
{_.isEmpty(listBank)
|
||||||
<BaseBox key={item.name}>
|
? []
|
||||||
<RadioCustom label={item.name} value={item.code} />
|
: listBank?.map((item: any) => (
|
||||||
</BaseBox>
|
<BaseBox key={item.id}>
|
||||||
))}
|
<RadioCustom label={item.namaBank} value={item.id} />
|
||||||
|
</BaseBox>
|
||||||
|
))}
|
||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -101,9 +101,8 @@ export default function InvestmentEdit() {
|
|||||||
|
|
||||||
const displayTargetDana = formatCurrencyDisplay(data?.targetDana);
|
const displayTargetDana = formatCurrencyDisplay(data?.targetDana);
|
||||||
const displayHargaPerLembar = formatCurrencyDisplay(data?.hargaLembar);
|
const displayHargaPerLembar = formatCurrencyDisplay(data?.hargaLembar);
|
||||||
const displayTotalLembar = formatCurrencyDisplay(
|
const realTotalLembar = Number(data?.targetDana) / Number(data?.hargaLembar);
|
||||||
Number(data?.targetDana) / Number(data?.hargaLembar)
|
const displayTotalLembar = formatCurrencyDisplay(realTotalLembar);
|
||||||
);
|
|
||||||
|
|
||||||
const handleChangeCurrency = (field: keyof typeof data) => (text: string) => {
|
const handleChangeCurrency = (field: keyof typeof data) => (text: string) => {
|
||||||
const numeric = text.replace(/\D/g, "");
|
const numeric = text.replace(/\D/g, "");
|
||||||
@@ -134,6 +133,7 @@ export default function InvestmentEdit() {
|
|||||||
const handleSubmitUpdate = async () => {
|
const handleSubmitUpdate = async () => {
|
||||||
let newData = {
|
let newData = {
|
||||||
...data,
|
...data,
|
||||||
|
totalLembar: realTotalLembar.toString(),
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!validateData()) {
|
if (!validateData()) {
|
||||||
|
|||||||
@@ -74,9 +74,8 @@ export default function InvestmentCreate() {
|
|||||||
|
|
||||||
const displayTargetDana = formatCurrencyDisplay(data.targetDana);
|
const displayTargetDana = formatCurrencyDisplay(data.targetDana);
|
||||||
const displayHargaPerLembar = formatCurrencyDisplay(data.hargaPerLembar);
|
const displayHargaPerLembar = formatCurrencyDisplay(data.hargaPerLembar);
|
||||||
const displayTotalLembar = formatCurrencyDisplay(
|
const realTotalLembar = Number(data.targetDana) / Number(data.hargaPerLembar);
|
||||||
Number(data.targetDana) / Number(data.hargaPerLembar)
|
const displayTotalLembar = formatCurrencyDisplay(realTotalLembar);
|
||||||
);
|
|
||||||
|
|
||||||
const handleChangeCurrency = (field: keyof typeof data) => (text: string) => {
|
const handleChangeCurrency = (field: keyof typeof data) => (text: string) => {
|
||||||
const numeric = text.replace(/\D/g, "");
|
const numeric = text.replace(/\D/g, "");
|
||||||
@@ -150,7 +149,7 @@ export default function InvestmentCreate() {
|
|||||||
title: data.title,
|
title: data.title,
|
||||||
targetDana: data.targetDana,
|
targetDana: data.targetDana,
|
||||||
hargaLembar: data.hargaPerLembar,
|
hargaLembar: data.hargaPerLembar,
|
||||||
totalLembar: displayTotalLembar,
|
totalLembar: realTotalLembar.toString(),
|
||||||
roi: data.rasioKeuntungan,
|
roi: data.rasioKeuntungan,
|
||||||
masterPencarianInvestorId: data.pencarianInvestor,
|
masterPencarianInvestorId: data.pencarianInvestor,
|
||||||
masterPembagianDevidenId: data.pembagianDeviden,
|
masterPembagianDevidenId: data.pembagianDeviden,
|
||||||
|
|||||||
@@ -1,54 +1,226 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import {
|
import {
|
||||||
BaseBox,
|
|
||||||
BoxButtonOnFooter,
|
BoxButtonOnFooter,
|
||||||
ButtonCenteredOnly,
|
ButtonCenteredOnly,
|
||||||
ButtonCustom,
|
ButtonCustom,
|
||||||
InformationBox,
|
InformationBox,
|
||||||
LandscapeFrameUploaded,
|
LandscapeFrameUploaded,
|
||||||
MapCustom,
|
|
||||||
Spacing,
|
Spacing,
|
||||||
TextInputCustom,
|
TextInputCustom,
|
||||||
ViewWrapper
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import API_IMAGE from "@/constants/api-storage";
|
||||||
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
|
import { apiMapsGetOne, apiMapsUpdate } from "@/service/api-client/api-maps";
|
||||||
|
import { uploadFileService } from "@/service/upload-service";
|
||||||
|
import pickFile, { IFileData } from "@/utils/pickFile";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import { StyleSheet, View } from "react-native";
|
||||||
|
import MapView, { LatLng, Marker } from "react-native-maps";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
|
const defaultRegion = {
|
||||||
|
latitude: -8.737109,
|
||||||
|
longitude: 115.1756897,
|
||||||
|
latitudeDelta: 0.1,
|
||||||
|
longitudeDelta: 0.1,
|
||||||
|
};
|
||||||
export default function MapsEdit() {
|
export default function MapsEdit() {
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState<any | null>({
|
||||||
|
id: "",
|
||||||
|
namePin: "",
|
||||||
|
latitude: "",
|
||||||
|
longitude: "",
|
||||||
|
imageId: "",
|
||||||
|
});
|
||||||
|
const [selectedLocation, setSelectedLocation] = useState<LatLng | null>(null);
|
||||||
|
const [image, setImage] = useState<IFileData | null>(null);
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiMapsGetOne({ id: id as string });
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setData({
|
||||||
|
id: response.data.id,
|
||||||
|
namePin: response.data.namePin,
|
||||||
|
latitude: response.data.latitude,
|
||||||
|
longitude: response.data.longitude,
|
||||||
|
imageId: response.data.imageId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleMapPress = (event: any) => {
|
||||||
|
const { latitude, longitude } = event.nativeEvent.coordinate;
|
||||||
|
const location = { latitude, longitude };
|
||||||
|
setSelectedLocation(location);
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
let newData: any;
|
||||||
|
if (!data.namePin) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Nama pin harus diisi",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
newData = {
|
||||||
|
namePin: data?.namePin,
|
||||||
|
latitude: selectedLocation?.latitude || data?.latitude,
|
||||||
|
longitude: selectedLocation?.longitude || data?.longitude,
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
if (image) {
|
||||||
|
const responseUpload = await uploadFileService({
|
||||||
|
dirId: DIRECTORY_ID.map_image,
|
||||||
|
imageUri: image?.uri,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!responseUpload?.data?.id) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengunggah gambar",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const imageId = responseUpload?.data?.id;
|
||||||
|
|
||||||
|
newData = {
|
||||||
|
namePin: data?.namePin,
|
||||||
|
latitude: selectedLocation?.latitude,
|
||||||
|
longitude: selectedLocation?.longitude,
|
||||||
|
newImageId: imageId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const responseUpdate = await apiMapsUpdate({
|
||||||
|
id: data?.id,
|
||||||
|
data: newData,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!responseUpdate.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengupdate map",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Map berhasil diupdate",
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const buttonFooter = (
|
const buttonFooter = (
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
onPress={() => {
|
disabled={!data.namePin}
|
||||||
console.log(`Simpan maps ${id}`);
|
onPress={handleSubmit}
|
||||||
router.back()
|
isLoading={isLoading}
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Simpan
|
Update
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
</BoxButtonOnFooter>
|
</BoxButtonOnFooter>
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper footerComponent={buttonFooter}>
|
<ViewWrapper footerComponent={buttonFooter}>
|
||||||
<InformationBox text="Tentukan lokasi pin map dengan menekan pada map." />
|
<InformationBox text="Tentukan lokasi pin map dengan menekan pada map." />
|
||||||
|
|
||||||
<BaseBox>
|
<View style={[styles.container, { height: 400 }]}>
|
||||||
<MapCustom />
|
<MapView
|
||||||
</BaseBox>
|
style={styles.map}
|
||||||
|
initialRegion={
|
||||||
|
data?.latitude && data?.longitude
|
||||||
|
? {
|
||||||
|
latitude: data?.latitude,
|
||||||
|
longitude: data?.longitude,
|
||||||
|
latitudeDelta: 0.1,
|
||||||
|
longitudeDelta: 0.1,
|
||||||
|
}
|
||||||
|
: defaultRegion
|
||||||
|
}
|
||||||
|
onPress={handleMapPress}
|
||||||
|
showsUserLocation={true}
|
||||||
|
showsMyLocationButton={true}
|
||||||
|
loadingEnabled={true}
|
||||||
|
loadingIndicatorColor="#666"
|
||||||
|
loadingBackgroundColor="#f0f0f0"
|
||||||
|
>
|
||||||
|
{selectedLocation ? (
|
||||||
|
<Marker
|
||||||
|
coordinate={selectedLocation}
|
||||||
|
title="Lokasi Dipilih"
|
||||||
|
description={`Lat: ${selectedLocation.latitude.toFixed(
|
||||||
|
6
|
||||||
|
)}, Lng: ${selectedLocation.longitude.toFixed(6)}`}
|
||||||
|
pinColor="red"
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<Marker
|
||||||
|
coordinate={defaultRegion}
|
||||||
|
title="Lokasi Dipilih"
|
||||||
|
description={`Lat: ${defaultRegion.latitude.toFixed(
|
||||||
|
6
|
||||||
|
)}, Lng: ${defaultRegion.longitude.toFixed(6)}`}
|
||||||
|
pinColor="red"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</MapView>
|
||||||
|
</View>
|
||||||
|
|
||||||
<TextInputCustom
|
<TextInputCustom
|
||||||
required
|
required
|
||||||
label="Nama Pin"
|
label="Nama Pin"
|
||||||
placeholder="Masukkan nama pin maps"
|
placeholder="Masukkan nama pin maps"
|
||||||
|
value={data?.namePin}
|
||||||
|
onChangeText={(value) => setData({ ...data, namePin: value })}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Spacing />
|
<Spacing />
|
||||||
|
|
||||||
<InformationBox text="Upload foto lokasi bisnis anda untuk ditampilkan dalam detail maps." />
|
<InformationBox text="Upload foto lokasi bisnis anda untuk ditampilkan dalam detail maps." />
|
||||||
<LandscapeFrameUploaded />
|
<LandscapeFrameUploaded
|
||||||
|
image={
|
||||||
|
image
|
||||||
|
? image?.uri
|
||||||
|
: API_IMAGE.GET({ fileId: data?.imageId as string })
|
||||||
|
}
|
||||||
|
/>
|
||||||
<ButtonCenteredOnly
|
<ButtonCenteredOnly
|
||||||
icon="upload"
|
icon="upload"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
console.log("Upload foto ");
|
pickFile({
|
||||||
router.navigate(`/take-picture/${id}`);
|
allowedType: "image",
|
||||||
|
setImageUri(file) {
|
||||||
|
setImage(file);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Upload
|
Upload
|
||||||
@@ -57,3 +229,16 @@ export default function MapsEdit() {
|
|||||||
</ViewWrapper>
|
</ViewWrapper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
width: "100%",
|
||||||
|
backgroundColor: "#f5f5f5",
|
||||||
|
overflow: "hidden",
|
||||||
|
borderRadius: 8,
|
||||||
|
marginBottom: 20,
|
||||||
|
},
|
||||||
|
map: {
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|||||||
@@ -6,21 +6,96 @@ import {
|
|||||||
InformationBox,
|
InformationBox,
|
||||||
LandscapeFrameUploaded,
|
LandscapeFrameUploaded,
|
||||||
Spacing,
|
Spacing,
|
||||||
TextCustom,
|
|
||||||
TextInputCustom,
|
TextInputCustom,
|
||||||
ViewWrapper,
|
ViewWrapper,
|
||||||
} from "@/components";
|
} from "@/components";
|
||||||
|
import MapSelected from "@/components/Map/MapSelected";
|
||||||
|
import DIRECTORY_ID from "@/constants/directory-id";
|
||||||
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import { apiMapsCreate } from "@/service/api-client/api-maps";
|
||||||
|
import { uploadFileService } from "@/service/upload-service";
|
||||||
|
import pickFile, { IFileData } from "@/utils/pickFile";
|
||||||
import { router, useLocalSearchParams } from "expo-router";
|
import { router, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useState } from "react";
|
||||||
|
import { LatLng } from "react-native-maps";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
export default function MapsCreate() {
|
export default function MapsCreate() {
|
||||||
|
const { user } = useAuth();
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
|
const [selectedLocation, setSelectedLocation] = useState<LatLng | null>(null);
|
||||||
|
const [name, setName] = useState<string>("");
|
||||||
|
const [image, setImage] = useState<IFileData | null>(null);
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
let newData: any;
|
||||||
|
newData = {
|
||||||
|
authorId: user?.id,
|
||||||
|
portofolioId: id,
|
||||||
|
namePin: name,
|
||||||
|
latitude: selectedLocation?.latitude,
|
||||||
|
longitude: selectedLocation?.longitude,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (image) {
|
||||||
|
const responseUpload = await uploadFileService({
|
||||||
|
dirId: DIRECTORY_ID.map_image,
|
||||||
|
imageUri: image?.uri,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!responseUpload?.data?.id) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal mengunggah gambar",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const imageId = responseUpload?.data?.id;
|
||||||
|
|
||||||
|
newData = {
|
||||||
|
authorId: user?.id,
|
||||||
|
portofolioId: id,
|
||||||
|
namePin: name,
|
||||||
|
latitude: selectedLocation?.latitude,
|
||||||
|
longitude: selectedLocation?.longitude,
|
||||||
|
imageId: imageId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const response = await apiMapsCreate({
|
||||||
|
data: newData,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Gagal menambahkan map",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Map berhasil ditambahkan",
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const buttonFooter = (
|
const buttonFooter = (
|
||||||
<BoxButtonOnFooter>
|
<BoxButtonOnFooter>
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
onPress={() => {
|
isLoading={isLoading}
|
||||||
console.log(`Simpan maps ${id}`);
|
disabled={!selectedLocation || name === ""}
|
||||||
router.replace(`/portofolio/${id}`);
|
onPress={handleSubmit}
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
Simpan
|
Simpan
|
||||||
</ButtonCustom>
|
</ButtonCustom>
|
||||||
@@ -30,25 +105,34 @@ export default function MapsCreate() {
|
|||||||
<ViewWrapper footerComponent={buttonFooter}>
|
<ViewWrapper footerComponent={buttonFooter}>
|
||||||
<InformationBox text="Tentukan lokasi pin map dengan menekan pada map." />
|
<InformationBox text="Tentukan lokasi pin map dengan menekan pada map." />
|
||||||
|
|
||||||
<BaseBox style={{ height: 400 }}>
|
<BaseBox>
|
||||||
<TextCustom>Maps Her</TextCustom>
|
<MapSelected
|
||||||
|
selectedLocation={selectedLocation as any}
|
||||||
|
setSelectedLocation={setSelectedLocation}
|
||||||
|
/>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
|
|
||||||
<TextInputCustom
|
<TextInputCustom
|
||||||
required
|
required
|
||||||
label="Nama Pin"
|
label="Nama Pin"
|
||||||
placeholder="Masukkan nama pin maps"
|
placeholder="Masukkan nama pin maps"
|
||||||
|
value={name}
|
||||||
|
onChangeText={setName}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Spacing height={50} />
|
<Spacing height={50} />
|
||||||
|
|
||||||
<InformationBox text="Upload foto lokasi bisnis anda untuk ditampilkan dalam detail maps." />
|
<InformationBox text="Upload foto lokasi bisnis anda untuk ditampilkan dalam detail maps." />
|
||||||
<LandscapeFrameUploaded />
|
<LandscapeFrameUploaded image={image?.uri} />
|
||||||
<ButtonCenteredOnly
|
<ButtonCenteredOnly
|
||||||
icon="upload"
|
icon="upload"
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
console.log("Upload foto ");
|
pickFile({
|
||||||
router.navigate(`/take-picture/${id}`);
|
allowedType: "image",
|
||||||
|
setImageUri(file) {
|
||||||
|
setImage(file);
|
||||||
|
},
|
||||||
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Upload
|
Upload
|
||||||
|
|||||||
@@ -1,19 +1,234 @@
|
|||||||
import { MapCustom, ViewWrapper } from "@/components";
|
import {
|
||||||
|
ButtonCustom,
|
||||||
|
DrawerCustom,
|
||||||
|
DummyLandscapeImage,
|
||||||
|
Grid,
|
||||||
|
Spacing,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
|
import GridTwoView from "@/components/_ShareComponent/GridTwoView";
|
||||||
|
import API_IMAGE from "@/constants/api-storage";
|
||||||
|
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
||||||
|
import { apiMapsGetAll } from "@/service/api-client/api-maps";
|
||||||
|
import { openInDeviceMaps } from "@/utils/openInDeviceMaps";
|
||||||
|
import { FontAwesome, Ionicons } from "@expo/vector-icons";
|
||||||
|
import { Image } from "expo-image";
|
||||||
|
import { router, useFocusEffect } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
import MapView from "react-native-maps";
|
import MapView, { Marker } from "react-native-maps";
|
||||||
|
|
||||||
|
const defaultRegion = {
|
||||||
|
latitude: -8.737109,
|
||||||
|
longitude: 115.1756897,
|
||||||
|
latitudeDelta: 0.1,
|
||||||
|
longitudeDelta: 0.1,
|
||||||
|
height: 300,
|
||||||
|
};
|
||||||
|
|
||||||
|
export interface LocationItem {
|
||||||
|
id: string | number;
|
||||||
|
latitude: number;
|
||||||
|
longitude: number;
|
||||||
|
name: string;
|
||||||
|
imageId?: string;
|
||||||
|
}
|
||||||
|
|
||||||
export default function Maps() {
|
export default function Maps() {
|
||||||
|
const [list, setList] = useState<any[] | null>(null);
|
||||||
|
const [loadList, setLoadList] = useState(false);
|
||||||
|
const [openDrawer, setOpenDrawer] = useState(false);
|
||||||
|
const [selected, setSelected] = useState({
|
||||||
|
id: "",
|
||||||
|
bidangBisnis: "",
|
||||||
|
nomorTelepon: "",
|
||||||
|
alamatBisnis: "",
|
||||||
|
namePin: "",
|
||||||
|
imageId: "",
|
||||||
|
portofolioId: "",
|
||||||
|
latitude: 0,
|
||||||
|
longitude: 0,
|
||||||
|
});
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
handlerLoadList();
|
||||||
|
}, [])
|
||||||
|
);
|
||||||
|
|
||||||
|
const handlerLoadList = async () => {
|
||||||
|
try {
|
||||||
|
setLoadList(true);
|
||||||
|
const response = await apiMapsGetAll();
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setList(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadList(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ViewWrapper style={{ paddingInline: 0, paddingBlock: 0 }}>
|
<>
|
||||||
{/* <MapCustom height={"100%"} /> */}
|
<ViewWrapper style={{ paddingInline: 0, paddingBlock: 0 }}>
|
||||||
<View style={{ flex: 1 }}>
|
{/* <MapCustom height={"100%"} /> */}
|
||||||
<MapView
|
<View style={{ flex: 1 }}>
|
||||||
style={{
|
{loadList ? (
|
||||||
width: "100%",
|
<MapView
|
||||||
height: "100%",
|
initialRegion={defaultRegion}
|
||||||
}}
|
style={{
|
||||||
/>
|
width: "100%",
|
||||||
</View>
|
height: "100%",
|
||||||
</ViewWrapper>
|
}}
|
||||||
|
/>
|
||||||
|
) : (
|
||||||
|
<MapView
|
||||||
|
initialRegion={defaultRegion}
|
||||||
|
style={{
|
||||||
|
width: "100%",
|
||||||
|
height: "100%",
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{list?.map((item: any, index: number) => {
|
||||||
|
return (
|
||||||
|
<Marker
|
||||||
|
key={item?.id}
|
||||||
|
coordinate={{
|
||||||
|
latitude: item?.latitude,
|
||||||
|
longitude: item?.longitude,
|
||||||
|
}}
|
||||||
|
title={item?.namePin}
|
||||||
|
onPress={() => {
|
||||||
|
setOpenDrawer(true);
|
||||||
|
setSelected({
|
||||||
|
id: item?.id,
|
||||||
|
bidangBisnis:
|
||||||
|
item?.Portofolio?.MasterBidangBisnis?.name,
|
||||||
|
nomorTelepon: item?.Portofolio?.tlpn,
|
||||||
|
alamatBisnis: item?.Portofolio?.alamatKantor,
|
||||||
|
namePin: item?.namePin,
|
||||||
|
imageId: item?.imageId,
|
||||||
|
portofolioId: item?.Portofolio?.id,
|
||||||
|
latitude: item?.latitude,
|
||||||
|
longitude: item?.longitude,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
// Gunakan gambar kustom jika tersedia
|
||||||
|
>
|
||||||
|
<View style={{}}>
|
||||||
|
<Image
|
||||||
|
source={{
|
||||||
|
uri: API_IMAGE.GET({
|
||||||
|
fileId: item?.Portofolio?.logoId,
|
||||||
|
}),
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
width: 30,
|
||||||
|
height: 30,
|
||||||
|
borderRadius: 100,
|
||||||
|
borderWidth: 1,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</Marker>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</MapView>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
</ViewWrapper>
|
||||||
|
|
||||||
|
<DrawerCustom
|
||||||
|
isVisible={openDrawer}
|
||||||
|
closeDrawer={() => setOpenDrawer(false)}
|
||||||
|
height={"auto"}
|
||||||
|
>
|
||||||
|
<DummyLandscapeImage height={200} imageId={selected.imageId} />
|
||||||
|
<Spacing />
|
||||||
|
<StackCustom gap={"xs"}>
|
||||||
|
<GridTwoView
|
||||||
|
spanLeft={2}
|
||||||
|
spanRight={10}
|
||||||
|
leftIcon={
|
||||||
|
<FontAwesome
|
||||||
|
name="building-o"
|
||||||
|
size={ICON_SIZE_SMALL}
|
||||||
|
color="white"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
rightIcon={<TextCustom>{selected.namePin}</TextCustom>}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<GridTwoView
|
||||||
|
spanLeft={2}
|
||||||
|
spanRight={10}
|
||||||
|
leftIcon={
|
||||||
|
<Ionicons
|
||||||
|
name="list-outline"
|
||||||
|
size={ICON_SIZE_SMALL}
|
||||||
|
color="white"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
rightIcon={<TextCustom>{selected.bidangBisnis}</TextCustom>}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<GridTwoView
|
||||||
|
spanLeft={2}
|
||||||
|
spanRight={10}
|
||||||
|
leftIcon={
|
||||||
|
<Ionicons
|
||||||
|
name="call-outline"
|
||||||
|
size={ICON_SIZE_SMALL}
|
||||||
|
color="white"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
rightIcon={<TextCustom>{selected.nomorTelepon}</TextCustom>}
|
||||||
|
/>
|
||||||
|
<GridTwoView
|
||||||
|
spanLeft={2}
|
||||||
|
spanRight={10}
|
||||||
|
leftIcon={
|
||||||
|
<Ionicons
|
||||||
|
name="location-outline"
|
||||||
|
size={ICON_SIZE_SMALL}
|
||||||
|
color="white"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
rightIcon={<TextCustom>{selected.alamatBisnis}</TextCustom>}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Grid>
|
||||||
|
<Grid.Col span={6} style={{ paddingRight: 10 }}>
|
||||||
|
<ButtonCustom
|
||||||
|
onPress={() => {
|
||||||
|
setOpenDrawer(false);
|
||||||
|
router.push(`/portofolio/${selected.portofolioId}`);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Detail
|
||||||
|
</ButtonCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col span={6} style={{ paddingLeft: 10 }}>
|
||||||
|
<ButtonCustom
|
||||||
|
onPress={() => {
|
||||||
|
openInDeviceMaps({
|
||||||
|
latitude: selected.latitude,
|
||||||
|
longitude: selected.longitude,
|
||||||
|
title: selected.namePin,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Buka Maps
|
||||||
|
</ButtonCustom>
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
</StackCustom>
|
||||||
|
</DrawerCustom>
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,18 @@
|
|||||||
/* eslint-disable react-hooks/exhaustive-deps */
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
import { DrawerCustom, LoaderCustom, Spacing, StackCustom } from "@/components";
|
import {
|
||||||
|
ButtonCustom,
|
||||||
|
DrawerCustom,
|
||||||
|
DummyLandscapeImage,
|
||||||
|
LoaderCustom,
|
||||||
|
Spacing,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
|
} from "@/components";
|
||||||
import LeftButtonCustom from "@/components/Button/BackButton";
|
import LeftButtonCustom from "@/components/Button/BackButton";
|
||||||
|
import GridTwoView from "@/components/_ShareComponent/GridTwoView";
|
||||||
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
import ViewWrapper from "@/components/_ShareComponent/ViewWrapper";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
||||||
import { useAuth } from "@/hooks/use-auth";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import Portofolio_BusinessLocation from "@/screens/Portofolio/BusinessLocationSection";
|
import Portofolio_BusinessLocation from "@/screens/Portofolio/BusinessLocationSection";
|
||||||
import Portofolio_ButtonDelete from "@/screens/Portofolio/ButtonDelete";
|
import Portofolio_ButtonDelete from "@/screens/Portofolio/ButtonDelete";
|
||||||
@@ -13,19 +23,20 @@ import Portofolio_SocialMediaSection from "@/screens/Portofolio/SocialMediaSecti
|
|||||||
import { apiGetOnePortofolio } from "@/service/api-client/api-portofolio";
|
import { apiGetOnePortofolio } from "@/service/api-client/api-portofolio";
|
||||||
import { apiUser } from "@/service/api-client/api-user";
|
import { apiUser } from "@/service/api-client/api-user";
|
||||||
import { GStyles } from "@/styles/global-styles";
|
import { GStyles } from "@/styles/global-styles";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { openInDeviceMaps } from "@/utils/openInDeviceMaps";
|
||||||
|
import { FontAwesome, Ionicons } from "@expo/vector-icons";
|
||||||
import { Stack, useFocusEffect, useLocalSearchParams } from "expo-router";
|
import { Stack, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
import { useCallback, useState } from "react";
|
import { useCallback, useState } from "react";
|
||||||
import { TouchableOpacity } from "react-native";
|
import { TouchableOpacity } from "react-native";
|
||||||
|
|
||||||
export default function Portofolio() {
|
export default function Portofolio() {
|
||||||
|
const { user } = useAuth();
|
||||||
const { id } = useLocalSearchParams();
|
const { id } = useLocalSearchParams();
|
||||||
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
const [isDrawerOpen, setIsDrawerOpen] = useState(false);
|
||||||
const [isLoadingDelete, setIsLoadingDelete] = useState(false);
|
const [isLoadingDelete, setIsLoadingDelete] = useState(false);
|
||||||
const [data, setData] = useState<any>();
|
const [data, setData] = useState<any>();
|
||||||
const [profileId, setProfileId] = useState<any>();
|
const [profileId, setProfileId] = useState<any>();
|
||||||
|
const [openDrawerLocation, setOpenDrawerLocation] = useState(false);
|
||||||
const { user } = useAuth();
|
|
||||||
|
|
||||||
const openDrawer = () => {
|
const openDrawer = () => {
|
||||||
setIsDrawerOpen(true);
|
setIsDrawerOpen(true);
|
||||||
@@ -43,19 +54,13 @@ export default function Portofolio() {
|
|||||||
|
|
||||||
async function onLoadData(id: string) {
|
async function onLoadData(id: string) {
|
||||||
const response = await apiGetOnePortofolio({ id: id });
|
const response = await apiGetOnePortofolio({ id: id });
|
||||||
console.log(
|
|
||||||
"[PROFILE ID]>>",
|
|
||||||
JSON.stringify(response.data.Profile.id, null, 2)
|
|
||||||
);
|
|
||||||
setData(response.data);
|
setData(response.data);
|
||||||
}
|
}
|
||||||
|
|
||||||
const onLoadUserByToken = async () => {
|
const onLoadUserByToken = async () => {
|
||||||
const response = await apiUser(user?.id as string);
|
const response = await apiUser(user?.id as string);
|
||||||
console.log(
|
|
||||||
"[PROFILE LOGIN]>>",
|
|
||||||
JSON.stringify(response.data?.Profile.id, null, 2)
|
|
||||||
);
|
|
||||||
setProfileId(response?.data?.Profile?.id);
|
setProfileId(response?.data?.Profile?.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -89,7 +94,11 @@ export default function Portofolio() {
|
|||||||
data={data}
|
data={data}
|
||||||
listSubBidang={data?.Portofolio_BidangDanSubBidangBisnis as any[]}
|
listSubBidang={data?.Portofolio_BidangDanSubBidangBisnis as any[]}
|
||||||
/>
|
/>
|
||||||
<Portofolio_BusinessLocation />
|
<Portofolio_BusinessLocation
|
||||||
|
data={data?.BusinessMaps}
|
||||||
|
imageId={data?.logoId}
|
||||||
|
setOpenDrawerLocation={setOpenDrawerLocation}
|
||||||
|
/>
|
||||||
<Portofolio_SocialMediaSection
|
<Portofolio_SocialMediaSection
|
||||||
data={data?.Portofolio_MediaSosial}
|
data={data?.Portofolio_MediaSosial}
|
||||||
/>
|
/>
|
||||||
@@ -110,10 +119,93 @@ export default function Portofolio() {
|
|||||||
height={"auto"}
|
height={"auto"}
|
||||||
>
|
>
|
||||||
<Portofolio_MenuDrawerSection
|
<Portofolio_MenuDrawerSection
|
||||||
drawerItems={drawerItemsPortofolio({ id: id as string })}
|
drawerItems={drawerItemsPortofolio({
|
||||||
|
id: id as string,
|
||||||
|
maps: data?.BusinessMaps,
|
||||||
|
})}
|
||||||
setIsDrawerOpen={setIsDrawerOpen}
|
setIsDrawerOpen={setIsDrawerOpen}
|
||||||
/>
|
/>
|
||||||
</DrawerCustom>
|
</DrawerCustom>
|
||||||
|
|
||||||
|
{/* Drawer Lokasi */}
|
||||||
|
<DrawerCustom
|
||||||
|
isVisible={openDrawerLocation}
|
||||||
|
closeDrawer={() => setOpenDrawerLocation(false)}
|
||||||
|
height={"auto"}
|
||||||
|
>
|
||||||
|
<DummyLandscapeImage
|
||||||
|
height={200}
|
||||||
|
imageId={data?.BusinessMaps?.imageId}
|
||||||
|
/>
|
||||||
|
<Spacing />
|
||||||
|
<StackCustom gap={"xs"}>
|
||||||
|
<GridTwoView
|
||||||
|
spanLeft={2}
|
||||||
|
spanRight={10}
|
||||||
|
leftIcon={
|
||||||
|
<FontAwesome
|
||||||
|
name="building-o"
|
||||||
|
size={ICON_SIZE_SMALL}
|
||||||
|
color="white"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
rightIcon={<TextCustom>{data?.BusinessMaps?.namePin}</TextCustom>}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<GridTwoView
|
||||||
|
spanLeft={2}
|
||||||
|
spanRight={10}
|
||||||
|
leftIcon={
|
||||||
|
<Ionicons
|
||||||
|
name="list-outline"
|
||||||
|
size={ICON_SIZE_SMALL}
|
||||||
|
color="white"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
rightIcon={
|
||||||
|
<TextCustom>{data?.MasterBidangBisnis?.name}</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<GridTwoView
|
||||||
|
spanLeft={2}
|
||||||
|
spanRight={10}
|
||||||
|
leftIcon={
|
||||||
|
<Ionicons
|
||||||
|
name="call-outline"
|
||||||
|
size={ICON_SIZE_SMALL}
|
||||||
|
color="white"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
rightIcon={<TextCustom>{data?.tlpn}</TextCustom>}
|
||||||
|
/>
|
||||||
|
<GridTwoView
|
||||||
|
spanLeft={2}
|
||||||
|
spanRight={10}
|
||||||
|
leftIcon={
|
||||||
|
<Ionicons
|
||||||
|
name="location-outline"
|
||||||
|
size={ICON_SIZE_SMALL}
|
||||||
|
color="white"
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
rightIcon={<TextCustom>{data?.alamatKantor}</TextCustom>}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Spacing />
|
||||||
|
<ButtonCustom
|
||||||
|
onPress={() => {
|
||||||
|
openInDeviceMaps({
|
||||||
|
latitude: data?.BusinessMaps?.latitude,
|
||||||
|
longitude: data?.BusinessMaps?.longitude,
|
||||||
|
title: data?.BusinessMaps?.namePin,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Buka Maps
|
||||||
|
</ButtonCustom>
|
||||||
|
</StackCustom>
|
||||||
|
</DrawerCustom>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export default function Profile() {
|
|||||||
const [dataToken, setDataToken] = useState<IProfile>();
|
const [dataToken, setDataToken] = useState<IProfile>();
|
||||||
const [listPortofolio, setListPortofolio] = useState<any[]>();
|
const [listPortofolio, setListPortofolio] = useState<any[]>();
|
||||||
|
|
||||||
const { logout, isAdmin, user } = useAuth();
|
const { token, logout, isAdmin, user, userData } = useAuth();
|
||||||
|
|
||||||
const openDrawer = () => {
|
const openDrawer = () => {
|
||||||
setIsDrawerOpen(true);
|
setIsDrawerOpen(true);
|
||||||
@@ -42,7 +42,8 @@ export default function Profile() {
|
|||||||
onLoadPortofolio(id as string);
|
onLoadPortofolio(id as string);
|
||||||
onLoadUserByToken();
|
onLoadUserByToken();
|
||||||
isUserCheck();
|
isUserCheck();
|
||||||
}, [id])
|
userData(token as string);
|
||||||
|
}, [id, token])
|
||||||
);
|
);
|
||||||
|
|
||||||
const isUserCheck = () => {
|
const isUserCheck = () => {
|
||||||
@@ -136,10 +137,7 @@ const ButtonnDot = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const isId = id === undefined || id === null;
|
const isId = id === undefined || id === null;
|
||||||
|
|
||||||
console.log("ID CHECK", id);
|
|
||||||
|
|
||||||
if (isId) {
|
if (isId) {
|
||||||
console.log("ID UNDEFINED", id);
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<TouchableOpacity onPress={logout}>
|
<TouchableOpacity onPress={logout}>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
import { ICON_SIZE_BUTTON } from "@/constants/constans-value";
|
||||||
import { useAuth } from "@/hooks/use-auth";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
|
import { apiUser } from "@/service/api-client/api-user";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
import { router } from "expo-router";
|
import { router } from "expo-router";
|
||||||
import Toast from "react-native-toast-message";
|
import Toast from "react-native-toast-message";
|
||||||
@@ -19,12 +20,25 @@ export default function WaitingRoom() {
|
|||||||
async function handleCheck() {
|
async function handleCheck() {
|
||||||
try {
|
try {
|
||||||
const response = await userData(token as string);
|
const response = await userData(token as string);
|
||||||
|
|
||||||
if (response.active) {
|
if (response.active) {
|
||||||
Toast.show({
|
const checkProfile = await apiUser(response.id);
|
||||||
type: "success",
|
|
||||||
text1: "Akun anda telah aktif", // text2: "Anda berhasil login",
|
if (checkProfile?.data?.Profile) {
|
||||||
});
|
Toast.show({
|
||||||
router.replace(`/(application)/(user)/profile/create`);
|
type: "success",
|
||||||
|
text1: "Akun anda telah aktif kembali", // text2: "Anda berhasil login",
|
||||||
|
});
|
||||||
|
router.replace(`/(application)/(user)/home`);
|
||||||
|
} else {
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Akun anda telah aktif", // text2: "Anda berhasil login",
|
||||||
|
});
|
||||||
|
router.replace(`/(application)/(user)/profile/create`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// router.replace(`/(application)/(user)/profile/create`);
|
||||||
} else {
|
} else {
|
||||||
Toast.show({
|
Toast.show({
|
||||||
type: "error",
|
type: "error",
|
||||||
|
|||||||
@@ -15,7 +15,10 @@ import {
|
|||||||
ICON_SIZE_XLARGE,
|
ICON_SIZE_XLARGE,
|
||||||
} from "@/constants/constans-value";
|
} from "@/constants/constans-value";
|
||||||
import { useAuth } from "@/hooks/use-auth";
|
import { useAuth } from "@/hooks/use-auth";
|
||||||
import { adminListMenu } from "@/screens/Admin/listPageAdmin";
|
import {
|
||||||
|
adminListMenu,
|
||||||
|
superAdminListMenu,
|
||||||
|
} from "@/screens/Admin/listPageAdmin";
|
||||||
import { GStyles } from "@/styles/global-styles";
|
import { GStyles } from "@/styles/global-styles";
|
||||||
import { FontAwesome6, Ionicons } from "@expo/vector-icons";
|
import { FontAwesome6, Ionicons } from "@expo/vector-icons";
|
||||||
import { router, Stack } from "expo-router";
|
import { router, Stack } from "expo-router";
|
||||||
@@ -24,8 +27,11 @@ import { useState } from "react";
|
|||||||
export default function AdminLayout() {
|
export default function AdminLayout() {
|
||||||
const [openDrawerNavbar, setOpenDrawerNavbar] = useState(false);
|
const [openDrawerNavbar, setOpenDrawerNavbar] = useState(false);
|
||||||
const [openDrawerUser, setOpenDrawerUser] = useState(false);
|
const [openDrawerUser, setOpenDrawerUser] = useState(false);
|
||||||
|
// const [user, setUser] = useState(null);
|
||||||
|
|
||||||
const { logout } = useAuth();
|
const { logout, user } = useAuth();
|
||||||
|
|
||||||
|
console.log("[USER LAYOUT]", JSON.stringify(user, null, 2));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -56,58 +62,58 @@ export default function AdminLayout() {
|
|||||||
),
|
),
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Stack.Screen name="dashboard" />
|
{/* <Stack.Screen name="dashboard" /> */}
|
||||||
{/* ================== Investment Start ================== */}
|
{/* ================== Investment Start ================== */}
|
||||||
<Stack.Screen name="investment/index" />
|
{/* <Stack.Screen name="investment/index" /> */}
|
||||||
{/* ================== Investment End ================== */}
|
{/* ================== Investment End ================== */}
|
||||||
|
|
||||||
{/* ================== Maps Start ================== */}
|
{/* ================== Maps Start ================== */}
|
||||||
<Stack.Screen name="maps" />
|
{/* <Stack.Screen name="maps" /> */}
|
||||||
{/* ================== Maps End ================== */}
|
{/* ================== Maps End ================== */}
|
||||||
|
|
||||||
{/* ================== App Information Start ================== */}
|
{/* ================== App Information Start ================== */}
|
||||||
<Stack.Screen name="app-information/index" />
|
{/* <Stack.Screen name="app-information/index" /> */}
|
||||||
{/* ================== App Information End ================== */}
|
{/* ================== App Information End ================== */}
|
||||||
|
|
||||||
{/* ================== Job Start ================== */}
|
{/* ================== Job Start ================== */}
|
||||||
<Stack.Screen name="job/index" />
|
{/* <Stack.Screen name="job/index" /> */}
|
||||||
{/* <Stack.Screen name="job/publish" />
|
{/* <Stack.Screen name="job/publish" />
|
||||||
<Stack.Screen name="job/review" />
|
<Stack.Screen name="job/review" />
|
||||||
<Stack.Screen name="job/reject" /> */}
|
<Stack.Screen name="job/reject" /> */}
|
||||||
<Stack.Screen name="job/[status]/status" />
|
{/* <Stack.Screen name="job/[status]/status" />
|
||||||
<Stack.Screen name="job/[id]/[status]/index" />
|
<Stack.Screen name="job/[id]/[status]/index" /> */}
|
||||||
|
|
||||||
{/* ================== Collaboration Start ================== */}
|
{/* ================== Collaboration Start ================== */}
|
||||||
<Stack.Screen name="collaboration/index" />
|
{/* <Stack.Screen name="collaboration/index" /> */}
|
||||||
<Stack.Screen name="collaboration/publish" />
|
{/* <Stack.Screen name="collaboration/publish" />
|
||||||
<Stack.Screen name="collaboration/group" />
|
<Stack.Screen name="collaboration/group" />
|
||||||
<Stack.Screen name="collaboration/reject" />
|
<Stack.Screen name="collaboration/reject" />
|
||||||
<Stack.Screen name="collaboration/[id]/[status]" />
|
<Stack.Screen name="collaboration/[id]/[status]" />
|
||||||
<Stack.Screen name="collaboration/[id]/group" />
|
<Stack.Screen name="collaboration/[id]/group" /> */}
|
||||||
{/* ================== Collaboration End ================== */}
|
{/* ================== Collaboration End ================== */}
|
||||||
|
|
||||||
{/* ================== Forum Start ================== */}
|
{/* ================== Forum Start ================== */}
|
||||||
<Stack.Screen name="forum/index" />
|
{/* <Stack.Screen name="forum/index" /> */}
|
||||||
<Stack.Screen name="forum/[id]/index" />
|
{/* <Stack.Screen name="forum/[id]/index" />
|
||||||
<Stack.Screen name="forum/report-comment" />
|
<Stack.Screen name="forum/report-comment" />
|
||||||
<Stack.Screen name="forum/report-posting" />
|
<Stack.Screen name="forum/report-posting" />
|
||||||
<Stack.Screen name="forum/[id]/list-report-posting" />
|
<Stack.Screen name="forum/[id]/list-report-posting" />
|
||||||
<Stack.Screen name="forum/[id]/list-report-comment" />
|
<Stack.Screen name="forum/[id]/list-report-comment" /> */}
|
||||||
{/* ================== Forum End ================== */}
|
{/* ================== Forum End ================== */}
|
||||||
|
|
||||||
{/* ================== Voting Start ================== */}
|
{/* ================== Voting Start ================== */}
|
||||||
<Stack.Screen name="voting/index" />
|
{/* <Stack.Screen name="voting/index" />
|
||||||
<Stack.Screen name="voting/[status]/status" />
|
<Stack.Screen name="voting/[status]/status" />
|
||||||
<Stack.Screen name="voting/[id]/[status]/index" />
|
<Stack.Screen name="voting/[id]/[status]/index" />
|
||||||
<Stack.Screen name="voting/[id]/reject-input" />
|
<Stack.Screen name="voting/[id]/reject-input" /> */}
|
||||||
{/* ================== Voting End ================== */}
|
{/* ================== Voting End ================== */}
|
||||||
|
|
||||||
{/* ================== Event Start ================== */}
|
{/* ================== Event Start ================== */}
|
||||||
<Stack.Screen name="event/index" />
|
{/* <Stack.Screen name="event/index" />
|
||||||
<Stack.Screen name="event/[status]/status" />
|
<Stack.Screen name="event/[status]/status" />
|
||||||
<Stack.Screen name="event/type-of-event" />
|
<Stack.Screen name="event/type-of-event" />
|
||||||
<Stack.Screen name="event/type-create" />
|
<Stack.Screen name="event/type-create" />
|
||||||
<Stack.Screen name="event/type-update" />
|
<Stack.Screen name="event/type-update" /> */}
|
||||||
{/* <Stack.Screen name="event/[id]/[status]/index" />
|
{/* <Stack.Screen name="event/[id]/[status]/index" />
|
||||||
<Stack.Screen name="event/[id]/reject-input"/> */}
|
<Stack.Screen name="event/[id]/reject-input"/> */}
|
||||||
{/* ================== Event End ================== */}
|
{/* ================== Event End ================== */}
|
||||||
@@ -134,7 +140,11 @@ export default function AdminLayout() {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<NavbarMenu
|
<NavbarMenu
|
||||||
items={adminListMenu}
|
items={
|
||||||
|
user?.masterUserRoleId === "2"
|
||||||
|
? adminListMenu
|
||||||
|
: superAdminListMenu
|
||||||
|
}
|
||||||
onClose={() => setOpenDrawerNavbar(false)}
|
onClose={() => setOpenDrawerNavbar(false)}
|
||||||
/>
|
/>
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
@@ -155,7 +165,7 @@ export default function AdminLayout() {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<TextCustom>Username</TextCustom>
|
<TextCustom>{user?.username || "-"}</TextCustom>
|
||||||
</GridComponentView>
|
</GridComponentView>
|
||||||
<GridComponentView
|
<GridComponentView
|
||||||
leftIcon={
|
leftIcon={
|
||||||
@@ -166,7 +176,13 @@ export default function AdminLayout() {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<TextCustom>User Role</TextCustom>
|
<TextCustom>
|
||||||
|
{user
|
||||||
|
? user?.masterUserRoleId === "2"
|
||||||
|
? "Admin"
|
||||||
|
: "Super Admin"
|
||||||
|
: "-"}
|
||||||
|
</TextCustom>
|
||||||
</GridComponentView>
|
</GridComponentView>
|
||||||
|
|
||||||
<MenuDrawerDynamicGrid
|
<MenuDrawerDynamicGrid
|
||||||
|
|||||||
@@ -1,13 +1,31 @@
|
|||||||
import {
|
import { StackCustom, TextCustom, ViewWrapper } from "@/components";
|
||||||
StackCustom,
|
|
||||||
TextCustom,
|
|
||||||
ViewWrapper
|
|
||||||
} from "@/components";
|
|
||||||
import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard";
|
import AdminComp_BoxDashboard from "@/components/_ShareComponent/Admin/BoxDashboard";
|
||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import { apiAdminMainDashboardGetAll } from "@/service/api-admin/api-admin-main-dashboard";
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
export default function AdminDashboard() {
|
export default function AdminDashboard() {
|
||||||
|
const [countUser, setCountUser] = useState(0);
|
||||||
|
const [countPortofolio, setCountPortofolio] = useState(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminMainDashboardGetAll();
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setCountUser(response.data.user);
|
||||||
|
setCountPortofolio(response.data.portofolio);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR LOAD DATA]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ViewWrapper>
|
<ViewWrapper>
|
||||||
@@ -15,7 +33,7 @@ export default function AdminDashboard() {
|
|||||||
<TextCustom bold size={30}>
|
<TextCustom bold size={30}>
|
||||||
Main Dashboard
|
Main Dashboard
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
{listData.map((item, i) => (
|
{listData(countUser, countPortofolio).map((item, i) => (
|
||||||
<AdminComp_BoxDashboard key={i} item={item} />
|
<AdminComp_BoxDashboard key={i} item={item} />
|
||||||
))}
|
))}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
@@ -24,15 +42,15 @@ export default function AdminDashboard() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const listData = [
|
const listData = (countUser: number, countPortofolio: number) => [
|
||||||
{
|
{
|
||||||
label: "User",
|
label: "User",
|
||||||
value: 4,
|
value: countUser,
|
||||||
icon: <Ionicons name="people" size={30} color={MainColor.yellow} />,
|
icon: <Ionicons name="people" size={30} color={MainColor.yellow} />,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Portofolio",
|
label: "Portofolio",
|
||||||
value: 7,
|
value: countPortofolio,
|
||||||
icon: (
|
icon: (
|
||||||
<Ionicons name="id-card-outline" size={30} color={MainColor.yellow} />
|
<Ionicons name="id-card-outline" size={30} color={MainColor.yellow} />
|
||||||
),
|
),
|
||||||
|
|||||||
128
app/(application)/admin/super-admin/[id]/index.tsx
Normal file
128
app/(application)/admin/super-admin/[id]/index.tsx
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import {
|
||||||
|
BoxButtonOnFooter,
|
||||||
|
ButtonCustom,
|
||||||
|
LoaderCustom,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
|
import GridTwoView from "@/components/_ShareComponent/GridTwoView";
|
||||||
|
import {
|
||||||
|
apiAdminUserAccessGetById,
|
||||||
|
apiAdminUserAccessUpdateStatus,
|
||||||
|
} from "@/service/api-admin/api-admin-user-access";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
|
export default function SuperAdminDetail() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState<any | null>(null);
|
||||||
|
const [loadData, setLoadData] = useState(false);
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminUserAccessGetById({ id: id as string });
|
||||||
|
|
||||||
|
setData(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR LOAD DATA]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const response = await apiAdminUserAccessUpdateStatus({
|
||||||
|
id: id as string,
|
||||||
|
role: data?.masterUserRoleId === "2" ? "user" : "admin",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Update role gagal",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Update role berhasil ",
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR UPDATE STATUS]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ViewWrapper
|
||||||
|
headerComponent={<AdminBackButtonAntTitle title={`Detail User`} />}
|
||||||
|
footerComponent={
|
||||||
|
data && (
|
||||||
|
<BoxButtonOnFooter>
|
||||||
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
|
backgroundColor={
|
||||||
|
data?.masterUserRoleId === "2" ? "red" : "green"
|
||||||
|
}
|
||||||
|
textColor={"white"}
|
||||||
|
onPress={handlerSubmit}
|
||||||
|
>
|
||||||
|
{data?.masterUserRoleId === "2"
|
||||||
|
? "Hapus akses admin"
|
||||||
|
: "Tambah sebagai admin"}
|
||||||
|
</ButtonCustom>
|
||||||
|
</BoxButtonOnFooter>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{loadData ? (
|
||||||
|
<LoaderCustom />
|
||||||
|
) : (
|
||||||
|
<StackCustom>
|
||||||
|
{listData(data && data)?.map((item: any, index: number) => (
|
||||||
|
<GridTwoView
|
||||||
|
key={index}
|
||||||
|
spanLeft={4}
|
||||||
|
spanRight={8}
|
||||||
|
leftIcon={<TextCustom bold>{item?.label}</TextCustom>}
|
||||||
|
rightIcon={<TextCustom>{item?.value}</TextCustom>}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</StackCustom>
|
||||||
|
)}
|
||||||
|
</ViewWrapper>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const listData = (data: any) => [
|
||||||
|
{
|
||||||
|
label: "Username",
|
||||||
|
value: (data && data?.username) || "-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Role",
|
||||||
|
value: data && data?.masterUserRoleId === "2" ? "Admin" : "User",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Nomor",
|
||||||
|
value: (data && `+${data?.nomor}`) || "-",
|
||||||
|
},
|
||||||
|
];
|
||||||
148
app/(application)/admin/super-admin/index.tsx
Normal file
148
app/(application)/admin/super-admin/index.tsx
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import {
|
||||||
|
BadgeCustom,
|
||||||
|
CenterCustom,
|
||||||
|
Divider,
|
||||||
|
SearchInput,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
|
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
||||||
|
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
|
||||||
|
import { AccentColor, MainColor } from "@/constants/color-palet";
|
||||||
|
import { ICON_SIZE_XLARGE } from "@/constants/constans-value";
|
||||||
|
import { apiAdminUserAccessGetAll } from "@/service/api-admin/api-admin-user-access";
|
||||||
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
|
||||||
|
import { router, useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
|
export default function SuperAdmin_ListUser() {
|
||||||
|
const [listData, setListData] = useState<any[] | null>(null);
|
||||||
|
const [search, setSearch] = useState("");
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [search])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminUserAccessGetAll({
|
||||||
|
search: search,
|
||||||
|
category: "all-role",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR LOAD DATA]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const rightComponent = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SearchInput
|
||||||
|
containerStyle={{ width: "100%", marginBottom: 0 }}
|
||||||
|
placeholder="Cari Username"
|
||||||
|
onChangeText={(text) => setSearch(text)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ViewWrapper
|
||||||
|
headerComponent={
|
||||||
|
<AdminComp_BoxTitle
|
||||||
|
title={"Super Admin"}
|
||||||
|
rightComponent={rightComponent()}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<GridViewCustomSpan
|
||||||
|
span1={2}
|
||||||
|
span2={5}
|
||||||
|
span3={5}
|
||||||
|
component1={
|
||||||
|
<TextCustom align="center" bold>
|
||||||
|
Aksi
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
component2={
|
||||||
|
<TextCustom align="center" bold>
|
||||||
|
Username
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
component3={
|
||||||
|
<TextCustom align="center" bold>
|
||||||
|
Role
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
<StackCustom>
|
||||||
|
{_.isEmpty(listData) ? (
|
||||||
|
<TextCustom align="center" color="gray" size={"small"}>
|
||||||
|
Tidak ada data
|
||||||
|
</TextCustom>
|
||||||
|
) : (
|
||||||
|
listData?.map((item: any, index: number) => (
|
||||||
|
<GridViewCustomSpan
|
||||||
|
key={index}
|
||||||
|
span1={2}
|
||||||
|
span2={5}
|
||||||
|
span3={5}
|
||||||
|
component1={
|
||||||
|
<CenterCustom>
|
||||||
|
<Ionicons
|
||||||
|
onPress={() =>
|
||||||
|
router.push(`/admin/super-admin/${item?.id}`)
|
||||||
|
}
|
||||||
|
name="open"
|
||||||
|
size={ICON_SIZE_XLARGE}
|
||||||
|
color={MainColor.yellow}
|
||||||
|
/>
|
||||||
|
</CenterCustom>
|
||||||
|
|
||||||
|
// <ButtonCustom
|
||||||
|
// onPress={() =>
|
||||||
|
// router.push(`/admin/super-admin/${item?.id}`)
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// Detail
|
||||||
|
// </ButtonCustom>
|
||||||
|
}
|
||||||
|
component2={
|
||||||
|
<TextCustom bold truncate>
|
||||||
|
{item?.username || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
component3={
|
||||||
|
<CenterCustom>
|
||||||
|
{item?.masterUserRoleId === "2" ? (
|
||||||
|
<BadgeCustom color={AccentColor.blue}>Admin</BadgeCustom>
|
||||||
|
) : (
|
||||||
|
<BadgeCustom color={AccentColor.softblue}>
|
||||||
|
User
|
||||||
|
</BadgeCustom>
|
||||||
|
)}
|
||||||
|
</CenterCustom>
|
||||||
|
}
|
||||||
|
style3={{ alignItems: "center", justifyContent: "center" }}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
|
</ViewWrapper>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,117 +0,0 @@
|
|||||||
import {
|
|
||||||
ButtonCustom,
|
|
||||||
Divider,
|
|
||||||
Grid,
|
|
||||||
SearchInput,
|
|
||||||
StackCustom,
|
|
||||||
TextCustom,
|
|
||||||
ViewWrapper
|
|
||||||
} from "@/components";
|
|
||||||
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
|
||||||
import { MainColor } from "@/constants/color-palet";
|
|
||||||
import { ICON_SIZE_MEDIUM } from "@/constants/constans-value";
|
|
||||||
import { Ionicons } from "@expo/vector-icons";
|
|
||||||
|
|
||||||
export default function AdminUserAccess() {
|
|
||||||
const rightComponent = () => {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<SearchInput
|
|
||||||
containerStyle={{ width: "100%", marginBottom: 0 }}
|
|
||||||
placeholder="Cari User"
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<ViewWrapper
|
|
||||||
headerComponent={
|
|
||||||
<AdminComp_BoxTitle
|
|
||||||
title="User Access"
|
|
||||||
rightComponent={rightComponent()}
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<Grid>
|
|
||||||
<Grid.Col span={4} style={{ alignItems: "center" }}>
|
|
||||||
<TextCustom bold>Aksi</TextCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col span={4} style={{ alignItems: "center" }}>
|
|
||||||
<TextCustom bold>Username</TextCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col span={4} style={{ alignItems: "center" }}>
|
|
||||||
<TextCustom bold>Nomor</TextCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
</Grid>
|
|
||||||
|
|
||||||
<Divider />
|
|
||||||
|
|
||||||
<StackCustom>
|
|
||||||
{Array.from({ length: 10 }).map((_, index) => (
|
|
||||||
<Grid key={index}>
|
|
||||||
<Grid.Col
|
|
||||||
span={4}
|
|
||||||
style={{
|
|
||||||
alignItems: "center",
|
|
||||||
paddingLeft: 5,
|
|
||||||
paddingRight: 5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TextCustom bold>
|
|
||||||
<ButtonCustom
|
|
||||||
iconLeft={
|
|
||||||
<Ionicons
|
|
||||||
name={
|
|
||||||
index % 2 === 0
|
|
||||||
? "checkmark-outline"
|
|
||||||
: "close-circle-outline"
|
|
||||||
}
|
|
||||||
size={ICON_SIZE_MEDIUM}
|
|
||||||
color="black"
|
|
||||||
/>
|
|
||||||
}
|
|
||||||
onPress={() => {}}
|
|
||||||
backgroundColor={
|
|
||||||
index % 2 === 0 ? MainColor.green : MainColor.red
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<TextCustom size={"small"} color={"black"}>
|
|
||||||
{index % 2 === 0 ? "Berikan Akses" : "Hapus Akses"}
|
|
||||||
</TextCustom>
|
|
||||||
</ButtonCustom>
|
|
||||||
</TextCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col
|
|
||||||
span={4}
|
|
||||||
style={{
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
paddingLeft: 5,
|
|
||||||
paddingRight: 5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TextCustom bold truncate>
|
|
||||||
Useraname
|
|
||||||
</TextCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col
|
|
||||||
span={4}
|
|
||||||
style={{
|
|
||||||
alignItems: "center",
|
|
||||||
justifyContent: "center",
|
|
||||||
paddingLeft: 5,
|
|
||||||
paddingRight: 5,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<TextCustom bold truncate>
|
|
||||||
08123456789
|
|
||||||
</TextCustom>
|
|
||||||
</Grid.Col>
|
|
||||||
</Grid>
|
|
||||||
))}
|
|
||||||
</StackCustom>
|
|
||||||
</ViewWrapper>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
124
app/(application)/admin/user-access/[id]/index.tsx
Normal file
124
app/(application)/admin/user-access/[id]/index.tsx
Normal file
@@ -0,0 +1,124 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import {
|
||||||
|
BoxButtonOnFooter,
|
||||||
|
ButtonCustom,
|
||||||
|
LoaderCustom,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
|
import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle";
|
||||||
|
import GridTwoView from "@/components/_ShareComponent/GridTwoView";
|
||||||
|
import {
|
||||||
|
apiAdminUserAccessGetById,
|
||||||
|
apiAdminUserAccessUpdateStatus,
|
||||||
|
} from "@/service/api-admin/api-admin-user-access";
|
||||||
|
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
import Toast from "react-native-toast-message";
|
||||||
|
|
||||||
|
export default function AdminUserAccessDetail() {
|
||||||
|
const { id } = useLocalSearchParams();
|
||||||
|
const [data, setData] = useState<any | null>(null);
|
||||||
|
const [loadData, setLoadData] = useState(false);
|
||||||
|
const [isLoading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [id])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
setLoadData(true);
|
||||||
|
const response = await apiAdminUserAccessGetById({ id: id as string });
|
||||||
|
|
||||||
|
setData(response.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR LOAD DATA]", error);
|
||||||
|
} finally {
|
||||||
|
setLoadData(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handlerSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const response = await apiAdminUserAccessUpdateStatus({
|
||||||
|
id: id as string,
|
||||||
|
active: !data?.active,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.success) {
|
||||||
|
Toast.show({
|
||||||
|
type: "error",
|
||||||
|
text1: "Update aktifasi gagal",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Toast.show({
|
||||||
|
type: "success",
|
||||||
|
text1: "Update aktifasi berhasil ",
|
||||||
|
});
|
||||||
|
router.back();
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR UPDATE STATUS]", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ViewWrapper
|
||||||
|
headerComponent={<AdminBackButtonAntTitle title={`Detail User`} />}
|
||||||
|
footerComponent={
|
||||||
|
data && (
|
||||||
|
<BoxButtonOnFooter>
|
||||||
|
<ButtonCustom
|
||||||
|
isLoading={isLoading}
|
||||||
|
backgroundColor={data?.active ? "red" : "green"}
|
||||||
|
textColor={"white"}
|
||||||
|
onPress={handlerSubmit}
|
||||||
|
>
|
||||||
|
{data?.active ? "Hapus Akses" : "Berikan Akses"}
|
||||||
|
</ButtonCustom>
|
||||||
|
</BoxButtonOnFooter>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{loadData ? (
|
||||||
|
<LoaderCustom />
|
||||||
|
) : (
|
||||||
|
<StackCustom>
|
||||||
|
{listData(data && data)?.map((item: any, index: number) => (
|
||||||
|
<GridTwoView
|
||||||
|
key={index}
|
||||||
|
spanLeft={4}
|
||||||
|
spanRight={8}
|
||||||
|
leftIcon={<TextCustom bold>{item?.label}</TextCustom>}
|
||||||
|
rightIcon={<TextCustom>{item?.value}</TextCustom>}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</StackCustom>
|
||||||
|
)}
|
||||||
|
</ViewWrapper>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const listData = (data: any) => [
|
||||||
|
{
|
||||||
|
label: "Username",
|
||||||
|
value: (data && data?.username) || "-",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Aktivasi",
|
||||||
|
value: data && data?.active ? "Aktif" : "Tidak Aktif",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Nomor",
|
||||||
|
value: (data && `+${data?.nomor}`) || "-",
|
||||||
|
},
|
||||||
|
];
|
||||||
143
app/(application)/admin/user-access/index.tsx
Normal file
143
app/(application)/admin/user-access/index.tsx
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
import {
|
||||||
|
BadgeCustom,
|
||||||
|
CenterCustom,
|
||||||
|
Divider,
|
||||||
|
SearchInput,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom,
|
||||||
|
ViewWrapper,
|
||||||
|
} from "@/components";
|
||||||
|
import AdminComp_BoxTitle from "@/components/_ShareComponent/Admin/BoxTitlePage";
|
||||||
|
import { GridViewCustomSpan } from "@/components/_ShareComponent/GridViewCustomSpan";
|
||||||
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
import { ICON_SIZE_XLARGE } from "@/constants/constans-value";
|
||||||
|
import { apiAdminUserAccessGetAll } from "@/service/api-admin/api-admin-user-access";
|
||||||
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
import { router, useFocusEffect } from "expo-router";
|
||||||
|
import _ from "lodash";
|
||||||
|
import { useCallback, useState } from "react";
|
||||||
|
|
||||||
|
export default function AdminUserAccess() {
|
||||||
|
const [listData, setListData] = useState<any[] | null>(null);
|
||||||
|
const [search, setSearch] = useState("");
|
||||||
|
|
||||||
|
useFocusEffect(
|
||||||
|
useCallback(() => {
|
||||||
|
onLoadData();
|
||||||
|
}, [search])
|
||||||
|
);
|
||||||
|
|
||||||
|
const onLoadData = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiAdminUserAccessGetAll({
|
||||||
|
search: search,
|
||||||
|
category: "only-user",
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.success) {
|
||||||
|
setListData(response.data);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[ERROR LOAD DATA]", error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const rightComponent = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<SearchInput
|
||||||
|
containerStyle={{ width: "100%", marginBottom: 0 }}
|
||||||
|
placeholder="Cari User"
|
||||||
|
onChangeText={(text) => setSearch(text)}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<ViewWrapper
|
||||||
|
headerComponent={
|
||||||
|
<AdminComp_BoxTitle
|
||||||
|
title="User Access"
|
||||||
|
rightComponent={rightComponent()}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<GridViewCustomSpan
|
||||||
|
span1={2}
|
||||||
|
span2={5}
|
||||||
|
span3={5}
|
||||||
|
component1={
|
||||||
|
<TextCustom align="center" bold>
|
||||||
|
Aksi
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
component2={
|
||||||
|
<TextCustom align="center" bold>
|
||||||
|
Username
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
component3={
|
||||||
|
<TextCustom align="center" bold>
|
||||||
|
Status Akses
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
<StackCustom>
|
||||||
|
{_.isEmpty(listData) ? (
|
||||||
|
<TextCustom align="center" color="gray" size={"small"}>
|
||||||
|
Tidak ada data
|
||||||
|
</TextCustom>
|
||||||
|
) : (
|
||||||
|
listData?.map((item: any, index: number) => (
|
||||||
|
<GridViewCustomSpan
|
||||||
|
key={index}
|
||||||
|
span1={2}
|
||||||
|
span2={5}
|
||||||
|
span3={5}
|
||||||
|
component1={
|
||||||
|
<CenterCustom>
|
||||||
|
<Ionicons
|
||||||
|
onPress={() =>
|
||||||
|
router.push(`/admin/user-access/${item?.id}`)
|
||||||
|
}
|
||||||
|
name="open"
|
||||||
|
size={ICON_SIZE_XLARGE}
|
||||||
|
color={MainColor.yellow}
|
||||||
|
/>
|
||||||
|
</CenterCustom>
|
||||||
|
// <ButtonCustom
|
||||||
|
// onPress={() =>
|
||||||
|
// router.push(`/admin/user-access/${item?.id}`)
|
||||||
|
// }
|
||||||
|
// >
|
||||||
|
// Detail
|
||||||
|
// </ButtonCustom>
|
||||||
|
}
|
||||||
|
component2={
|
||||||
|
<TextCustom bold truncate>
|
||||||
|
{item?.username || "-"}
|
||||||
|
</TextCustom>
|
||||||
|
}
|
||||||
|
component3={
|
||||||
|
<CenterCustom>
|
||||||
|
{item?.active ? (
|
||||||
|
<BadgeCustom color="green">Aktif</BadgeCustom>
|
||||||
|
) : (
|
||||||
|
<BadgeCustom color="red">Tidak Aktif</BadgeCustom>
|
||||||
|
)}
|
||||||
|
</CenterCustom>
|
||||||
|
}
|
||||||
|
style3={{ alignItems: "center", justifyContent: "center" }}
|
||||||
|
/>
|
||||||
|
))
|
||||||
|
)}
|
||||||
|
</StackCustom>
|
||||||
|
</ViewWrapper>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import { MainColor } from "@/constants/color-palet";
|
import { MainColor } from "@/constants/color-palet";
|
||||||
import { Href, router } from "expo-router";
|
import { Href, router } from "expo-router";
|
||||||
import { DimensionValue, TouchableOpacity } from "react-native";
|
import { DimensionValue, StyleProp, TouchableOpacity, ViewStyle } from "react-native";
|
||||||
|
|
||||||
type SizeType = "xs" | "sm" | "md" | "lg" | "xl" | number | string | undefined;
|
type SizeType = "xs" | "sm" | "md" | "lg" | "xl" | number | string | undefined;
|
||||||
|
|
||||||
@@ -10,12 +10,14 @@ export default function ActionIcon({
|
|||||||
icon,
|
icon,
|
||||||
size = "md",
|
size = "md",
|
||||||
disabled = false,
|
disabled = false,
|
||||||
|
style,
|
||||||
}: {
|
}: {
|
||||||
href?: Href;
|
href?: Href;
|
||||||
onPress?: () => void;
|
onPress?: () => void;
|
||||||
icon: React.ReactNode;
|
icon: React.ReactNode;
|
||||||
size?: SizeType;
|
size?: SizeType;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
style?: StyleProp<ViewStyle>;
|
||||||
}) {
|
}) {
|
||||||
const sizeMap = {
|
const sizeMap = {
|
||||||
xs: 22,
|
xs: 22,
|
||||||
@@ -39,7 +41,7 @@ export default function ActionIcon({
|
|||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
activeOpacity={0.7}
|
activeOpacity={0.7}
|
||||||
style={{
|
style={[{
|
||||||
backgroundColor: disabled ? MainColor.disabled : MainColor.yellow,
|
backgroundColor: disabled ? MainColor.disabled : MainColor.yellow,
|
||||||
padding: 5,
|
padding: 5,
|
||||||
borderRadius: 50,
|
borderRadius: 50,
|
||||||
@@ -47,7 +49,7 @@ export default function ActionIcon({
|
|||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
width: iconSize,
|
width: iconSize,
|
||||||
height: iconSize,
|
height: iconSize,
|
||||||
}}
|
}, style]}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (disabled) return;
|
if (disabled) return;
|
||||||
if (href) {
|
if (href) {
|
||||||
|
|||||||
72
components/Button/CoyButton.tsx
Normal file
72
components/Button/CoyButton.tsx
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
import React, { useState } from "react";
|
||||||
|
import { TouchableOpacity, Text, StyleSheet } from "react-native";
|
||||||
|
import * as Clipboard from "expo-clipboard";
|
||||||
|
import { MainColor } from "@/constants/color-palet";
|
||||||
|
|
||||||
|
interface CopyButtonProps {
|
||||||
|
textToCopy: string;
|
||||||
|
copyLabel?: string; // Teks tombol saat normal, default: "Copy"
|
||||||
|
copiedLabel?: string; // Teks tombol saat berhasil, default: "Copied!"
|
||||||
|
onCopySuccess?: () => void; // Callback opsional saat berhasil menyalin
|
||||||
|
duration?: number; // Durasi (ms) menampilkan "Copied!", default: 2000
|
||||||
|
style?: any; // Gaya tambahan untuk tombol
|
||||||
|
textStyle?: any; // Gaya tambahan untuk teks
|
||||||
|
}
|
||||||
|
|
||||||
|
const CopyButton: React.FC<CopyButtonProps> = ({
|
||||||
|
textToCopy,
|
||||||
|
copyLabel = "Copy",
|
||||||
|
copiedLabel = "Copied!",
|
||||||
|
onCopySuccess,
|
||||||
|
duration = 2000,
|
||||||
|
style,
|
||||||
|
textStyle,
|
||||||
|
}) => {
|
||||||
|
const [isCopied, setIsCopied] = useState(false);
|
||||||
|
|
||||||
|
const handleCopy = async () => {
|
||||||
|
try {
|
||||||
|
await Clipboard.setStringAsync(textToCopy);
|
||||||
|
setIsCopied(true);
|
||||||
|
onCopySuccess?.();
|
||||||
|
|
||||||
|
// Reset kembali ke label "Copy" setelah durasi tertentu
|
||||||
|
setTimeout(() => {
|
||||||
|
setIsCopied(false);
|
||||||
|
}, duration);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Failed to copy text:", error);
|
||||||
|
// Opsional: tampilkan error toast jika diperlukan
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<TouchableOpacity
|
||||||
|
style={[styles.button, style]}
|
||||||
|
onPress={handleCopy}
|
||||||
|
activeOpacity={0.7}
|
||||||
|
>
|
||||||
|
<Text style={[styles.text, textStyle]}>
|
||||||
|
{isCopied ? copiedLabel : copyLabel}
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
button: {
|
||||||
|
backgroundColor: MainColor.yellow,
|
||||||
|
paddingHorizontal: 16,
|
||||||
|
paddingVertical: 8,
|
||||||
|
borderRadius: 50,
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
color: MainColor.darkblue,
|
||||||
|
fontWeight: "600",
|
||||||
|
fontSize: 14,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default CopyButton;
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
// components/MapComponent.js
|
// components/MapComponent.js
|
||||||
|
|
||||||
|
import API_IMAGE from "@/constants/api-storage";
|
||||||
|
import { Image } from "expo-image";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { DimensionValue, StyleSheet, View } from "react-native";
|
import { DimensionValue, StyleSheet, View } from "react-native";
|
||||||
import MapView, { Marker } from "react-native-maps";
|
import MapView, { Marker } from "react-native-maps";
|
||||||
@@ -10,6 +12,9 @@ interface MapComponentProps {
|
|||||||
latitudeDelta?: number;
|
latitudeDelta?: number;
|
||||||
longitudeDelta?: number;
|
longitudeDelta?: number;
|
||||||
height?: DimensionValue;
|
height?: DimensionValue;
|
||||||
|
namePin?: string;
|
||||||
|
imageId?: string;
|
||||||
|
onPress?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MapCustom = ({
|
const MapCustom = ({
|
||||||
@@ -18,6 +23,9 @@ const MapCustom = ({
|
|||||||
latitudeDelta = 0.1,
|
latitudeDelta = 0.1,
|
||||||
longitudeDelta = 0.1,
|
longitudeDelta = 0.1,
|
||||||
height = 300,
|
height = 300,
|
||||||
|
namePin = "Bali",
|
||||||
|
imageId,
|
||||||
|
onPress,
|
||||||
}: MapComponentProps) => {
|
}: MapComponentProps) => {
|
||||||
const initialRegion = {
|
const initialRegion = {
|
||||||
latitude,
|
latitude,
|
||||||
@@ -40,9 +48,22 @@ const MapCustom = ({
|
|||||||
latitude,
|
latitude,
|
||||||
longitude,
|
longitude,
|
||||||
}}
|
}}
|
||||||
title="Bali"
|
title={namePin}
|
||||||
description="Badung, Bali, Indonesia"
|
onPress={onPress}
|
||||||
/>
|
// Gunakan gambar kustom jika tersedia
|
||||||
|
>
|
||||||
|
<View style={{}}>
|
||||||
|
<Image
|
||||||
|
source={{ uri: API_IMAGE.GET({ fileId: imageId as string }) }}
|
||||||
|
style={{
|
||||||
|
width: 30,
|
||||||
|
height: 30,
|
||||||
|
borderRadius: 100,
|
||||||
|
borderWidth: 1,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
</Marker>
|
||||||
</MapView>
|
</MapView>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|||||||
79
components/Map/MapSelected.tsx
Normal file
79
components/Map/MapSelected.tsx
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { StyleSheet, View } from "react-native";
|
||||||
|
import MapView, { LatLng, Marker } from "react-native-maps";
|
||||||
|
|
||||||
|
interface MapSelectedProps {
|
||||||
|
initialRegion?: {
|
||||||
|
latitude?: number;
|
||||||
|
longitude?: number;
|
||||||
|
latitudeDelta?: number;
|
||||||
|
longitudeDelta?: number;
|
||||||
|
};
|
||||||
|
onLocationSelect?: (location: LatLng) => void;
|
||||||
|
height?: number; // Opsional: tinggi peta dalam piksel
|
||||||
|
selectedLocation: LatLng;
|
||||||
|
setSelectedLocation: (location: LatLng) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const MapSelected: React.FC<MapSelectedProps> = ({
|
||||||
|
initialRegion,
|
||||||
|
onLocationSelect,
|
||||||
|
selectedLocation,
|
||||||
|
setSelectedLocation,
|
||||||
|
height = 400, // Default height: 400
|
||||||
|
}) => {
|
||||||
|
const handleMapPress = (event: any) => {
|
||||||
|
const { latitude, longitude } = event.nativeEvent.coordinate;
|
||||||
|
const location = { latitude, longitude };
|
||||||
|
setSelectedLocation(location);
|
||||||
|
onLocationSelect?.(location);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Default region sesuai permintaan
|
||||||
|
const defaultRegion = {
|
||||||
|
latitude: -8.737109,
|
||||||
|
longitude: 115.1756897,
|
||||||
|
latitudeDelta: 0.1,
|
||||||
|
longitudeDelta: 0.1,
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={[styles.container, { height }]}>
|
||||||
|
<MapView
|
||||||
|
style={styles.map}
|
||||||
|
initialRegion={(initialRegion as any) || defaultRegion}
|
||||||
|
onPress={handleMapPress}
|
||||||
|
showsUserLocation={true}
|
||||||
|
showsMyLocationButton={true}
|
||||||
|
loadingEnabled={true}
|
||||||
|
loadingIndicatorColor="#666"
|
||||||
|
loadingBackgroundColor="#f0f0f0"
|
||||||
|
>
|
||||||
|
{selectedLocation && (
|
||||||
|
<Marker
|
||||||
|
coordinate={selectedLocation}
|
||||||
|
title="Lokasi Dipilih"
|
||||||
|
description={`Lat: ${selectedLocation.latitude.toFixed(
|
||||||
|
6
|
||||||
|
)}, Lng: ${selectedLocation.longitude.toFixed(6)}`}
|
||||||
|
pinColor="red"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
</MapView>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
width: "100%",
|
||||||
|
backgroundColor: "#f5f5f5",
|
||||||
|
overflow: "hidden",
|
||||||
|
borderRadius: 8,
|
||||||
|
},
|
||||||
|
map: {
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default MapSelected;
|
||||||
37
components/_ShareComponent/GridTwoView.tsx
Normal file
37
components/_ShareComponent/GridTwoView.tsx
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { ViewStyle } from "react-native";
|
||||||
|
import Grid from "../Grid/GridCustom";
|
||||||
|
|
||||||
|
export default function GridTwoView({
|
||||||
|
spanLeft = 6,
|
||||||
|
spanRight = 6,
|
||||||
|
leftIcon,
|
||||||
|
rightIcon,
|
||||||
|
styleLeft,
|
||||||
|
styleRight,
|
||||||
|
}: {
|
||||||
|
spanLeft?: number;
|
||||||
|
spanRight?: number;
|
||||||
|
leftIcon?: React.ReactNode;
|
||||||
|
rightIcon?: React.ReactNode;
|
||||||
|
styleLeft?: ViewStyle;
|
||||||
|
styleRight?: ViewStyle;
|
||||||
|
}) {
|
||||||
|
const baseStyle: ViewStyle = { justifyContent: "center" };
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Grid containerStyle={{ marginBottom: 0 }}>
|
||||||
|
<Grid.Col
|
||||||
|
span={spanLeft}
|
||||||
|
style={styleLeft ? { ...baseStyle, ...styleLeft } : baseStyle}
|
||||||
|
>
|
||||||
|
{leftIcon}
|
||||||
|
</Grid.Col>
|
||||||
|
<Grid.Col
|
||||||
|
span={spanRight}
|
||||||
|
style={styleRight ? { ...baseStyle, ...styleRight } : baseStyle}
|
||||||
|
>
|
||||||
|
{rightIcon}
|
||||||
|
</Grid.Col>
|
||||||
|
</Grid>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
import { Grid } from "@/components";
|
import { Grid } from "@/components";
|
||||||
|
import { StyleProp, ViewStyle } from "react-native";
|
||||||
|
|
||||||
export const GridViewCustomSpan = ({
|
export const GridViewCustomSpan = ({
|
||||||
span1,
|
span1,
|
||||||
@@ -7,31 +8,52 @@ export const GridViewCustomSpan = ({
|
|||||||
component1,
|
component1,
|
||||||
component2,
|
component2,
|
||||||
component3,
|
component3,
|
||||||
|
style1,
|
||||||
|
style2,
|
||||||
|
style3,
|
||||||
}: {
|
}: {
|
||||||
span1: number;
|
span1?: number;
|
||||||
span2: number;
|
span2?: number;
|
||||||
span3: number;
|
span3?: number;
|
||||||
component1: React.ReactNode;
|
component1: React.ReactNode;
|
||||||
component2: React.ReactNode;
|
component2: React.ReactNode;
|
||||||
component3: React.ReactNode;
|
component3: React.ReactNode;
|
||||||
|
style1?: StyleProp<ViewStyle>;
|
||||||
|
style2?: StyleProp<ViewStyle>;
|
||||||
|
style3?: StyleProp<ViewStyle>;
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col
|
<Grid.Col
|
||||||
span={span1 || 4}
|
span={span1 || 4}
|
||||||
style={{ justifyContent: "center", paddingRight: 5, paddingLeft: 5 }}
|
style={{
|
||||||
|
justifyContent: "center",
|
||||||
|
paddingRight: 10,
|
||||||
|
paddingLeft: 10,
|
||||||
|
...(style1 as object)
|
||||||
|
} as ViewStyle}
|
||||||
>
|
>
|
||||||
{component1}
|
{component1}
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col
|
<Grid.Col
|
||||||
span={span2 || 4}
|
span={span2 || 4}
|
||||||
style={{ justifyContent: "center", paddingRight: 5, paddingLeft: 5 }}
|
style={{
|
||||||
|
justifyContent: "center",
|
||||||
|
paddingRight: 10,
|
||||||
|
paddingLeft: 10,
|
||||||
|
...(style2 as object)
|
||||||
|
} as ViewStyle}
|
||||||
>
|
>
|
||||||
{component2}
|
{component2}
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
<Grid.Col
|
<Grid.Col
|
||||||
span={span3 || 4}
|
span={span3 || 4}
|
||||||
style={{ justifyContent: "center", paddingRight: 5, paddingLeft: 5 }}
|
style={{
|
||||||
|
justifyContent: "center",
|
||||||
|
paddingRight: 10,
|
||||||
|
paddingLeft: 10,
|
||||||
|
...(style3 as object)
|
||||||
|
} as ViewStyle}
|
||||||
>
|
>
|
||||||
{component3}
|
{component3}
|
||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
|
|||||||
118
components/_ShareComponent/MoneyTransferAnimation.tsx
Normal file
118
components/_ShareComponent/MoneyTransferAnimation.tsx
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
/* eslint-disable react-hooks/exhaustive-deps */
|
||||||
|
// MoneyTransferAnimation.tsx
|
||||||
|
import React from "react";
|
||||||
|
import { View, StyleSheet } from "react-native";
|
||||||
|
import { FontAwesome } from "@expo/vector-icons";
|
||||||
|
import Animated, {
|
||||||
|
useSharedValue,
|
||||||
|
useAnimatedStyle,
|
||||||
|
withTiming,
|
||||||
|
Easing,
|
||||||
|
runOnJS,
|
||||||
|
} from "react-native-reanimated";
|
||||||
|
import { AccentColor, MainColor } from "@/constants/color-palet";
|
||||||
|
import TextCustom from "../Text/TextCustom";
|
||||||
|
|
||||||
|
const SCREEN_WIDTH = 300; // Lebar area animasi
|
||||||
|
const DURATION = 2500; // Durasi sekali jalan (kiri → kanan)
|
||||||
|
|
||||||
|
const MoneyTransferAnimation: React.FC = () => {
|
||||||
|
const progress = useSharedValue(0);
|
||||||
|
const opacity = useSharedValue(0);
|
||||||
|
|
||||||
|
// Fungsi untuk mereset dan mulai ulang animasi
|
||||||
|
const startAnimation = () => {
|
||||||
|
progress.value = 0;
|
||||||
|
opacity.value = 0;
|
||||||
|
|
||||||
|
// Fade in di awal
|
||||||
|
opacity.value = withTiming(1, { duration: 300 });
|
||||||
|
|
||||||
|
// Gerak kiri → kanan
|
||||||
|
progress.value = withTiming(
|
||||||
|
1,
|
||||||
|
{
|
||||||
|
duration: DURATION,
|
||||||
|
easing: Easing.linear,
|
||||||
|
},
|
||||||
|
(finished) => {
|
||||||
|
if (finished) {
|
||||||
|
// Fade out di akhir
|
||||||
|
opacity.value = withTiming(0, { duration: 300 }, () => {
|
||||||
|
// Setelah fade out, ulangi
|
||||||
|
runOnJS(startAnimation)();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
React.useEffect(() => {
|
||||||
|
startAnimation();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const animatedStyle = useAnimatedStyle(() => {
|
||||||
|
return {
|
||||||
|
transform: [
|
||||||
|
{
|
||||||
|
translateX: progress.value * SCREEN_WIDTH,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
opacity: opacity.value,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<View style={styles.container}>
|
||||||
|
{/* Area animasi (track tidak wajib, tapi bisa ditambahkan) */}
|
||||||
|
<View style={styles.track} />
|
||||||
|
|
||||||
|
{/* Ikon uang animasi */}
|
||||||
|
<Animated.View style={[styles.iconContainer, animatedStyle]}>
|
||||||
|
<FontAwesome name="money" size={28} color="#2ecc71" />
|
||||||
|
</Animated.View>
|
||||||
|
|
||||||
|
{/* Teks status */}
|
||||||
|
<View style={styles.textContainer}>
|
||||||
|
<TextCustom bold>Transaksi Sedang Diproses</TextCustom>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
paddingVertical: 30,
|
||||||
|
position: "relative",
|
||||||
|
width: SCREEN_WIDTH,
|
||||||
|
},
|
||||||
|
track: {
|
||||||
|
position: "absolute",
|
||||||
|
top: 20,
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
height: 2,
|
||||||
|
backgroundColor: AccentColor.darkblue,
|
||||||
|
borderRadius: 1,
|
||||||
|
},
|
||||||
|
iconContainer: {
|
||||||
|
position: "absolute",
|
||||||
|
top: 4,
|
||||||
|
left: -30, // Mulai di luar kiri
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
textContainer: {
|
||||||
|
marginTop: 40,
|
||||||
|
},
|
||||||
|
text: {
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: "600",
|
||||||
|
color: MainColor.white,
|
||||||
|
textAlign: "center",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default MoneyTransferAnimation;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
// PdfViewer.tsx
|
// PdfViewer.tsx
|
||||||
import React, { useState } from "react";
|
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";
|
import WebView from "react-native-webview";
|
||||||
|
|
||||||
interface PdfViewerProps {
|
interface PdfViewerProps {
|
||||||
@@ -10,6 +10,13 @@ interface PdfViewerProps {
|
|||||||
const PdfViewer: React.FC<PdfViewerProps> = ({ uri }) => {
|
const PdfViewer: React.FC<PdfViewerProps> = ({ uri }) => {
|
||||||
const [loading, setLoading] = useState(true);
|
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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{loading && (
|
{loading && (
|
||||||
@@ -18,7 +25,9 @@ const PdfViewer: React.FC<PdfViewerProps> = ({ uri }) => {
|
|||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
<WebView
|
<WebView
|
||||||
source={{ uri }}
|
source={{
|
||||||
|
uri: selectedDivice,
|
||||||
|
}}
|
||||||
style={styles.webView}
|
style={styles.webView}
|
||||||
onLoadEnd={() => setLoading(false)}
|
onLoadEnd={() => setLoading(false)}
|
||||||
onError={(syntheticEvent) => {
|
onError={(syntheticEvent) => {
|
||||||
@@ -26,10 +35,10 @@ const PdfViewer: React.FC<PdfViewerProps> = ({ uri }) => {
|
|||||||
console.warn("WebView error:", nativeEvent);
|
console.warn("WebView error:", nativeEvent);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}}
|
}}
|
||||||
scalesPageToFit={true}
|
// scalesPageToFit={true}
|
||||||
javaScriptEnabled={true}
|
// javaScriptEnabled={true}
|
||||||
domStorageEnabled={true}
|
// domStorageEnabled={true}
|
||||||
originWhitelist={["*"]}
|
// originWhitelist={["*"]}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
4
constants/local-storage-key.ts
Normal file
4
constants/local-storage-key.ts
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
export const LOCAL_STORAGE_KEY = {
|
||||||
|
transactionInvestment: "transactionInvestment",
|
||||||
|
transactionDonation: "transactionDonation",
|
||||||
|
};
|
||||||
@@ -135,7 +135,7 @@ export const AuthProvider = ({ children }: { children: React.ReactNode }) => {
|
|||||||
const userData = async (token: string) => {
|
const userData = async (token: string) => {
|
||||||
try {
|
try {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
const response = await apiConfig.get(`/mobile/user?token=${token}`, {
|
const response = await apiConfig.get(`/mobile?token=${token}`, {
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,15 +17,15 @@ const listDataNotPublishInvesment = ({ data }: { data: any }) => [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Total Lembar",
|
label: "Total Lembar",
|
||||||
value: data?.totalLembar || "-",
|
value: formatCurrencyDisplay(data?.totalLembar) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Pencarian Investor",
|
label: "Pencarian Investor",
|
||||||
value: data && data?.MasterPencarianInvestor?.name + " hari" || "-",
|
value: (data && data?.MasterPencarianInvestor?.name + " hari") || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Jadwal Pembagian",
|
label: "Jadwal Pembagian",
|
||||||
value: data && data?.MasterPembagianDeviden?.name + " bulan" || "-",
|
value: (data && data?.MasterPembagianDeviden?.name + " bulan") || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Pembagian Deviden",
|
label: "Pembagian Deviden",
|
||||||
@@ -52,11 +52,11 @@ const listDataPublishInvesment = ({ data }: { data: any }) => [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Total Lembar",
|
label: "Total Lembar",
|
||||||
value: data?.totalLembar || "-",
|
value: formatCurrencyDisplay(data?.totalLembar) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Sisa Lembar",
|
label: "Sisa Lembar",
|
||||||
value: data?.sisaLembar || "-",
|
value: formatCurrencyDisplay(data?.sisaLembar) || "-",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Pencarian Investor",
|
label: "Pencarian Investor",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { NavbarItem } from "@/components/Drawer/NavbarMenu";
|
import { NavbarItem } from "@/components/Drawer/NavbarMenu";
|
||||||
|
|
||||||
export { adminListMenu }
|
export { adminListMenu, superAdminListMenu }
|
||||||
|
|
||||||
const adminListMenu: NavbarItem[] = [
|
const adminListMenu: NavbarItem[] = [
|
||||||
{
|
{
|
||||||
@@ -93,4 +93,102 @@ const adminListMenu: NavbarItem[] = [
|
|||||||
icon: "people",
|
icon: "people",
|
||||||
link: "/admin/user-access",
|
link: "/admin/user-access",
|
||||||
},
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const superAdminListMenu: NavbarItem[] = [
|
||||||
|
{
|
||||||
|
label: "Main Dashboard",
|
||||||
|
icon: "home",
|
||||||
|
link: "/admin/dashboard",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Investasi",
|
||||||
|
icon: "wallet",
|
||||||
|
links: [
|
||||||
|
{ label: "Dashboard", link: "/admin/investment" },
|
||||||
|
{ label: "Publish", link: "/admin/investment/publish/status" },
|
||||||
|
{ label: "Review", link: "/admin/investment/review/status" },
|
||||||
|
{ label: "Reject", link: "/admin/investment/reject/status" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Donasi",
|
||||||
|
icon: "hand-right",
|
||||||
|
links: [
|
||||||
|
{ label: "Dashboard", link: "/admin/donation" },
|
||||||
|
{ label: "Publish", link: "/admin/donation/publish/status" },
|
||||||
|
{ label: "Review", link: "/admin/donation/review/status" },
|
||||||
|
{ label: "Reject", link: "/admin/donation/reject/status" },
|
||||||
|
{ label: "Kategori", link: "/admin/donation/category" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Event",
|
||||||
|
icon: "calendar-clear",
|
||||||
|
links: [
|
||||||
|
{ label: "Dashboard", link: "/admin/event" },
|
||||||
|
{ label: "Publish", link: "/admin/event/publish/status" },
|
||||||
|
{ label: "Review", link: "/admin/event/review/status" },
|
||||||
|
{ label: "Reject", link: "/admin/event/reject/status" },
|
||||||
|
{ label: "Tipe Acara", link: "/admin/event/type-of-event" },
|
||||||
|
{ label: "Riwayat", link: "/admin/event/riwayat/status" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Voting",
|
||||||
|
icon: "accessibility-outline",
|
||||||
|
links: [
|
||||||
|
{ label: "Dashboard", link: "/admin/voting" },
|
||||||
|
{ label: "Publish", link: "/admin/voting/publish/status" },
|
||||||
|
{ label: "Review", link: "/admin/voting/review/status" },
|
||||||
|
{ label: "Reject", link: "/admin/voting/reject/status" },
|
||||||
|
{ label: "Riwayat", link: "/admin/voting/riwayat/status" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Job",
|
||||||
|
icon: "desktop-outline",
|
||||||
|
links: [
|
||||||
|
{ label: "Dashboard", link: "/admin/job" },
|
||||||
|
{ label: "Publish", link: "/admin/job/publish/status" },
|
||||||
|
{ label: "Review", link: "/admin/job/review/status" },
|
||||||
|
{ label: "Reject", link: "/admin/job/reject/status" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Forum",
|
||||||
|
icon: "chatbubble-ellipses-outline",
|
||||||
|
links: [
|
||||||
|
{ label: "Dashboard", link: "/admin/forum" },
|
||||||
|
{ label: "Posting", link: "/admin/forum/posting" },
|
||||||
|
{ label: "Report Posting", link: "/admin/forum/report-posting" },
|
||||||
|
{ label: "Report Comment", link: "/admin/forum/report-comment" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Collaboration",
|
||||||
|
icon: "people",
|
||||||
|
links: [
|
||||||
|
{ label: "Dashboard", link: "/admin/collaboration" },
|
||||||
|
{ label: "Publish", link: "/admin/collaboration/publish" },
|
||||||
|
{ label: "Group", link: "/admin/collaboration/group" },
|
||||||
|
{ label: "Reject", link: "/admin/collaboration/reject" },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{ label: "Maps", icon: "map", link: "/admin/maps" },
|
||||||
|
{
|
||||||
|
label: "App Information",
|
||||||
|
icon: "information-circle",
|
||||||
|
link: "/admin/app-information",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "User Access",
|
||||||
|
icon: "people",
|
||||||
|
link: "/admin/user-access",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Super Admin",
|
||||||
|
icon: "globe",
|
||||||
|
link: "/admin/super-admin",
|
||||||
|
},
|
||||||
];
|
];
|
||||||
@@ -8,27 +8,42 @@ import {
|
|||||||
} from "@/components";
|
} from "@/components";
|
||||||
import { View } from "react-native";
|
import { View } from "react-native";
|
||||||
|
|
||||||
export default function Donation_BoxPublish({ id }: { id: string }) {
|
export default function Donation_BoxPublish({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BaseBox paddingTop={7} paddingBottom={7} href={`/donation/${id}`}>
|
<BaseBox paddingTop={7} paddingBottom={7} href={`/donation/${id}`}>
|
||||||
<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>
|
||||||
<View>
|
<View style={{ gap: 10 }}>
|
||||||
<TextCustom truncate>
|
<TextCustom truncate={2} bold>
|
||||||
Judul Donasi: Lorem ipsum dolor sit amet consectetur
|
{data?.title || "-"}
|
||||||
adipisicing elit.
|
</TextCustom>
|
||||||
|
<TextCustom size="small">
|
||||||
|
Sisa hari: {data?.durasiDonasi || 0}
|
||||||
</TextCustom>
|
</TextCustom>
|
||||||
<TextCustom size="small">Sisa hari: 0</TextCustom>
|
|
||||||
</View>
|
</View>
|
||||||
<ProgressCustom value={(Number(id) % 5) * 20} size="lg" />
|
<ProgressCustom
|
||||||
|
label={data?.progres + "%" || "0%"}
|
||||||
|
value={data?.progres || 0}
|
||||||
|
size="lg"
|
||||||
|
/>
|
||||||
{/* <TextCustom>
|
{/* <TextCustom>
|
||||||
Terkumpul : Rp 300.000
|
Terkumpul : Rp 300.000
|
||||||
</TextCustom> */}
|
</TextCustom> */}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -11,13 +11,16 @@ import { ICON_SIZE_SMALL } from "@/constants/constans-value";
|
|||||||
import { Ionicons } from "@expo/vector-icons";
|
import { Ionicons } from "@expo/vector-icons";
|
||||||
|
|
||||||
export default function Donation_ComponentInfoFundrising({
|
export default function Donation_ComponentInfoFundrising({
|
||||||
id,
|
dataAuthor,
|
||||||
}: {
|
}: {
|
||||||
id: string;
|
dataAuthor: any;
|
||||||
}) {
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BaseBox href={`/donation/${id}/infromation-fundrising`} style={{paddingBottom: 0}}>
|
<BaseBox
|
||||||
|
href={`/donation/${dataAuthor?.id}/infromation-fundrising`}
|
||||||
|
style={{ paddingBottom: 0 }}
|
||||||
|
>
|
||||||
<StackCustom gap={"xs"}>
|
<StackCustom gap={"xs"}>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.Col span={10}>
|
<Grid.Col span={10}>
|
||||||
@@ -37,10 +40,12 @@ export default function Donation_ComponentInfoFundrising({
|
|||||||
</Grid.Col>
|
</Grid.Col>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<AvatarUsernameAndOtherComponent />
|
<AvatarUsernameAndOtherComponent
|
||||||
<InformationBox
|
avatar={dataAuthor?.Profile?.imageId}
|
||||||
text="Semua dana yang terkumpul akan disalurkan ke penggalang dana, kabar penyaluran dapat dilihat di halaman kabar terbaru."
|
name={dataAuthor?.username}
|
||||||
|
avatarHref={`/profile/${dataAuthor?.Profile?.id}`}
|
||||||
/>
|
/>
|
||||||
|
<InformationBox text="Semua dana yang terkumpul akan disalurkan ke penggalang dana, kabar penyaluran dapat dilihat di halaman kabar terbaru." />
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -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>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -8,11 +8,10 @@ export default function Investment_ButtonInvestasiSection({
|
|||||||
id: string;
|
id: string;
|
||||||
isMine: boolean;
|
isMine: boolean;
|
||||||
}) {
|
}) {
|
||||||
console.log("[IS MINE]", isMine);
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{isMine ? (
|
{isMine ? (
|
||||||
<ButtonCustom disabled>Investasi Ini Milik Anda</ButtonCustom>
|
<ButtonCustom disabled>Investasi ini milik Anda</ButtonCustom>
|
||||||
) : (
|
) : (
|
||||||
<ButtonCustom
|
<ButtonCustom
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
|||||||
@@ -1,12 +1,45 @@
|
|||||||
import { BaseBox, MapCustom, StackCustom, TextCustom } from "@/components";
|
import {
|
||||||
|
BaseBox,
|
||||||
|
MapCustom,
|
||||||
|
StackCustom,
|
||||||
|
TextCustom
|
||||||
|
} from "@/components";
|
||||||
|
|
||||||
export default function Portofolio_BusinessLocation() {
|
export default function Portofolio_BusinessLocation({
|
||||||
|
data,
|
||||||
|
imageId,
|
||||||
|
setOpenDrawerLocation,
|
||||||
|
}: {
|
||||||
|
data: any;
|
||||||
|
imageId?: string;
|
||||||
|
setOpenDrawerLocation: (value: boolean) => void;
|
||||||
|
}) {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BaseBox>
|
<BaseBox style={{ height: !data ? 200 : "auto" }}>
|
||||||
<StackCustom>
|
<StackCustom>
|
||||||
<TextCustom bold>Lokasi Bisnis</TextCustom>
|
<TextCustom bold>Lokasi Bisnis</TextCustom>
|
||||||
<MapCustom />
|
{!data ? (
|
||||||
|
<TextCustom
|
||||||
|
style={{ paddingTop: 50 }}
|
||||||
|
align="center"
|
||||||
|
color="gray"
|
||||||
|
size={"small"}
|
||||||
|
bold
|
||||||
|
>
|
||||||
|
Lokasi bisnis belum ditambahkan
|
||||||
|
</TextCustom>
|
||||||
|
) : (
|
||||||
|
<MapCustom
|
||||||
|
latitude={data?.latitude}
|
||||||
|
longitude={data?.longitude}
|
||||||
|
namePin={data?.namePin}
|
||||||
|
imageId={imageId}
|
||||||
|
onPress={() => {
|
||||||
|
setOpenDrawerLocation(true);
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</StackCustom>
|
</StackCustom>
|
||||||
</BaseBox>
|
</BaseBox>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -41,7 +41,11 @@ export default function Portofolio_Data({
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: (
|
icon: (
|
||||||
<Ionicons name="home-outline" size={ICON_SIZE_SMALL} color="white" />
|
<Ionicons
|
||||||
|
name="location-outline"
|
||||||
|
size={ICON_SIZE_SMALL}
|
||||||
|
color="white"
|
||||||
|
/>
|
||||||
),
|
),
|
||||||
label: data && data?.alamatKantor ? data.alamatKantor : "-",
|
label: data && data?.alamatKantor ? data.alamatKantor : "-",
|
||||||
},
|
},
|
||||||
@@ -89,8 +93,6 @@ export default function Portofolio_Data({
|
|||||||
// },
|
// },
|
||||||
// ];
|
// ];
|
||||||
|
|
||||||
// console.log("List Sub Bidang >>", JSON.stringify(listSubBidang, null, 2));
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<BaseBox>
|
<BaseBox>
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
import { IMenuDrawerItem } from "@/components/_Interface/types";
|
||||||
import { AccentColor } from "@/constants/color-palet";
|
import { AccentColor } from "@/constants/color-palet";
|
||||||
import { ICON_SIZE_MEDIUM } from "@/constants/constans-value";
|
import { ICON_SIZE_MEDIUM } from "@/constants/constans-value";
|
||||||
import { Ionicons, FontAwesome5, FontAwesome, Fontisto } from "@expo/vector-icons";
|
import {
|
||||||
|
FontAwesome,
|
||||||
|
Fontisto,
|
||||||
|
Ionicons
|
||||||
|
} from "@expo/vector-icons";
|
||||||
|
|
||||||
export const drawerItemsPortofolio = ({ id }: { id: string }): IMenuDrawerItem[] => [
|
export const drawerItemsPortofolio = ({
|
||||||
|
id,
|
||||||
|
maps,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
maps: any;
|
||||||
|
}): IMenuDrawerItem[] => [
|
||||||
{
|
{
|
||||||
icon: (
|
icon: (
|
||||||
<Ionicons
|
<Ionicons
|
||||||
@@ -45,18 +55,20 @@ export const drawerItemsPortofolio = ({ id }: { id: string }): IMenuDrawerItem[]
|
|||||||
color={AccentColor.white}
|
color={AccentColor.white}
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
label: "Edit Map",
|
label: `${!maps ? "Tambah" : "Edit"} Map`,
|
||||||
path: `/(application)/maps/${id}/edit`,
|
path: !maps
|
||||||
},
|
? `/(application)/maps/create?id=${id}`
|
||||||
{
|
: `/(application)/maps/${maps?.id}/edit`,
|
||||||
icon: (
|
|
||||||
<FontAwesome5
|
|
||||||
name="map-pin"
|
|
||||||
size={ICON_SIZE_MEDIUM}
|
|
||||||
color={AccentColor.white}
|
|
||||||
/>
|
|
||||||
),
|
|
||||||
label: "Custom Pin Map",
|
|
||||||
path: `/(application)/maps/${id}/custom-pin`,
|
|
||||||
},
|
},
|
||||||
|
// {
|
||||||
|
// icon: (
|
||||||
|
// <FontAwesome5
|
||||||
|
// name="map-pin"
|
||||||
|
// size={ICON_SIZE_MEDIUM}
|
||||||
|
// color={AccentColor.white}
|
||||||
|
// />
|
||||||
|
// ),
|
||||||
|
// label: "Custom Pin Map",
|
||||||
|
// path: `/(application)/maps/${id}/custom-pin`,
|
||||||
|
// },
|
||||||
];
|
];
|
||||||
|
|||||||
10
service/api-admin/api-admin-main-dashboard.ts
Normal file
10
service/api-admin/api-admin-main-dashboard.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { apiConfig } from "../api-config";
|
||||||
|
|
||||||
|
export const apiAdminMainDashboardGetAll = async () => {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/admin/main-dashboard`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
47
service/api-admin/api-admin-user-access.ts
Normal file
47
service/api-admin/api-admin-user-access.ts
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import { apiConfig } from "../api-config";
|
||||||
|
|
||||||
|
export const apiAdminUserAccessGetAll = async ({
|
||||||
|
search,
|
||||||
|
category,
|
||||||
|
}: {
|
||||||
|
search?: string;
|
||||||
|
category: "only-user" | "only-admin" | "all-role";
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/admin/user?category=${category}&search=${search}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const apiAdminUserAccessGetById = async ({ id }: { id: string }) => {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/admin/user/${id}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export const apiAdminUserAccessUpdateStatus = async ({
|
||||||
|
id,
|
||||||
|
active,
|
||||||
|
role,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
active?: boolean;
|
||||||
|
role?: "user" | "admin" | "super_admin";
|
||||||
|
}) => {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(`/mobile/admin/user/${id}`, {
|
||||||
|
data: {
|
||||||
|
active,
|
||||||
|
role,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
257
service/api-client/api-donation.ts
Normal file
257
service/api-client/api-donation.ts
Normal file
@@ -0,0 +1,257 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationUpdateData({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
category,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
category: "edit-donation" | "edit-story" | "edit-bank-account";
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(
|
||||||
|
`/mobile/donation/${id}?category=${category}`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationGetAll({
|
||||||
|
category,
|
||||||
|
authorId,
|
||||||
|
}: {
|
||||||
|
category: "beranda" | "my-donation";
|
||||||
|
authorId?: string;
|
||||||
|
}) {
|
||||||
|
const authorQuery = authorId ? `&authorId=${authorId}` : "";
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/donation?category=${category}${authorQuery}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationFundrising({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/donation/${id}/fundrising`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationCreateDonatur({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.post(`/mobile/donation/${id}/donatur`, {
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationCreateInvoice({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.post(`/mobile/donation/${id}/invoice`, {
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationGetInvoiceById({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/donation/${id}/invoice`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationUpdateInvoice({
|
||||||
|
id,
|
||||||
|
fileId,
|
||||||
|
status,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
fileId?: string;
|
||||||
|
status: "berhasil" | "gagal" | "proses" | "menunggu";
|
||||||
|
}) {
|
||||||
|
const statusQuery = `?status=${status}`;
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(
|
||||||
|
`/mobile/donation/${id}/invoice${statusQuery}`,
|
||||||
|
{
|
||||||
|
data: fileId,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationCreateNews({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.post(`/mobile/donation/${id}/news`, {
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationGetNewsById({
|
||||||
|
id,
|
||||||
|
category,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
category: "get-all" | "get-one";
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/donation/${id}/news?category=${category}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationUpdateNews({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(`/mobile/donation/${id}/news`, {
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiDonationDeleteNews({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.delete(`/mobile/donation/${id}/news`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -137,3 +137,107 @@ export async function apiInvestmentGetAll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function apiInvestmentCreateInvoice({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: any;
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.post(`/mobile/investment/${id}/invoice`, {
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiInvestmentGetInvoice({
|
||||||
|
id,
|
||||||
|
authorId,
|
||||||
|
category,
|
||||||
|
}: {
|
||||||
|
id?: string;
|
||||||
|
authorId?: string;
|
||||||
|
category: "my-invest" | "transaction" | "invoice";
|
||||||
|
}) {
|
||||||
|
const categoryQuery = `?category=${category}`;
|
||||||
|
const authorIdQuery = authorId ? `&authorId=${authorId}` : "";
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(
|
||||||
|
`/mobile/investment/${id}/invoice${categoryQuery}${authorIdQuery}`
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiInvestmentUpdateInvoice({
|
||||||
|
id,
|
||||||
|
data,
|
||||||
|
status,
|
||||||
|
}: {
|
||||||
|
id: string;
|
||||||
|
data: {
|
||||||
|
imageId?: string;
|
||||||
|
};
|
||||||
|
status: "berhasil" | "gagal" | "proses" | "menunggu";
|
||||||
|
}) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(
|
||||||
|
`/mobile/investment/${id}/invoice?status=${status}`,
|
||||||
|
{
|
||||||
|
data: data,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
41
service/api-client/api-maps.ts
Normal file
41
service/api-client/api-maps.ts
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
import { apiConfig } from "../api-config";
|
||||||
|
|
||||||
|
export async function apiMapsCreate({ data }: { data: any }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.post(`/mobile/maps`, {
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiMapsGetAll() {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get("/mobile/maps");
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiMapsGetOne({ id }: { id: string }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/maps/${id}`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function apiMapsUpdate({ id, data }: { id: string; data: any }) {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.put(`/mobile/maps/${id}`, {
|
||||||
|
data: data,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -110,7 +110,11 @@ export async function apiForumCreateReportCommentar({
|
|||||||
export async function apiMasterInvestment({
|
export async function apiMasterInvestment({
|
||||||
category,
|
category,
|
||||||
}: {
|
}: {
|
||||||
category?: "pencarian-investor" | "periode-deviden" | "pembagian-deviden" | string;
|
category?:
|
||||||
|
| "pencarian-investor"
|
||||||
|
| "periode-deviden"
|
||||||
|
| "pembagian-deviden"
|
||||||
|
| string;
|
||||||
}) {
|
}) {
|
||||||
const selectCategory = category ? `?category=${category}` : "";
|
const selectCategory = category ? `?category=${category}` : "";
|
||||||
try {
|
try {
|
||||||
@@ -122,3 +126,28 @@ export async function apiMasterInvestment({
|
|||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function apiMasterBank() {
|
||||||
|
try {
|
||||||
|
const response = await apiConfig.get(`/mobile/master/bank`);
|
||||||
|
return response.data;
|
||||||
|
} catch (error) {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
37
utils/openInDeviceMaps.ts
Normal file
37
utils/openInDeviceMaps.ts
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import { Platform, Linking, Alert } from "react-native";
|
||||||
|
|
||||||
|
export const openInDeviceMaps = async ({
|
||||||
|
latitude,
|
||||||
|
longitude,
|
||||||
|
title = "Lokasi",
|
||||||
|
}: {
|
||||||
|
latitude: number;
|
||||||
|
longitude: number;
|
||||||
|
title?: string;
|
||||||
|
}) => {
|
||||||
|
let url = "";
|
||||||
|
|
||||||
|
if (Platform.OS === "ios") {
|
||||||
|
// Apple Maps
|
||||||
|
url = `maps://?q=${encodeURIComponent(title)}&ll=${latitude},${longitude}`;
|
||||||
|
} else {
|
||||||
|
// Android: Google Maps
|
||||||
|
url = `geo:${latitude},${longitude}?q=${latitude},${longitude}(${encodeURIComponent(
|
||||||
|
title
|
||||||
|
)})`;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const canOpen = await Linking.canOpenURL(url);
|
||||||
|
if (canOpen) {
|
||||||
|
await Linking.openURL(url);
|
||||||
|
} else {
|
||||||
|
// Fallback ke web
|
||||||
|
const webUrl = `https://www.google.com/maps/search/?api=1&query=${latitude},${longitude}`;
|
||||||
|
await Linking.openURL(webUrl);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("Gagal membuka Maps:", error);
|
||||||
|
Alert.alert("Error", "Tidak dapat membuka aplikasi Maps.");
|
||||||
|
}
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user