Component
Fix: fix nama upload dan delete file service Invesment: Fix: - Edit data dan edit prospektus - View file dengan metode react-native-webview ### No issue
This commit is contained in:
@@ -44,7 +44,7 @@ export async function apiInvestmentUpdateStatus({
|
||||
id: string;
|
||||
status: "publish" | "draft" | "review" | "reject";
|
||||
}) {
|
||||
console.log("[DATA FETCH]", JSON.stringify({ id, status }, null, 2));
|
||||
|
||||
try {
|
||||
const response = await apiConfig.put(`/mobile/investment/${id}/${status}`);
|
||||
return response.data;
|
||||
@@ -65,12 +65,15 @@ export async function apiInvestmentDelete({ id }: { id: string }) {
|
||||
export async function apiInvestmentUpdateData({
|
||||
id,
|
||||
data,
|
||||
category,
|
||||
}: {
|
||||
id: string;
|
||||
data: any;
|
||||
category: "data" | "prospectus";
|
||||
}) {
|
||||
|
||||
try {
|
||||
const response = await apiConfig.put(`/mobile/investment/${id}`, {
|
||||
const response = await apiConfig.put(`/mobile/investment/${id}?category=${category}`, {
|
||||
data: data,
|
||||
});
|
||||
return response.data;
|
||||
|
||||
@@ -2,9 +2,9 @@ import { API_BASE_URL } from "@/service/api-config";
|
||||
import AsyncStorage from "@react-native-async-storage/async-storage";
|
||||
import { apiFileDelete, apiFileUpload } from "./api-client/api-file";
|
||||
|
||||
export async function uploadImageService({
|
||||
export async function uploadFileService({
|
||||
dirId,
|
||||
imageUri,
|
||||
imageUri: fileUri,
|
||||
}: {
|
||||
dirId: string;
|
||||
imageUri: string | null;
|
||||
@@ -14,12 +14,12 @@ export async function uploadImageService({
|
||||
|
||||
console.log("url >>", url);
|
||||
|
||||
if (!imageUri) {
|
||||
if (!fileUri) {
|
||||
throw new Error("Harap pilih gambar terlebih dahulu");
|
||||
}
|
||||
|
||||
try {
|
||||
const uri = imageUri;
|
||||
const uri = fileUri;
|
||||
const filename = uri.split("/").pop();
|
||||
const match = /\.(\w+)$/.exec(filename || "");
|
||||
const type = match ? `image/${match[1]}` : "image";
|
||||
@@ -50,7 +50,7 @@ export async function uploadImageService({
|
||||
}
|
||||
}
|
||||
|
||||
export async function deleteImageService({ id }: { id: string }) {
|
||||
export async function deleteFileService({ id }: { id: string }) {
|
||||
const token = await AsyncStorage.getItem("authToken");
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user