API Upload Image

Profile:
- (user)/profile/[id]/update-background.tsx : perbaikan api
-  app/(application)/(user)/profile/[id]/update-photo.tsx

Fix:
-   service/upload-service.ts : ganti Toast menjadi throw untuk dapatkna error

### No Issue
This commit is contained in:
2025-08-28 15:18:15 +08:00
parent d3c4f04e07
commit 40441c929f
7 changed files with 94 additions and 99 deletions

View File

@@ -15,6 +15,7 @@ import pickImage from "@/utils/pickImage";
import { router, useFocusEffect, useLocalSearchParams } from "expo-router";
import { useCallback, useState } from "react";
import { Image } from "react-native";
import Toast from "react-native-toast-message";
export default function UpdateBackgroundProfile() {
const { id } = useLocalSearchParams();
@@ -52,15 +53,35 @@ export default function UpdateBackgroundProfile() {
if (response.success) {
const fileId = response.data.id;
await apiUpdateProfile({
const responseUpdate = await apiUpdateProfile({
id: id as string,
data: { fileId },
category: "background",
});
if (!responseUpdate.success) {
Toast.show({
type: "error",
text1: "Info",
text2: responseUpdate.message,
});
return;
}
Toast.show({
type: "success",
text1: "Sukses",
text2: "Background berhasil diupdate",
});
router.back();
}
} catch (error) {
console.log("error upload >>", error);
Toast.show({
type: "error",
text1: "Gagal",
text2: error as string,
});
} finally {
setIsLoading(false);
}