diff --git a/.gitignore b/.gitignore index 331c2b3..83e2643 100644 --- a/.gitignore +++ b/.gitignore @@ -16,4 +16,7 @@ yarn-error.log *.ipa *.aab -.expo \ No newline at end of file +.expo + +android/** +ios/** \ No newline at end of file diff --git a/app/_layout.tsx b/app/_layout.tsx index df04d73..b4fa1c3 100644 --- a/app/_layout.tsx +++ b/app/_layout.tsx @@ -17,7 +17,7 @@ import "../translations/i18n"; function AuthenticatedLayout() { const { t } = useTranslation(); return ( - + @@ -26,6 +26,9 @@ function AuthenticatedLayout() { + + + ); } diff --git a/app/jobs/_layout.tsx b/app/jobs/_layout.tsx index 9724f86..ed4fa48 100644 --- a/app/jobs/_layout.tsx +++ b/app/jobs/_layout.tsx @@ -1,6 +1,10 @@ -import { Stack } from "expo-router"; +import { Stack, useLocalSearchParams, useRouter } from "expo-router"; function JobsStack() { + const router = useRouter(); + const params = useLocalSearchParams(); + console.log("*** ~ JobsStack ~ params:", params); + return ( - - + { + router.setParams({ + search: event?.nativeEvent?.text, + }); + }, + }, + }} + /> + ({ + title: (route.params as any)?.title || "Job Details", + })} + /> ); } diff --git a/app/jobs/index.tsx b/app/jobs/index.tsx index 3523ff2..830483a 100644 --- a/app/jobs/index.tsx +++ b/app/jobs/index.tsx @@ -1,24 +1,4 @@ -import { Link } from "expo-router"; -import { StyleSheet, Text, View } from "react-native"; - +import JobsList from "../../components/jobs-list/jobs-list"; export default function Tab() { - return ( - - Jobs Screen. - - Go to detail - - - ); + return ; } - -const styles = StyleSheet.create({ - container: { - flex: 1, - justifyContent: "center", - alignItems: "center", - }, -}); diff --git a/app/search/_layout.tsx b/app/search/_layout.tsx new file mode 100644 index 0000000..3a7b906 --- /dev/null +++ b/app/search/_layout.tsx @@ -0,0 +1,24 @@ +import { Stack, useRouter } from "expo-router"; + +export default function SearchLayout() { + const router = useRouter(); + return ( + + { + router.setParams({ + globalSearch: event?.nativeEvent?.text, + }); + }, + }, + }} + /> + + ); +} diff --git a/app/search/index.tsx b/app/search/index.tsx new file mode 100644 index 0000000..6193cb1 --- /dev/null +++ b/app/search/index.tsx @@ -0,0 +1,12 @@ +import { useLocalSearchParams } from "expo-router"; +import { ScrollView } from "react-native"; +import { Text } from "react-native-paper"; + +export default function SearchIndex() { + const { globalSearch } = useLocalSearchParams(); + return ( + + Some search results here for: {globalSearch} + + ); +} diff --git a/components/jobs-list/job-list-item.jsx b/components/jobs-list/job-list-item.jsx new file mode 100644 index 0000000..f4adfec --- /dev/null +++ b/components/jobs-list/job-list-item.jsx @@ -0,0 +1,54 @@ +import { useRouter } from "expo-router"; +import { useTranslation } from "react-i18next"; +import { Button, List, Text, useTheme } from "react-native-paper"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { logImEXEvent } from "../../firebase/firebase.analytics"; +import { setCameraJob, setCameraJobId } from "../../redux/app/app.actions"; + +const mapStateToProps = createStructuredSelector({}); +const mapDispatchToProps = (dispatch) => ({ + setCameraJobId: (id) => dispatch(setCameraJobId(id)), + setCameraJob: (job) => dispatch(setCameraJob(job)), +}); + +export function JobListItem({ setCameraJob, setCameraJobId, item }) { + const { t } = useTranslation(); + const router = useRouter(); + const theme = useTheme(); + const onPress = () => { + logImEXEvent("imexmobile_view_job_detail"); + router.navigate({ + pathname: `/jobs/${item.id}`, + params: { + title: item.ro_number || t("general.labels.na"), + }, + }); + }; + + const handleUpload = () => {}; + + return ( + ( + + {item.ro_number || t("general.labels.na")} + + )} + right={() => ( + + )} + /> + ); +} + +export default connect(mapStateToProps, mapDispatchToProps)(JobListItem); diff --git a/components/jobs-list/jobs-list.jsx b/components/jobs-list/jobs-list.jsx new file mode 100644 index 0000000..545dc00 --- /dev/null +++ b/components/jobs-list/jobs-list.jsx @@ -0,0 +1,82 @@ +import { useQuery } from "@apollo/client"; +import { useLocalSearchParams } from "expo-router"; +import React from "react"; +import { useTranslation } from "react-i18next"; +import { FlatList, RefreshControl, Text, View } from "react-native"; +import { ActivityIndicator, Button } from "react-native-paper"; +import { SafeAreaView } from "react-native-safe-area-context"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { QUERY_ALL_ACTIVE_JOBS } from "../../graphql/jobs.queries"; +import { selectBodyshop } from "../../redux/user/user.selectors"; +//import ErrorDisplay from "../error-display/error-display.component"; +import JobListItem from "./job-list-item"; + +const mapStateToProps = createStructuredSelector({ + bodyshop: selectBodyshop, +}); + +export function JobListComponent({ bodyshop }) { + const { t } = useTranslation(); + const { search } = useLocalSearchParams(); + + const { loading, error, data, refetch } = useQuery(QUERY_ALL_ACTIVE_JOBS, { + variables: { + statuses: bodyshop?.md_ro_statuses?.active_statuses || ["Open", "Open*"], + }, + skip: !bodyshop, + notifyOnNetworkStatusChange: true, + }); + + const onRefresh = async () => { + return refetch(); + }; + + if (loading) return ; + if (error) return {error.message}; + if (data && data.jobs && data.jobs.length === 0) + return ( + + + {t("joblist.labels.nojobs")} + + + + ); + + const jobs = data + ? search === "" || !search + ? data.jobs + : data.jobs.filter( + (j) => + (j.ro_number || "") + .toString() + .toLowerCase() + .includes(search.toLowerCase()) || + (j.ownr_co_nm || "").toLowerCase().includes(search.toLowerCase()) || + (j.ownr_fn || "").toLowerCase().includes(search.toLowerCase()) || + (j.ownr_ln || "").toLowerCase().includes(search.toLowerCase()) || + (j.v_model_desc || "") + .toLowerCase() + .includes(search.toLowerCase()) || + (j.v_make_desc || "").toLowerCase().includes(search.toLowerCase()) + ) + : []; + + return ( + + + } + style={{ flex: 1 }} + data={jobs} + renderItem={(object) => } + /> + + ); +} + +export default connect(mapStateToProps, null)(JobListComponent);