From b6155c6a85f22c62b56de1c355a2217dd16e7452 Mon Sep 17 00:00:00 2001
From: Patrick Fic <>
Date: Thu, 13 May 2021 09:39:29 -0700
Subject: [PATCH] Resolve issue for temp uploads & add search.
---
babel-translations.babel | 42 +++++++
.../camera-select-job.component.jsx | 20 +--
.../data-label/data-label.component.jsx | 6 +-
components/job-lines/job-lines.component.jsx | 117 +++++++++---------
components/job-list/job-list.component.jsx | 66 ++++++++--
.../screen-media-browser.component.jsx | 72 +++++------
graphql/client.js | 11 +-
graphql/jobs.queries.js | 69 +----------
translations/en-US/common.json | 4 +-
translations/es-MX/common.json | 4 +-
translations/fr-CA/common.json | 4 +-
11 files changed, 230 insertions(+), 185 deletions(-)
diff --git a/babel-translations.babel b/babel-translations.babel
index e2eb8e5..30d4d18 100644
--- a/babel-translations.babel
+++ b/babel-translations.babel
@@ -1085,6 +1085,27 @@
actions
+
+ refresh
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
swipecamera
false
@@ -1153,6 +1174,27 @@
+
+ nojobs
+ false
+
+
+
+
+
+ en-US
+ false
+
+
+ es-MX
+ false
+
+
+ fr-CA
+ false
+
+
+
diff --git a/components/camera-select-job/camera-select-job.component.jsx b/components/camera-select-job/camera-select-job.component.jsx
index bf93cc6..072f09c 100644
--- a/components/camera-select-job/camera-select-job.component.jsx
+++ b/components/camera-select-job/camera-select-job.component.jsx
@@ -41,18 +41,17 @@ export function CameraSelectJob({
skip: !bodyshop,
});
const { t } = useTranslation();
+ const [visible, setVisible] = React.useState(false);
+ const [searchQuery, setSearchQuery] = React.useState("");
if (loading) return ;
if (error) return ;
- const [visible, setVisible] = React.useState(false);
-
const showModal = () => setVisible(true);
const hideModal = () => setVisible(false);
const onRefresh = async () => {
return refetch();
};
- const [searchQuery, setSearchQuery] = React.useState("");
const onChangeSearch = (query) => setSearchQuery(query);
@@ -96,6 +95,7 @@ export function CameraSelectJob({
contentContainerStyle={{
paddingTop: 20,
paddingBottom: 20,
+ margin: 12,
flex: 1,
backgroundColor: "white",
}}
@@ -148,12 +148,18 @@ export function CameraSelectJob({
: {}),
}}
title={`${
- object.item.ro_number ? `${object.item.ro_number} - ` : ``
+ object.item.ro_number ? `${object.item.ro_number} ` : ``
}${object.item.ownr_fn || ""} ${object.item.ownr_ln || ""} ${
object.item.ownr_co_nm || ""
- } - ${object.item.v_model_yr || ""} ${
- object.item.v_make_desc || ""
- } ${object.item.v_model_desc || ""}`}
+ } ${
+ object.item.v_model_yr ? `- ${object.item.v_model_yr}` : ""
+ } ${
+ object.item.v_make_desc ? `- ${object.item.v_make_desc}` : ""
+ } ${
+ object.item.v_model_desc
+ ? `- ${object.item.v_model_desc}`
+ : ""
+ }`}
key={object.item.id}
/>
)}
diff --git a/components/data-label/data-label.component.jsx b/components/data-label/data-label.component.jsx
index f5d3604..be703f9 100644
--- a/components/data-label/data-label.component.jsx
+++ b/components/data-label/data-label.component.jsx
@@ -1,6 +1,6 @@
import { DateTime } from "luxon";
import React from "react";
-import { Text, TextInput, View } from "react-native";
+import { Text, View } from "react-native";
export default function DataLabelComponent({
label,
@@ -16,8 +16,8 @@ export default function DataLabelComponent({
);
return (
-
-
+
+ {label}
{theContent}
);
diff --git a/components/job-lines/job-lines.component.jsx b/components/job-lines/job-lines.component.jsx
index 85cd3a7..ee85312 100644
--- a/components/job-lines/job-lines.component.jsx
+++ b/components/job-lines/job-lines.component.jsx
@@ -2,6 +2,7 @@ import Dinero from "dinero.js";
import React from "react";
import { useTranslation } from "react-i18next";
import { FlatList, RefreshControl, StyleSheet, Text, View } from "react-native";
+import { ScrollView } from "react-native-gesture-handler";
import { Card, DataTable } from "react-native-paper";
export default function JobLines({ job, loading, refetch }) {
@@ -17,64 +18,66 @@ export default function JobLines({ job, loading, refetch }) {
};
return (
-
-
-
-
- {t("jobdetail.labels.lines_desc")}
-
-
- {t("jobdetail.labels.lines_lbr_ty")}
-
-
- {t("jobdetail.labels.lines_lb_hrs")}
-
-
- {t("jobdetail.labels.lines_part_type")}
-
-
- {t("jobdetail.labels.lines_qty")}
-
-
- {t("jobdetail.labels.lines_price")}
-
-
-
+
+
+
+
+
+ {t("jobdetail.labels.lines_desc")}
+
+
+ {t("jobdetail.labels.lines_lbr_ty")}
+
+
+ {t("jobdetail.labels.lines_lb_hrs")}
+
+
+ {t("jobdetail.labels.lines_part_type")}
+
+
+ {t("jobdetail.labels.lines_qty")}
+
+
+ {t("jobdetail.labels.lines_price")}
+
+
+
-
- }
- keyExtractor={(item) => item.id}
- renderItem={(object) => (
-
-
- {object.item.line_desc}
-
-
- {object.item.mod_lbr_ty &&
- t(`jobdetail.lbr_types.${object.item.mod_lbr_ty}`)}
-
-
- {object.item.mod_lb_hrs}
-
-
- {object.item.part_type &&
- t(`jobdetail.part_types.${object.item.part_type}`)}
-
-
- {object.item.part_qty}
-
-
- {Dinero({
- amount: Math.round((object.item.act_price || 0) * 100),
- }).toFormat()}
-
-
- )}
- />
-
+
+ }
+ keyExtractor={(item) => item.id}
+ renderItem={(object) => (
+
+
+ {object.item.line_desc}
+
+
+ {object.item.mod_lbr_ty &&
+ t(`jobdetail.lbr_types.${object.item.mod_lbr_ty}`)}
+
+
+ {object.item.mod_lb_hrs}
+
+
+ {object.item.part_type &&
+ t(`jobdetail.part_types.${object.item.part_type}`)}
+
+
+ {object.item.part_qty}
+
+
+ {Dinero({
+ amount: Math.round((object.item.act_price || 0) * 100),
+ }).toFormat()}
+
+
+ )}
+ />
+
+
);
}
diff --git a/components/job-list/job-list.component.jsx b/components/job-list/job-list.component.jsx
index 8122ae5..bac93dd 100644
--- a/components/job-list/job-list.component.jsx
+++ b/components/job-list/job-list.component.jsx
@@ -1,6 +1,6 @@
import { useQuery } from "@apollo/client";
import React from "react";
-import { RefreshControl } from "react-native";
+import { RefreshControl, View, Text } from "react-native";
import { FlatList } from "react-native-gesture-handler";
import { connect } from "react-redux";
import { createStructuredSelector } from "reselect";
@@ -9,12 +9,15 @@ import { selectBodyshop } from "../../redux/user/user.selectors";
import ErrorDisplay from "../error-display/error-display.component";
import JobListItem from "../job-list-item/job-list-item.component";
import LoadingDisplay from "../loading-display/loading-display.component";
-
+import { Title, Button, Searchbar } from "react-native-paper";
+import { useTranslation } from "react-i18next";
const mapStateToProps = createStructuredSelector({
bodyshop: selectBodyshop,
});
export function JobListComponent({ bodyshop }) {
+ const { t } = useTranslation();
+ const [searchQuery, setSearchQuery] = React.useState("");
const { loading, error, data, refetch } = useQuery(QUERY_ALL_ACTIVE_JOBS, {
variables: {
statuses: bodyshop.md_ro_statuses.active_statuses || ["Open", "Open*"],
@@ -25,19 +28,62 @@ export function JobListComponent({ bodyshop }) {
const onRefresh = async () => {
return refetch();
};
+ const onChangeSearch = (query) => setSearchQuery(query);
if (loading) return ;
if (error) return ;
+ if (data && data.jobs && data.jobs.length === 0)
+ return (
+
+
+ {t("joblist.labels.nojobs")}
+
+
+
+ );
+
+ const jobs = data
+ ? searchQuery === ""
+ ? data.jobs
+ : data.jobs.filter(
+ (j) =>
+ (j.ro_number || "")
+ .toString()
+ .toLowerCase()
+ .includes(searchQuery.toLowerCase()) ||
+ (j.ownr_co_nm || "")
+ .toLowerCase()
+ .includes(searchQuery.toLowerCase()) ||
+ (j.ownr_fn || "")
+ .toLowerCase()
+ .includes(searchQuery.toLowerCase()) ||
+ (j.ownr_ln || "")
+ .toLowerCase()
+ .includes(searchQuery.toLowerCase()) ||
+ (j.v_model_desc || "")
+ .toLowerCase()
+ .includes(searchQuery.toLowerCase()) ||
+ (j.v_make_desc || "")
+ .toLowerCase()
+ .includes(searchQuery.toLowerCase())
+ )
+ : [];
+
return (
-
- }
- style={{ flex: 1 }}
- data={data ? data.jobs : []}
- renderItem={(object) => }
- />
+
+
+
+ }
+ style={{ flex: 1 }}
+ data={jobs}
+ renderItem={(object) => }
+ />
+
);
}
diff --git a/components/screen-media-browser/screen-media-browser.component.jsx b/components/screen-media-browser/screen-media-browser.component.jsx
index f45f2d5..0827a51 100644
--- a/components/screen-media-browser/screen-media-browser.component.jsx
+++ b/components/screen-media-browser/screen-media-browser.component.jsx
@@ -49,6 +49,7 @@ export function ImageBrowserScreen({
const forceRerender = useCallback(() => {
setTick((tick) => tick + 1);
}, []);
+
const client = useApolloClient();
async function handleOnSuccess(uri, id) {
console.log("Succesful upload!", uri);
@@ -61,44 +62,45 @@ export function ImageBrowserScreen({
//Validate to make sure the totals for the file sizes do not exceed the total on the job.
- const queryData = await client.query({
- query: GET_DOC_SIZE_TOTALS,
+ if (selectedCameraJobId !== "temp") {
+ const queryData = await client.query({
+ query: GET_DOC_SIZE_TOTALS,
- fetchPolicy: "network-only",
- variables: {
- jobId: selectedCameraJobId !== "temp" ? selectedCameraJobId : null,
- },
- });
-
- const totalOfUploads = await data.reduce(async (acc, val) => {
- //Get the size of the file based on URI.
- 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,
- "Shop Limit",
- bodyshop.jobsizelimit,
- "Space remaining",
- bodyshop.jobsizelimit -
+ fetchPolicy: "network-only",
+ variables: {
+ jobId: selectedCameraJobId,
+ },
+ });
+ const totalOfUploads = await data.reduce(async (acc, val) => {
+ //Get the size of the file based on URI.
+ 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,
- "Total of uploaded files",
- totalOfUploads
- );
-
- if (
- bodyshop.jobsizelimit -
- queryData.data.documents_aggregate.aggregate.sum.size <=
- totalOfUploads
- ) {
- //No more room... abandon ship.
- Alert.alert(
- t("mediabrowser.labels.storageexceeded_title"),
- t("mediabrowser.labels.storageexceeded")
+ "Shop Limit",
+ bodyshop.jobsizelimit,
+ "Space remaining",
+ bodyshop.jobsizelimit -
+ queryData.data.documents_aggregate.aggregate.sum.size,
+ "Total of uploaded files",
+ totalOfUploads
);
- return;
+
+ if (
+ bodyshop.jobsizelimit -
+ queryData.data.documents_aggregate.aggregate.sum.size <=
+ totalOfUploads
+ ) {
+ //No more room... abandon ship.
+ Alert.alert(
+ t("mediabrowser.labels.storageexceeded_title"),
+ t("mediabrowser.labels.storageexceeded")
+ );
+ return;
+ }
}
const ret = await Promise.all(
diff --git a/graphql/client.js b/graphql/client.js
index 523630b..ae16d99 100644
--- a/graphql/client.js
+++ b/graphql/client.js
@@ -128,10 +128,11 @@ export const client = new ApolloClient({
//link: from([apolloLogger, errorLink, authLink, link]),
link: from([authLink, link]),
cache,
+
// connectToDevTools: process.env.NODE_ENV !== "production",
- // defaultOptions: {
- // watchQuery: {
- // fetchPolicy: "cache-and-network",
- // },
- // },
+ defaultOptions: {
+ watchQuery: {
+ fetchPolicy: "network-only",
+ },
+ },
});
diff --git a/graphql/jobs.queries.js b/graphql/jobs.queries.js
index a028258..8cd0aef 100644
--- a/graphql/jobs.queries.js
+++ b/graphql/jobs.queries.js
@@ -8,47 +8,15 @@ export const QUERY_ALL_ACTIVE_JOBS = gql`
) {
ownr_fn
ownr_ln
- ownr_ph1
- ownr_ea
- owner {
- id
- allow_text_message
- preferred_contact
- }
- plate_no
- plate_st
- v_vin
+ ownr_co_nm
+ clm_no
v_model_yr
v_model_desc
v_make_desc
- v_color
- vehicleid
- actual_completion
- actual_delivery
- actual_in
-
id
- ins_co_nm
- ins_ct_fn
- ins_ct_ln
- ins_ph1
- ins_ea
- est_co_nm
- est_ph1
- est_ea
- est_ct_fn
- est_ct_ln
- clm_no
- clm_total
owner_owing
ro_number
- scheduled_completion
- scheduled_in
- scheduled_delivery
status
- updated_at
- ded_amt
- vehicleid
}
}
`;
@@ -152,7 +120,6 @@ export const GET_JOB_BY_PK = gql`
special_coverage_policy
scheduled_delivery
converted
-
ro_number
clm_total
inproduction
@@ -163,18 +130,7 @@ export const GET_JOB_BY_PK = gql`
v_model_desc
v_make_desc
v_color
- vehicle {
- id
- plate_no
- v_vin
- v_model_yr
- v_model_desc
- v_make_desc
- v_color
- }
- ins_co_id
- policy_no
- loss_date
+
clm_no
area_of_damage
ins_co_nm
@@ -190,10 +146,7 @@ export const GET_JOB_BY_PK = gql`
pay_date
est_ph1
est_ea
- selling_dealer
- servicing_dealer
- selling_dealer_contact
- servicing_dealer_contact
+
regie_number
scheduled_completion
id
@@ -216,20 +169,6 @@ export const GET_JOB_BY_PK = gql`
ownr_zip
ownr_ctry
ownr_ph1
- owner {
- id
- ownr_fn
- ownr_ln
- ownr_ea
- ownr_addr1
- ownr_addr2
- ownr_city
- ownr_st
- ownr_zip
- ownr_ctry
- ownr_ph1
- }
-
actual_in
scheduled_completion
scheduled_in
diff --git a/translations/en-US/common.json b/translations/en-US/common.json
index edcea94..60fa44f 100644
--- a/translations/en-US/common.json
+++ b/translations/en-US/common.json
@@ -70,11 +70,13 @@
},
"joblist": {
"actions": {
+ "refresh": "Refresh",
"swipecamera": "Add Pictures/Video"
},
"labels": {
"activejobs": "Jobs",
- "detail": "Job Detail"
+ "detail": "Job Detail",
+ "nojobs": "There are no active jobs."
},
"titles": {
"jobtab": "Jobs"
diff --git a/translations/es-MX/common.json b/translations/es-MX/common.json
index cf799e2..4e3fdce 100644
--- a/translations/es-MX/common.json
+++ b/translations/es-MX/common.json
@@ -70,11 +70,13 @@
},
"joblist": {
"actions": {
+ "refresh": "",
"swipecamera": ""
},
"labels": {
"activejobs": "",
- "detail": ""
+ "detail": "",
+ "nojobs": ""
},
"titles": {
"jobtab": ""
diff --git a/translations/fr-CA/common.json b/translations/fr-CA/common.json
index 27701dd..ffc1074 100644
--- a/translations/fr-CA/common.json
+++ b/translations/fr-CA/common.json
@@ -70,11 +70,13 @@
},
"joblist": {
"actions": {
+ "refresh": "",
"swipecamera": ""
},
"labels": {
"activejobs": "",
- "detail": ""
+ "detail": "",
+ "nojobs": ""
},
"titles": {
"jobtab": ""