Fixed camera mounting issue. Separated media cache modal. Starting working on deleting images after upload. IO-397 IO-398

This commit is contained in:
Patrick Fic
2020-11-17 17:19:17 -08:00
parent 8fc357a6d9
commit ccb42548d0
5 changed files with 175 additions and 75 deletions

View File

@@ -9,7 +9,7 @@ import { axiosAuthInterceptorId } from "./CleanAxios";
var cleanAxios = axios.create();
cleanAxios.interceptors.request.eject(axiosAuthInterceptorId);
export const handleUpload = (ev, context) => {
export const handleUpload = async (ev, context) => {
const { onError, onSuccess, onProgress } = ev;
const { bodyshop, jobId } = context;
@@ -18,7 +18,7 @@ export const handleUpload = (ev, context) => {
""
)}`;
uploadToCloudinary(
return uploadToCloudinary(
key,
ev.file.type,
ev.file,
@@ -70,18 +70,14 @@ export const uploadToCloudinary = async (
);
} catch (error) {
console.log("ERROR GETTING SIGNED URL", error);
return;
return { success: false, error: error };
}
if (signedURLResponse.status !== 200) {
console.log("Error Getting Signed URL", signedURLResponse.statusText);
if (!!onError) onError(signedURLResponse.statusText);
// notification["error"]({
// message: i18n.t("documents.errors.getpresignurl", {
// message: signedURLResponse.statusText,
// }),
// });
return;
return { success: false, error: signedURLResponse.statusText };
}
//Build request to end to cloudinary.
@@ -94,11 +90,6 @@ export const uploadToCloudinary = async (
};
const formData = new FormData();
console.log("Sending!", {
uri: photo.uri,
type: fileType,
name: file.data.name,
});
formData.append("file", {
uri: photo.uri,
type: fileType,
@@ -126,6 +117,7 @@ export const uploadToCloudinary = async (
console.log("Cloudinary Upload Response", cloudinaryUploadResponse.data);
} catch (error) {
console.log("CLOUDINARY error", error, cloudinaryUploadResponse);
return { success: false, error: error };
}
if (cloudinaryUploadResponse.status !== 200) {
@@ -135,12 +127,7 @@ export const uploadToCloudinary = async (
cloudinaryUploadResponse
);
if (!!onError) onError(cloudinaryUploadResponse.statusText);
// notification["error"]({
// message: i18n.t("documents.errors.insert", {
// message: cloudinaryUploadResponse.statusText,
// }),
// });
return;
return { success: false, error: cloudinaryUploadResponse.statusText };
}
//Insert the document with the matching key.
@@ -179,6 +166,7 @@ export const uploadToCloudinary = async (
// message: JSON.stringify(JSON.stringify(documentInsert.errors)),
// }),
// });
return;
return { success: false, error: JSON.stringify(documentInsert.errors) };
}
return { success: true };
};