diff --git a/client/src/components/Camera.jsx b/client/src/components/Camera.jsx
index ed1afc1..76690fc 100644
--- a/client/src/components/Camera.jsx
+++ b/client/src/components/Camera.jsx
@@ -74,9 +74,10 @@ const Camera = () => {
if (file) {
const reader = new FileReader();
reader.onload = (e) => {
- setCapturedPhoto(e.target.result);
+ const capturedImage = e.target.result;
+ setCapturedPhoto(capturedImage);
if (device === 'mobile'){
- submitPhoto().then(() => {
+ submitPhoto(capturedImage).then(() => {
setCapturedPhoto(null);
setIsUpdating(false);
});
@@ -86,11 +87,17 @@ const Camera = () => {
}
};
- const submitPhoto = async () => {
+ const submitPhoto = async (capturedMobileImage) => {
+ let imageData;
+ if(device === "desktop"){
+ imageData = capturedPhoto;
+ } else if (device === "mobile"){
+ imageData = capturedMobileImage
+ }
try {
setIsUpdating(true);
const url = import.meta.env.VITE_PROD_OCR_ENDPOINT;
- const formData = imageToFormData(capturedPhoto);
+ const formData = imageToFormData(imageData);
const init = {
method: 'POST',
body: formData,
@@ -115,7 +122,7 @@ const Camera = () => {
}
} catch (error) {
console.error('Error submitting photo:', error);
- alert('An error occurred while processing the image. Please try again.');
+ alert(`An error occurred while processing the image. Please try again ${error}`);
} finally {
setIsUpdating(false);
}
@@ -176,7 +183,6 @@ const Camera = () => {
)}
-
);