Remove time tickets from bottom tab navigation, and update version for production deployment.
This commit is contained in:
@@ -2,13 +2,20 @@ import { useLazyQuery, useQuery } from "@apollo/client";
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FlatList, RefreshControl, Text, View } from "react-native";
|
||||
import {
|
||||
FlatList,
|
||||
Keyboard,
|
||||
KeyboardAvoidingView,
|
||||
RefreshControl,
|
||||
Text,
|
||||
View,
|
||||
} from "react-native";
|
||||
import { Button, List, Modal, Portal, Searchbar } from "react-native-paper";
|
||||
import { connect } from "react-redux";
|
||||
import { SEARCH_JOBS_FOR_AUTOCOMPLETE } from "../../graphql/jobs.queries";
|
||||
import ErrorDisplay from "../error-display/error-display.component";
|
||||
import _ from "lodash";
|
||||
import { useCallback,useRef, useEffect } from "react";
|
||||
import { useCallback, useRef, useEffect } from "react";
|
||||
|
||||
const useIsMounted = () => {
|
||||
const isMounted = useRef(false);
|
||||
@@ -23,7 +30,6 @@ const useIsMounted = () => {
|
||||
};
|
||||
|
||||
export function JobSearchAndSelectModal(props) {
|
||||
|
||||
const { t } = useTranslation();
|
||||
const jobSrchNotExported =
|
||||
props?.notExported !== undefined ? props.notExported : true;
|
||||
@@ -35,7 +41,7 @@ export function JobSearchAndSelectModal(props) {
|
||||
const jobSrchCurrentValue =
|
||||
props?.currentValue !== undefined
|
||||
? props.currentValue
|
||||
: { id:"temp", ro_number:t("selectjobid.labels.noselection") };
|
||||
: { id: "temp", ro_number: t("selectjobid.labels.noselection") };
|
||||
const jobSrchOnSetCurrentValue =
|
||||
props?.onSetCurrentValue !== undefined
|
||||
? props.onSetCurrentValue
|
||||
@@ -50,7 +56,8 @@ export function JobSearchAndSelectModal(props) {
|
||||
const hideModal = () => setVisible(false);
|
||||
|
||||
const [searchQuery, { loading, error, data, refetch }] = useLazyQuery(
|
||||
SEARCH_JOBS_FOR_AUTOCOMPLETE,{fetchPolicy: "cache-and-network",}
|
||||
SEARCH_JOBS_FOR_AUTOCOMPLETE,
|
||||
{ fetchPolicy: "cache-and-network" }
|
||||
);
|
||||
if (error) return <ErrorDisplay errorMessage={error.message} />;
|
||||
const onRefresh = async () => {
|
||||
@@ -61,8 +68,10 @@ export function JobSearchAndSelectModal(props) {
|
||||
search: searchText,
|
||||
});
|
||||
};
|
||||
const search = (v) => {if (v && v !== "") searchQuery(v);};
|
||||
const searchDebouncer = useCallback(_.debounce(search, 1000),[]);
|
||||
const search = (v) => {
|
||||
if (v && v !== "") searchQuery(v);
|
||||
};
|
||||
const searchDebouncer = useCallback(_.debounce(search, 1000), []);
|
||||
const onChangeSearch = (query) => {
|
||||
setSearchText(query);
|
||||
searchDebouncer({
|
||||
@@ -87,104 +96,109 @@ export function JobSearchAndSelectModal(props) {
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
if (visible) {
|
||||
setFocus();
|
||||
}
|
||||
}, 300);
|
||||
setTimeout(() => {
|
||||
if (visible) {
|
||||
setFocus();
|
||||
}
|
||||
}, 300);
|
||||
}, [visible, isMounted]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Portal>
|
||||
<Modal
|
||||
visible={visible}
|
||||
onDismiss={hideModal}
|
||||
contentContainerStyle={{
|
||||
paddingTop: 20,
|
||||
paddingBottom: 20,
|
||||
margin: 12,
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
}}
|
||||
>
|
||||
<View
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
margin: 8,
|
||||
<KeyboardAvoidingView>
|
||||
<Portal>
|
||||
<Modal
|
||||
visible={visible}
|
||||
onDismiss={hideModal}
|
||||
contentContainerStyle={{
|
||||
paddingTop: 20,
|
||||
paddingBottom: 20,
|
||||
margin: 12,
|
||||
flex: 1,
|
||||
backgroundColor: "white",
|
||||
}}
|
||||
>
|
||||
<Button onPress={() => hideModal()}>
|
||||
<Ionicons name="ios-arrow-back" size={32} color="dodgerblue" />
|
||||
</Button>
|
||||
<Searchbar
|
||||
style={{ flex: 1 }}
|
||||
onChangeText={onChangeSearch}
|
||||
value={searchText}
|
||||
ref={inputSearch}
|
||||
placeholder={t("selectjobid.labels.searchplaceholder")}
|
||||
/>
|
||||
</View>
|
||||
<FlatList
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={loading} onRefresh={onRefresh} />
|
||||
}
|
||||
data={data?.search_jobs}
|
||||
keyExtractor={(item) => item.id}
|
||||
renderItem={(object) => (
|
||||
<List.Item
|
||||
onPress={() => {
|
||||
jobSrchOnSetCurrentValue(object.item);
|
||||
hideModal();
|
||||
setSearchText("");
|
||||
}}
|
||||
left={() => {
|
||||
if (object.item.id !== jobSrchCurrentValue?.id) return null;
|
||||
return (
|
||||
<Ionicons
|
||||
name="ios-checkmark-circle"
|
||||
size={24}
|
||||
color="dodgerblue"
|
||||
style={{ alignSelf: "center" }}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
titleStyle={{
|
||||
...(object.item.id === jobSrchCurrentValue?.id
|
||||
? { color: "dodgerblue" }
|
||||
: {}),
|
||||
}}
|
||||
title={`${
|
||||
object.item.ro_number ? `${object.item.ro_number} ` : ``
|
||||
}${object.item.ownr_fn || ""} ${object.item.ownr_ln || ""}${
|
||||
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
|
||||
style={{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
alignItems: "center",
|
||||
margin: 8,
|
||||
}}
|
||||
>
|
||||
<Button onPress={() => hideModal()}>
|
||||
<Ionicons name="ios-arrow-back" size={32} color="dodgerblue" />
|
||||
</Button>
|
||||
<Searchbar
|
||||
style={{ flex: 1 }}
|
||||
onChangeText={onChangeSearch}
|
||||
value={searchText}
|
||||
ref={inputSearch}
|
||||
placeholder={t("selectjobid.labels.searchplaceholder")}
|
||||
/>
|
||||
)}
|
||||
ListEmptyComponent={
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
padding: 10,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Text>{t("selectjobid.labels.nodata")}</Text>
|
||||
</View>
|
||||
}
|
||||
/>
|
||||
</Modal>
|
||||
</Portal>
|
||||
</View>
|
||||
<FlatList
|
||||
refreshControl={
|
||||
<RefreshControl refreshing={loading} onRefresh={onRefresh} />
|
||||
}
|
||||
data={data?.search_jobs}
|
||||
keyExtractor={(item) => item.id}
|
||||
renderItem={(object) => (
|
||||
<List.Item
|
||||
onPress={() => {
|
||||
jobSrchOnSetCurrentValue(object.item);
|
||||
hideModal();
|
||||
setSearchText("");
|
||||
}}
|
||||
left={() => {
|
||||
if (object.item.id !== jobSrchCurrentValue?.id) return null;
|
||||
return (
|
||||
<Ionicons
|
||||
name="ios-checkmark-circle"
|
||||
size={24}
|
||||
color="dodgerblue"
|
||||
style={{ alignSelf: "center" }}
|
||||
/>
|
||||
);
|
||||
}}
|
||||
titleStyle={{
|
||||
...(object.item.id === jobSrchCurrentValue?.id
|
||||
? { color: "dodgerblue" }
|
||||
: {}),
|
||||
}}
|
||||
title={`${
|
||||
object.item.ro_number ? `${object.item.ro_number} ` : ``
|
||||
}${object.item.ownr_fn || ""} ${object.item.ownr_ln || ""}${
|
||||
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}
|
||||
/>
|
||||
)}
|
||||
ListEmptyComponent={
|
||||
<View
|
||||
style={{
|
||||
flex: 1,
|
||||
padding: 10,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
}}
|
||||
>
|
||||
<Text>{t("selectjobid.labels.nodata")}</Text>
|
||||
</View>
|
||||
}
|
||||
/>
|
||||
</Modal>
|
||||
</Portal>
|
||||
</KeyboardAvoidingView>
|
||||
|
||||
<Button
|
||||
mode="outlined"
|
||||
style={{
|
||||
|
||||
Reference in New Issue
Block a user