IOS-7 Added takenat to documents and uploads.
This commit is contained in:
@@ -5,6 +5,8 @@ import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { INSERT_NEW_DOCUMENT } from "../../graphql/documents.queries";
|
||||
import { axiosAuthInterceptorId } from "../../utils/CleanAxios";
|
||||
import client from "../../utils/GraphQLClient";
|
||||
import exifr from "exifr";
|
||||
|
||||
//Context: currentUserEmail, bodyshop, jobid, invoiceid
|
||||
|
||||
//Required to prevent headers from getting set and rejected from Cloudinary.
|
||||
@@ -85,6 +87,7 @@ export const uploadToCloudinary = async (
|
||||
if (!!onProgress) onProgress({ percent: (e.loaded / e.total) * 100 });
|
||||
},
|
||||
};
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
|
||||
@@ -122,6 +125,12 @@ export const uploadToCloudinary = async (
|
||||
}
|
||||
|
||||
//Insert the document with the matching key.
|
||||
let takenat;
|
||||
if (fileType.includes("image")) {
|
||||
const exif = await exifr.parse(file);
|
||||
console.log(`exif`, exif);
|
||||
takenat = exif && exif.DateTimeOriginal;
|
||||
}
|
||||
const documentInsert = await client.mutate({
|
||||
mutation: INSERT_NEW_DOCUMENT,
|
||||
variables: {
|
||||
@@ -135,6 +144,7 @@ export const uploadToCloudinary = async (
|
||||
extension: extension,
|
||||
bodyshopid: bodyshop.id,
|
||||
size: cloudinaryUploadResponse.data.bytes || file.size,
|
||||
takenat,
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
@@ -9,15 +9,13 @@ export const GET_DOCUMENTS_BY_JOB = gql`
|
||||
}
|
||||
}
|
||||
}
|
||||
documents(
|
||||
order_by: { updated_at: desc }
|
||||
where: { jobid: { _eq: $jobId } }
|
||||
) {
|
||||
documents(order_by: { takenat: desc }, where: { jobid: { _eq: $jobId } }) {
|
||||
id
|
||||
name
|
||||
key
|
||||
type
|
||||
size
|
||||
takenat
|
||||
bill {
|
||||
id
|
||||
invoice_number
|
||||
@@ -51,6 +49,7 @@ export const INSERT_NEW_DOCUMENT = gql`
|
||||
name
|
||||
key
|
||||
size
|
||||
takenat
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -78,6 +77,7 @@ export const QUERY_TEMPORARY_DOCS = gql`
|
||||
type
|
||||
extension
|
||||
size
|
||||
takenat
|
||||
}
|
||||
}
|
||||
`;
|
||||
@@ -94,6 +94,7 @@ export const UPDATE_DOCUMENT = gql`
|
||||
type
|
||||
key
|
||||
size
|
||||
takenat
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
Reference in New Issue
Block a user