Check for mobile app access.
This commit is contained in:
@@ -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 (
|
||||
<SafeAreaView style={{ flex: 1 }}>
|
||||
<NavigationContainer>
|
||||
{currentUser.authorized === null ? (
|
||||
<ScreenSplash />
|
||||
) : currentUser.authorized ? (
|
||||
bodyshop ? (
|
||||
bodyshop && hasMobileAccess ? (
|
||||
<BottomTabsNavigator />
|
||||
) : (
|
||||
<ScreenSplash />
|
||||
<ScreenSplash noAccess />
|
||||
)
|
||||
) : (
|
||||
<ScreenSignIn />
|
||||
|
||||
@@ -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 (
|
||||
<View style={[localStyles.container]}>
|
||||
@@ -13,7 +13,15 @@ export default function ScreenSplash() {
|
||||
<Title>{t("app.title")}</Title>
|
||||
</View>
|
||||
|
||||
<ActivityIndicator color="dodgerblue" size="large" />
|
||||
{noAccess ? (
|
||||
<View style={[localStyles.logoContainer]}>
|
||||
<Subheading style={{ textAlign: "center" }}>
|
||||
{t("app.nomobileaccess")}
|
||||
</Subheading>
|
||||
</View>
|
||||
) : (
|
||||
<ActivityIndicator color="dodgerblue" size="large" />
|
||||
)}
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user