Capture Photo Info & Change Env Dynamically.
This commit is contained in:
3
App.js
3
App.js
@@ -11,8 +11,7 @@ import { persistor, store } from "./redux/store";
|
||||
import "./translations/i18n";
|
||||
|
||||
Sentry.init({
|
||||
dsn:
|
||||
"https://8d6c3de1940a4e4f8b81cf4d2150bdea@o492140.ingest.sentry.io/5558869",
|
||||
dsn: "https://8d6c3de1940a4e4f8b81cf4d2150bdea@o492140.ingest.sentry.io/5558869",
|
||||
enableInExpoDevelopment: true,
|
||||
// debug: true, // Sentry will try to print out useful debugging information if something goes wrong with sending an event. Set this to `false` in production.
|
||||
});
|
||||
|
||||
@@ -32,6 +32,8 @@ export default function JobDocumentsComponent({ job, loading, refetch }) {
|
||||
[job.documents]
|
||||
);
|
||||
|
||||
console.log(job.documents);
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<FlatList
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import { useApolloClient } from "@apollo/client";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
//const limit = plimit(2);
|
||||
import * as FileSystem from "expo-file-system";
|
||||
import { AssetsSelector } from "expo-images-picker";
|
||||
import * as MediaLibrary from "expo-media-library";
|
||||
import _ from "lodash";
|
||||
import React, { useCallback, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { StyleSheet, Text, View, Alert } from "react-native";
|
||||
import { Alert, StyleSheet, Text, View } from "react-native";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.analytics";
|
||||
import { GET_DOC_SIZE_TOTALS } from "../../graphql/documents.queries";
|
||||
import {
|
||||
selectCurrentCameraJobId,
|
||||
selectDeleteAfterUpload,
|
||||
@@ -21,9 +24,6 @@ import { handleUpload } from "../../util/document-upload.utility";
|
||||
import CameraSelectJob from "../camera-select-job/camera-select-job.component";
|
||||
import UploadDeleteSwitch from "../upload-delete-switch/upload-delete-switch.component";
|
||||
import UploadProgress from "../upload-progress/upload-progress.component";
|
||||
import { GET_DOC_SIZE_TOTALS } from "../../graphql/documents.queries";
|
||||
//const limit = plimit(2);
|
||||
import * as FileSystem from "expo-file-system";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
@@ -76,7 +76,7 @@ export function ImageBrowserScreen({
|
||||
const info = await FileSystem.getInfoAsync(val.uri, { size: true });
|
||||
return (await acc) + info.size;
|
||||
}, 0);
|
||||
console.log("data :>> ", data);
|
||||
|
||||
console.log(
|
||||
"Size of uploaded documents.",
|
||||
queryData.data.documents_aggregate.aggregate.sum.size,
|
||||
@@ -108,6 +108,7 @@ export function ImageBrowserScreen({
|
||||
let filename;
|
||||
//Appears to work for android.
|
||||
//iOS provides the filename, android doe snot.
|
||||
console.log("pid", p.id);
|
||||
filename = p.filename || p.uri.split("/").pop();
|
||||
const result = await handleUpload(
|
||||
{
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
selectSigningIn,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import SignInErrorAlertComponent from "../sign-in-error-alert/sign-in-error-alert.component";
|
||||
import Constants from "expo-constants";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
@@ -73,6 +74,12 @@ export function SignIn({ emailSignInStart, signingIn }) {
|
||||
<Button mode="outlined" loading={signingIn} onPress={handleSubmit}>
|
||||
<Text>{t("signin.actions.signin")}</Text>
|
||||
</Button>
|
||||
<Text>
|
||||
{t("settings.labels.version", {
|
||||
number: Constants.manifest.version,
|
||||
})}{" "}
|
||||
{process.env.NODE_ENV || ""}
|
||||
</Text>
|
||||
</View>
|
||||
)}
|
||||
</Formik>
|
||||
|
||||
64
env.js
64
env.js
@@ -1,47 +1,28 @@
|
||||
import Constants from "expo-constants";
|
||||
|
||||
export const prodUrl = "https://someapp.herokuapp.com";
|
||||
|
||||
const ENV = {
|
||||
dev: {
|
||||
API_URL: "https://api.imex.online",
|
||||
API_URL: "https://api.test.imex.online",
|
||||
uri: "https://db.test.bodyshop.app/v1/graphql",
|
||||
wsuri: "wss://db.test.bodyshop.app/v1/graphql",
|
||||
REACT_APP_CLOUDINARY_ENDPOINT_API:
|
||||
"https://api.cloudinary.com/v1_1/bodyshop",
|
||||
REACT_APP_CLOUDINARY_ENDPOINT: "https://res.cloudinary.com/bodyshop",
|
||||
REACT_APP_CLOUDINARY_API_KEY: "473322739956866",
|
||||
REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS: "c_fill,f_auto,h_250,w_250",
|
||||
firebase: {
|
||||
apiKey: "AIzaSyBw7_GTy7GtQyfkIRPVrWHEGKfcqeyXw0c",
|
||||
authDomain: "imex-test.firebaseapp.com",
|
||||
projectId: "imex-test",
|
||||
storageBucket: "imex-test.appspot.com",
|
||||
messagingSenderId: "991923618608",
|
||||
appId: "1:991923618608:web:633437569cdad78299bef5",
|
||||
measurementId: "G-TW0XLZEH18",
|
||||
},
|
||||
},
|
||||
|
||||
REACT_APP_CLOUDINARY_ENDPOINT_API:
|
||||
"https://api.cloudinary.com/v1_1/bodyshop",
|
||||
REACT_APP_CLOUDINARY_ENDPOINT: "https://res.cloudinary.com/bodyshop",
|
||||
REACT_APP_CLOUDINARY_API_KEY: "473322739956866",
|
||||
REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS: "c_fill,f_auto,h_250,w_250",
|
||||
firebase: {
|
||||
apiKey: "AIzaSyDPLT8GiDHDR1R4nI66Qi0BY1aYviDPioc",
|
||||
authDomain: "imex-dev.firebaseapp.com",
|
||||
databaseURL: "https://imex-dev.firebaseio.com",
|
||||
projectId: "imex-dev",
|
||||
storageBucket: "imex-dev.appspot.com",
|
||||
messagingSenderId: "759548147434",
|
||||
appId: "1:759548147434:web:e8239868a48ceb36700993",
|
||||
measurementId: "G-K5XRBVVB4S",
|
||||
},
|
||||
},
|
||||
staging: {
|
||||
API_URL: "https://api.imex.online",
|
||||
REACT_APP_CLOUDINARY_ENDPOINT_API:
|
||||
"https://api.cloudinary.com/v1_1/bodyshop",
|
||||
REACT_APP_CLOUDINARY_ENDPOINT: "https://res.cloudinary.com/bodyshop",
|
||||
REACT_APP_CLOUDINARY_API_KEY: "473322739956866",
|
||||
REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS: "c_fill,f_auto,h_250,w_250",
|
||||
firebase: {
|
||||
apiKey: "AIzaSyDSezy-jGJreo7ulgpLdlpOwAOrgcaEkhU",
|
||||
authDomain: "imex-prod.firebaseapp.com",
|
||||
databaseURL: "https://imex-prod.firebaseio.com",
|
||||
projectId: "imex-prod",
|
||||
storageBucket: "imex-prod.appspot.com",
|
||||
messagingSenderId: "253497221485",
|
||||
appId: "1:253497221485:web:3c81c483b94db84b227a64",
|
||||
measurementId: "G-NTWBKG2L0M",
|
||||
},
|
||||
},
|
||||
prod: {
|
||||
API_URL: "https://api.imex.online",
|
||||
uri: "https://db.imex.online/v1/graphql",
|
||||
wsuri: "wss://db.imex.online/v1/graphql",
|
||||
REACT_APP_CLOUDINARY_ENDPOINT_API:
|
||||
"https://api.cloudinary.com/v1_1/bodyshop",
|
||||
REACT_APP_CLOUDINARY_ENDPOINT: "https://res.cloudinary.com/bodyshop",
|
||||
@@ -60,7 +41,8 @@ const ENV = {
|
||||
},
|
||||
};
|
||||
|
||||
function getEnvVars(env = "") {
|
||||
function getEnvVars() {
|
||||
let env = process.env.NODE_ENV;
|
||||
if (env === null || env === undefined || env === "") return ENV.dev;
|
||||
if (env.indexOf("dev") !== -1) return ENV.dev;
|
||||
if (env.indexOf("staging") !== -1) return ENV.staging;
|
||||
@@ -68,4 +50,4 @@ function getEnvVars(env = "") {
|
||||
else return ENV.prod;
|
||||
}
|
||||
|
||||
export default getEnvVars(Constants.manifest.releaseChannel);
|
||||
export default getEnvVars();
|
||||
|
||||
@@ -1,31 +1,11 @@
|
||||
import * as firebase from "firebase/app";
|
||||
import "firebase/auth";
|
||||
import env from "../env";
|
||||
|
||||
//const config = JSON.parse(process.env.REACT_APP_FIREBASE_CONFIG);
|
||||
// const config = {
|
||||
// apiKey: "AIzaSyDPLT8GiDHDR1R4nI66Qi0BY1aYviDPioc",
|
||||
// authDomain: "imex-dev.firebaseapp.com",
|
||||
// databaseURL: "https://imex-dev.firebaseio.com",
|
||||
// projectId: "imex-dev",
|
||||
// storageBucket: "imex-dev.appspot.com",
|
||||
// messagingSenderId: "759548147434",
|
||||
// appId: "1:759548147434:web:e8239868a48ceb36700993",
|
||||
// measurementId: "G-K5XRBVVB4S",
|
||||
// };
|
||||
|
||||
const config = {
|
||||
apiKey: "AIzaSyDSezy-jGJreo7ulgpLdlpOwAOrgcaEkhU",
|
||||
authDomain: "imex-prod.firebaseapp.com",
|
||||
databaseURL: "https://imex-prod.firebaseio.com",
|
||||
projectId: "imex-prod",
|
||||
storageBucket: "imex-prod.appspot.com",
|
||||
messagingSenderId: "253497221485",
|
||||
appId: "1:253497221485:web:3c81c483b94db84b227a64",
|
||||
measurementId: "G-NTWBKG2L0M",
|
||||
};
|
||||
console.log(env.firebase);
|
||||
|
||||
if (!firebase.apps.length) {
|
||||
firebase.initializeApp(config);
|
||||
firebase.initializeApp(env.firebase);
|
||||
}
|
||||
|
||||
export const auth = firebase.auth();
|
||||
|
||||
@@ -12,10 +12,10 @@ import { RetryLink } from "@apollo/client/link/retry";
|
||||
import { WebSocketLink } from "@apollo/client/link/ws";
|
||||
import { getMainDefinition } from "@apollo/client/utilities";
|
||||
import { auth } from "../firebase/firebase.utils";
|
||||
|
||||
import env from "../env";
|
||||
const httpLink = new HttpLink({
|
||||
// uri: "https://bodyshop-dev-db.herokuapp.com/v1/graphql",
|
||||
uri: "https://db.imex.online/v1/graphql",
|
||||
uri: env.uri,
|
||||
});
|
||||
|
||||
const wsLink = new WebSocketLink({
|
||||
|
||||
@@ -21,11 +21,12 @@ export const GET_DOCUMENTS_BY_JOB = gql`
|
||||
}
|
||||
}
|
||||
}
|
||||
documents(order_by: { updated_at: desc }) {
|
||||
documents(order_by: { takenat: desc }) {
|
||||
id
|
||||
name
|
||||
key
|
||||
type
|
||||
takenat
|
||||
bill {
|
||||
id
|
||||
invoice_number
|
||||
|
||||
@@ -212,7 +212,7 @@ export const GET_JOB_BY_PK = gql`
|
||||
updated_at
|
||||
created_by
|
||||
}
|
||||
documents(order_by: { created_at: desc }) {
|
||||
documents(order_by: { takenat: desc }) {
|
||||
id
|
||||
name
|
||||
key
|
||||
@@ -303,7 +303,7 @@ export const QUERY_JOB_CARD_DETAILS = gql`
|
||||
start
|
||||
scheduledreturn
|
||||
}
|
||||
documents(limit: 3, order_by: { created_at: desc }) {
|
||||
documents(limit: 3, order_by: { takenat: desc }) {
|
||||
id
|
||||
key
|
||||
}
|
||||
@@ -372,7 +372,7 @@ export const QUERY_TECH_JOB_DETAILS = gql`
|
||||
created_at
|
||||
}
|
||||
updated_at
|
||||
documents(order_by: { created_at: desc }) {
|
||||
documents(order_by: { takenat: desc }) {
|
||||
id
|
||||
key
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ import env from "../env";
|
||||
import { client } from "../graphql/client";
|
||||
import { INSERT_NEW_DOCUMENT } from "../graphql/documents.queries";
|
||||
import { axiosAuthInterceptorId } from "./CleanAxios";
|
||||
import * as MediaLibrary from "expo-media-library";
|
||||
|
||||
//Context: currentUserEmail, bodyshop, jobid, invoiceid
|
||||
|
||||
//Required to prevent headers from getting set and rejected from Cloudinary.
|
||||
@@ -45,15 +47,8 @@ export const uploadToCloudinary = async (
|
||||
onProgress,
|
||||
context
|
||||
) => {
|
||||
const {
|
||||
bodyshop,
|
||||
jobId,
|
||||
billId,
|
||||
uploaded_by,
|
||||
callback,
|
||||
tagsArray,
|
||||
photo,
|
||||
} = context;
|
||||
const { bodyshop, jobId, billId, uploaded_by, callback, tagsArray, photo } =
|
||||
context;
|
||||
|
||||
//Set variables for getting the signed URL.
|
||||
let timestamp = Math.floor(Date.now() / 1000);
|
||||
@@ -139,7 +134,12 @@ export const uploadToCloudinary = async (
|
||||
if (onError) onError(cloudinaryUploadResponse.statusText);
|
||||
return { success: false, error: cloudinaryUploadResponse.statusText };
|
||||
}
|
||||
|
||||
console.log("mediaId", mediaId);
|
||||
const imageData = await MediaLibrary.getAssetInfoAsync(mediaId);
|
||||
console.log(
|
||||
"🚀 ~ file: document-upload.utility.js ~ line 140 ~ imageData",
|
||||
imageData.creationTime
|
||||
);
|
||||
//Insert the document with the matching key.
|
||||
const documentInsert = await client.mutate({
|
||||
mutation: INSERT_NEW_DOCUMENT,
|
||||
@@ -154,6 +154,9 @@ export const uploadToCloudinary = async (
|
||||
extension: extension,
|
||||
bodyshopid: bodyshop.id,
|
||||
size: cloudinaryUploadResponse.data.bytes || file.size,
|
||||
...(imageData.creationTime
|
||||
? { takenat: new Date(imageData.creationTime) }
|
||||
: {}),
|
||||
},
|
||||
],
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user