Resolve issue for temp uploads & add search.

This commit is contained in:
Patrick Fic
2021-05-13 09:39:29 -07:00
parent bdf7390678
commit b6155c6a85
11 changed files with 230 additions and 185 deletions

View File

@@ -1085,6 +1085,27 @@
<folder_node>
<name>actions</name>
<children>
<concept_node>
<name>refresh</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
<concept_node>
<name>swipecamera</name>
<definition_loaded>false</definition_loaded>
@@ -1153,6 +1174,27 @@
</translation>
</translations>
</concept_node>
<concept_node>
<name>nojobs</name>
<definition_loaded>false</definition_loaded>
<description></description>
<comment></comment>
<default_text></default_text>
<translations>
<translation>
<language>en-US</language>
<approved>false</approved>
</translation>
<translation>
<language>es-MX</language>
<approved>false</approved>
</translation>
<translation>
<language>fr-CA</language>
<approved>false</approved>
</translation>
</translations>
</concept_node>
</children>
</folder_node>
<folder_node>

View File

@@ -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 <LoadingDisplay />;
if (error) return <ErrorDisplay errorMessage={error.message} />;
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}
/>
)}

View File

@@ -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 (
<View {...restProps}>
<TextInput disabled placeholder={label} />
<View {...restProps} style={{ margin: 4, ...restProps.style }}>
<Text style={{ color: "slategray" }}>{label}</Text>
<Text>{theContent}</Text>
</View>
);

View File

@@ -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,6 +18,7 @@ export default function JobLines({ job, loading, refetch }) {
};
return (
<ScrollView horizontal>
<View>
<DataTable>
<DataTable.Header>
@@ -75,6 +77,7 @@ export default function JobLines({ job, loading, refetch }) {
)}
/>
</View>
</ScrollView>
);
}

View File

@@ -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 <LoadingDisplay />;
if (error) return <ErrorDisplay errorMessage={error.message} />;
if (data && data.jobs && data.jobs.length === 0)
return (
<View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
<Title>
<Text>{t("joblist.labels.nojobs")}</Text>
</Title>
<Button onPress={() => refetch()}>
{t("joblist.actions.refresh")}
</Button>
</View>
);
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 (
<View style={{ flex: 1 }}>
<Searchbar onChangeText={onChangeSearch} value={searchQuery} />
<FlatList
refreshControl={
<RefreshControl refreshing={loading} onRefresh={onRefresh} />
}
style={{ flex: 1 }}
data={data ? data.jobs : []}
data={jobs}
renderItem={(object) => <JobListItem item={object.item} />}
/>
</View>
);
}

View File

@@ -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,15 +62,15 @@ export function ImageBrowserScreen({
//Validate to make sure the totals for the file sizes do not exceed the total on the job.
if (selectedCameraJobId !== "temp") {
const queryData = await client.query({
query: GET_DOC_SIZE_TOTALS,
fetchPolicy: "network-only",
variables: {
jobId: selectedCameraJobId !== "temp" ? selectedCameraJobId : null,
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 });
@@ -100,6 +101,7 @@ export function ImageBrowserScreen({
);
return;
}
}
const ret = await Promise.all(
data.map(async (p) => {

View File

@@ -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",
},
},
});

View File

@@ -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

View File

@@ -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"

View File

@@ -70,11 +70,13 @@
},
"joblist": {
"actions": {
"refresh": "",
"swipecamera": ""
},
"labels": {
"activejobs": "",
"detail": ""
"detail": "",
"nojobs": ""
},
"titles": {
"jobtab": ""

View File

@@ -70,11 +70,13 @@
},
"joblist": {
"actions": {
"refresh": "",
"swipecamera": ""
},
"labels": {
"activejobs": "",
"detail": ""
"detail": "",
"nojobs": ""
},
"titles": {
"jobtab": ""