From 14c0f0e4994f9cd3648926bda5e59c76985b7a1f Mon Sep 17 00:00:00 2001 From: bagasbanuna Date: Tue, 20 Jan 2026 17:41:02 +0800 Subject: [PATCH] =?UTF-8?q?User=20=E2=80=93=20Investment?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit app/(application)/(user)/investment/(tabs)/_layout.tsx app/(application)/(user)/investment/(tabs)/portofolio.tsx app/(application)/(user)/investment/create.tsx Admin – Investment app/(application)/admin/investment/[id]/reject-input.tsx Screens / UI screens/Invesment/BoxBerandaSection.tsx API service/api-admin/api-admin-investment.ts Utils utils/pickFile.ts ### No Issue --- .../(user)/investment/(tabs)/_layout.tsx | 26 ++++++++- .../(user)/investment/(tabs)/portofolio.tsx | 6 +- .../(user)/investment/create.tsx | 9 ++- .../admin/investment/[id]/reject-input.tsx | 58 ++++++++++++------- screens/Invesment/BoxBerandaSection.tsx | 5 -- service/api-admin/api-admin-investment.ts | 3 +- utils/pickFile.ts | 54 +++++++++++++---- 7 files changed, 116 insertions(+), 45 deletions(-) diff --git a/app/(application)/(user)/investment/(tabs)/_layout.tsx b/app/(application)/(user)/investment/(tabs)/_layout.tsx index 0e49df0..9272ec9 100644 --- a/app/(application)/(user)/investment/(tabs)/_layout.tsx +++ b/app/(application)/(user)/investment/(tabs)/_layout.tsx @@ -1,9 +1,33 @@ +import BackButtonFromNotification from "@/components/Button/BackButtonFromNotification"; import { ICON_SIZE_SMALL } from "@/constants/constans-value"; import { TabsStyles } from "@/styles/tabs-styles"; import { Feather, FontAwesome6, Ionicons } from "@expo/vector-icons"; -import { Tabs } from "expo-router"; +import { router, Tabs, useLocalSearchParams, useNavigation } from "expo-router"; +import { useLayoutEffect } from "react"; export default function InvestmentTabsLayout() { + // const navigation = useNavigation(); + + // const { from, category } = useLocalSearchParams<{ + // from?: string; + // category?: string; + // }>(); + + // console.log("from", from); + // console.log("category", category); + + // // Atur header secara dinamis + // useLayoutEffect(() => { + // navigation.setOptions({ + // headerLeft: () => ( + // + // ), + // }); + // }, [from, router, navigation]); + return ( (); + const [activeCategory, setActiveCategory] = useState( - "publish" + status || "publish" ); const [listData, setListData] = useState([]); diff --git a/app/(application)/(user)/investment/create.tsx b/app/(application)/(user)/investment/create.tsx index ca64b6b..d7a9442 100644 --- a/app/(application)/(user)/investment/create.tsx +++ b/app/(application)/(user)/investment/create.tsx @@ -167,7 +167,7 @@ export default function InvestmentCreate() { text1: "Berhasil", text2: response.message, }); - router.replace("/investment/portofolio"); + router.replace("/investment/portofolio?status=review"); } else { Toast.show({ type: "error", @@ -224,7 +224,6 @@ export default function InvestmentCreate() { onPress={() => { pickFile({ setPdfUri: ({ uri, name, size }) => { - setPdf({ uri, name, size }); }, allowedType: "pdf", @@ -357,7 +356,11 @@ export default function InvestmentCreate() { )} - handleSubmit()}> + handleSubmit()} + > Simpan diff --git a/app/(application)/admin/investment/[id]/reject-input.tsx b/app/(application)/admin/investment/[id]/reject-input.tsx index c7361e0..444a973 100644 --- a/app/(application)/admin/investment/[id]/reject-input.tsx +++ b/app/(application)/admin/investment/[id]/reject-input.tsx @@ -7,34 +7,39 @@ import { } from "@/components"; import AdminBackButtonAntTitle from "@/components/_ShareComponent/Admin/BackButtonAntTitle"; import AdminButtonReject from "@/components/_ShareComponent/Admin/ButtonReject"; -import { apiAdminInvestasiUpdateByStatus, apiAdminInvestmentDetailById } from "@/service/api-admin/api-admin-investment"; +import { useAuth } from "@/hooks/use-auth"; +import { + apiAdminInvestasiUpdateByStatus, + apiAdminInvestmentDetailById, +} from "@/service/api-admin/api-admin-investment"; import { router, useFocusEffect, useLocalSearchParams } from "expo-router"; import { useCallback, useState } from "react"; import Toast from "react-native-toast-message"; export default function AdminInvestmentRejectInput() { + const { user } = useAuth(); const { id, status } = useLocalSearchParams(); console.log("[STATUS]", status); const [value, setValue] = useState(null); - const [isLoading , setLoading] = useState(false) + const [isLoading, setLoading] = useState(false); - useFocusEffect( - useCallback(() => { - onLoadData(); - }, [id]) - ); - - const onLoadData = async () => { - try { - const response = await apiAdminInvestmentDetailById({ id: id as string }); - console.log("[DATA]", JSON.stringify(response, null, 2)); - if (response.success) { - setValue(response.data?.catatan); - } - } catch (error) { - console.log(error); + useFocusEffect( + useCallback(() => { + onLoadData(); + }, [id]) + ); + + const onLoadData = async () => { + try { + const response = await apiAdminInvestmentDetailById({ id: id as string }); + console.log("[DATA]", JSON.stringify(response, null, 2)); + if (response.success) { + setValue(response.data?.catatan); } - }; + } catch (error) { + console.log(error); + } + }; const handlerSubmit = async () => { if (!value) { @@ -45,12 +50,23 @@ export default function AdminInvestmentRejectInput() { return; } + if (!user?.id) { + Toast.show({ + type: "error", + text1: "User tidak ditemukan", + }); + return; + } + try { - setLoading(true) + setLoading(true); const response = await apiAdminInvestasiUpdateByStatus({ id: id as string, status: "reject", - data: value, + data: { + catatan: value, + senderId: user?.id as string, + }, }); console.log("[RESPONSE]", JSON.stringify(response, null, 2)); @@ -76,7 +92,7 @@ export default function AdminInvestmentRejectInput() { } catch (error) { console.error(["ERROR"], error); } finally { - setLoading(false) + setLoading(false); } }; diff --git a/screens/Invesment/BoxBerandaSection.tsx b/screens/Invesment/BoxBerandaSection.tsx index 5e6292a..4113bb3 100644 --- a/screens/Invesment/BoxBerandaSection.tsx +++ b/screens/Invesment/BoxBerandaSection.tsx @@ -7,7 +7,6 @@ import { TextCustom, } from "@/components"; import API_STRORAGE from "@/constants/base-url-api-strorage"; -import { MainColor } from "@/constants/color-palet"; import DUMMY_IMAGE from "@/constants/dummy-image-value"; import { countDownAndCondition } from "@/utils/countDownAndCondition"; import { Ionicons } from "@expo/vector-icons"; @@ -22,8 +21,6 @@ export default function Investment_BoxBerandaSection({ id: string; data: any; }) { - // console.log("[DATA By one]", JSON.stringify(data, null, 2)); - const [value, setValue] = useState({ sisa: 0, reminder: false, @@ -33,8 +30,6 @@ export default function Investment_BoxBerandaSection({ updateCountDown(); }, [data]); - console.log("[DATA BERANDA]", JSON.stringify(data, null, 2)); - const updateCountDown = () => { const countDown = countDownAndCondition({ duration: data?.pencarianInvestor, diff --git a/service/api-admin/api-admin-investment.ts b/service/api-admin/api-admin-investment.ts index 5bb57d3..3709237 100644 --- a/service/api-admin/api-admin-investment.ts +++ b/service/api-admin/api-admin-investment.ts @@ -1,3 +1,4 @@ +import { typeRejectedData } from "@/types/type-collect-other"; import { apiConfig } from "../api-config"; export async function apiAdminInvestment({ @@ -38,7 +39,7 @@ export async function apiAdminInvestasiUpdateByStatus({ }: { id: string; status: "publish" | "review" | "reject"; - data: any; + data: typeRejectedData; }) { try { const response = await apiConfig.put( diff --git a/utils/pickFile.ts b/utils/pickFile.ts index 613a7d7..68f279c 100644 --- a/utils/pickFile.ts +++ b/utils/pickFile.ts @@ -1,6 +1,6 @@ import * as ImagePicker from "expo-image-picker"; import * as DocumentPicker from "expo-document-picker"; -import { Alert } from "react-native"; +import { Alert, Platform } from "react-native"; const ALLOWED_IMAGE_EXTENSIONS = ["jpg", "jpeg", "png"]; const MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB @@ -33,22 +33,52 @@ export default async function pickFile({ await pickImage(setImageUri, aspectRatio); } else { // Jika tidak, tawarkan pilihan rasio (default [4,3]) - showAspectRatioChoice(setImageUri); + // 🚀 Hanya tampilkan pilihan rasio di ANDROID + if (Platform.OS === "android") { + showAspectRatioChoice(setImageUri); + } else { + // iOS: langsung buka galeri dengan default [4, 3] + await pickImage(setImageUri, [4, 3]); + } } } else if (allowedType === "pdf") { await pickPdf(setPdfUri); } else { // Mode fleksibel: tampilkan pilihan - Alert.alert( - "Pilih Jenis File", - "Pilih sumber file yang ingin diunggah:", - [ - { text: "Batal", style: "cancel" }, - { text: "Dokumen (PDF)", onPress: () => pickPdf(setPdfUri) }, - { text: "Gambar", onPress: () => pickImage(setImageUri, aspectRatio) }, - ], - { cancelable: true } - ); + // Alert.alert( + // "Pilih Jenis File", + // "Pilih sumber file yang ingin diunggah:", + // [ + // { text: "Batal", style: "cancel" }, + // { text: "Dokumen (PDF)", onPress: () => pickPdf(setPdfUri) }, + // { text: "Gambar", onPress: () => pickImage(setImageUri, aspectRatio) }, + // ], + // { cancelable: true } + // ); + if (Platform.OS === "android") { + Alert.alert( + "Pilih Jenis File", + "Pilih sumber file yang ingin diunggah:", + [ + { text: "Batal", style: "cancel" }, + { text: "Dokumen (PDF)", onPress: () => pickPdf(setPdfUri) }, + { text: "Gambar", onPress: () => showAspectRatioChoice(setImageUri) }, + ], + { cancelable: true } + ); + } else { + // iOS: Langsung pakai default [4,3] untuk gambar + Alert.alert( + "Pilih Jenis File", + "Pilih sumber file yang ingin diunggah:", + [ + { text: "Batal", style: "cancel" }, + { text: "Dokumen (PDF)", onPress: () => pickPdf(setPdfUri) }, + { text: "Gambar", onPress: () => pickImage(setImageUri, [4, 3]) }, + ], + { cancelable: true } + ); + } } }