From 667ddc25d1a00e84878ad698663ff25a829fb7fe Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Wed, 12 Jan 2022 15:21:31 -0800 Subject: [PATCH] Check for mobile app access. --- babel-translations.babel | 21 +++++++++++++++++++ .../screen-main/screen-main.component.jsx | 17 ++++++++++++--- .../screen-splash/screen-splash.component.jsx | 14 ++++++++++--- graphql/bodyshop.queries.js | 9 +++----- graphql/client.js | 19 ++++++++++------- translations/en-US/common.json | 1 + translations/es-MX/common.json | 1 + translations/fr-CA/common.json | 1 + 8 files changed, 63 insertions(+), 20 deletions(-) diff --git a/babel-translations.babel b/babel-translations.babel index 6bdcb8f..ca5ae9e 100644 --- a/babel-translations.babel +++ b/babel-translations.babel @@ -24,6 +24,27 @@ app + + nomobileaccess + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + title false diff --git a/components/screen-main/screen-main.component.jsx b/components/screen-main/screen-main.component.jsx index 8507021..65dd259 100644 --- a/components/screen-main/screen-main.component.jsx +++ b/components/screen-main/screen-main.component.jsx @@ -25,7 +25,7 @@ import ScreenMediaBrowser from "../screen-media-browser/screen-media-browser.com import ScreenSettingsComponent from "../screen-settings/screen-settings.component"; import ScreenSignIn from "../screen-sign-in/screen-sign-in.component"; import ScreenSplash from "../screen-splash/screen-splash.component"; - +import moment from "moment"; const JobStack = createStackNavigator(); const MoreStack = createStackNavigator(); const BottomTabs = createBottomTabNavigator(); @@ -155,16 +155,27 @@ export function ScreenMainComponent({ checkUserSession(); }, [checkUserSession]); + const hasMobileAccess = + bodyshop && + bodyshop.features && + (bodyshop.features.allAccess === true || + moment(bodyshop.features.mobile).isAfter(moment())); + + console.log( + "🚀 ~ file: screen-main.component.jsx ~ line 171 ~ hasMobileAccess", + hasMobileAccess, + bodyshop && bodyshop.features + ); return ( {currentUser.authorized === null ? ( ) : currentUser.authorized ? ( - bodyshop ? ( + bodyshop && hasMobileAccess ? ( ) : ( - + ) ) : ( diff --git a/components/screen-splash/screen-splash.component.jsx b/components/screen-splash/screen-splash.component.jsx index 78fcb7c..b0d554d 100644 --- a/components/screen-splash/screen-splash.component.jsx +++ b/components/screen-splash/screen-splash.component.jsx @@ -1,10 +1,10 @@ import React from "react"; import { useTranslation } from "react-i18next"; import { ActivityIndicator, Image, StyleSheet, View } from "react-native"; -import { Title } from "react-native-paper"; +import { Title, Subheading } from "react-native-paper"; import Logo from "../../assets/logo192.png"; -export default function ScreenSplash() { +export default function ScreenSplash({ noAccess }) { const { t } = useTranslation(); return ( @@ -13,7 +13,15 @@ export default function ScreenSplash() { {t("app.title")} - + {noAccess ? ( + + + {t("app.nomobileaccess")} + + + ) : ( + + )} ); } diff --git a/graphql/bodyshop.queries.js b/graphql/bodyshop.queries.js index 484586a..cb1e2f8 100644 --- a/graphql/bodyshop.queries.js +++ b/graphql/bodyshop.queries.js @@ -6,13 +6,10 @@ export const QUERY_BODYSHOP = gql` id jobsizelimit md_ro_statuses - md_order_statuses + shopname - messagingservicesid - md_referral_sources - md_messaging_presets - md_parts_locations - md_notes_presets + + features } } `; diff --git a/graphql/client.js b/graphql/client.js index 0520efa..ce3855c 100644 --- a/graphql/client.js +++ b/graphql/client.js @@ -67,14 +67,13 @@ const link = split( // split based on operation type ({ query }) => { const definition = getMainDefinition(query); - // console.log( - // "##Intercepted GQL Transaction : " + - // definition.operation + - // "|" + - // definition.name.value + - // "##", - // query - // ); + console.log( + "##Intercepted GQL Transaction : " + + definition.operation + + "|" + + // definition.name.value + + "##" + ); return ( definition.kind === "OperationDefinition" && definition.operation === "subscription" @@ -133,6 +132,10 @@ export const client = new ApolloClient({ defaultOptions: { watchQuery: { fetchPolicy: "network-only", + nextFetchPolicy: "network-only", + }, + query: { + fetchPolicy: "network-only", }, }, }); diff --git a/translations/en-US/common.json b/translations/en-US/common.json index ca835d2..2ac41ca 100644 --- a/translations/en-US/common.json +++ b/translations/en-US/common.json @@ -1,6 +1,7 @@ { "translation": { "app": { + "nomobileaccess": "Your shop does not currently have access to ImEX Mobile. ", "title": "ImEX Mobile" }, "camera": { diff --git a/translations/es-MX/common.json b/translations/es-MX/common.json index 1efd0ce..1cf5001 100644 --- a/translations/es-MX/common.json +++ b/translations/es-MX/common.json @@ -1,6 +1,7 @@ { "translation": { "app": { + "nomobileaccess": "", "title": "" }, "camera": { diff --git a/translations/fr-CA/common.json b/translations/fr-CA/common.json index b8a59e1..0290d22 100644 --- a/translations/fr-CA/common.json +++ b/translations/fr-CA/common.json @@ -1,6 +1,7 @@ { "translation": { "app": { + "nomobileaccess": "", "title": "" }, "camera": {