Added apollo client and basic provider setup.
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import React from "react";
|
||||
import { View, Text } from "react-native";
|
||||
import { View, Text, Button } from "react-native";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useQuery, useLazyQuery, useSubscription } from "@apollo/client";
|
||||
import { QUERY_BODYSHOP } from "../../graphql/bodyshop.queries.js";
|
||||
export default function ScreenJobList({ navigation }) {
|
||||
const { t } = useTranslation();
|
||||
const { loading, error, data } = useSubscription(QUERY_BODYSHOP);
|
||||
console.log("ScreenJobList -> error", error);
|
||||
console.log("ScreenJobList -> loading", loading);
|
||||
console.log("BodyshopData", data);
|
||||
return (
|
||||
<View>
|
||||
<Text>This is the Job List.</Text>
|
||||
|
||||
@@ -3,12 +3,16 @@ import { NavigationContainer } from "@react-navigation/native";
|
||||
import { createStackNavigator } from "@react-navigation/stack";
|
||||
import { createDrawerNavigator } from "@react-navigation/drawer";
|
||||
import i18n from "i18next";
|
||||
import React from "react";
|
||||
import React, { useEffect } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { StatusBar as rnStatusBar, StyleSheet } from "react-native";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { emailSignInStart, signOutStart } from "../../redux/user/user.actions";
|
||||
import {
|
||||
emailSignInStart,
|
||||
signOutStart,
|
||||
checkUserSession,
|
||||
} from "../../redux/user/user.actions";
|
||||
import {
|
||||
selectBodyshop,
|
||||
selectCurrentUser,
|
||||
@@ -19,6 +23,8 @@ import ScreenMessagingConversation from "../screen-messaging-conversation/screen
|
||||
import ScreenMessagingList from "../screen-messaging-list/screen-messaging-list.component";
|
||||
import ScreenSignIn from "../screen-sign-in/screen-sign-in.component";
|
||||
import ScreenSettingsComponent from "../screen-settings/screen-settings.component";
|
||||
import ScreenSplash from "../screen-splash/screen-splash.component";
|
||||
|
||||
const JobStack = createStackNavigator();
|
||||
const MessagingStack = createStackNavigator();
|
||||
const BottomTabs = createBottomTabNavigator();
|
||||
@@ -30,6 +36,7 @@ const mapStateToProps = createStructuredSelector({
|
||||
});
|
||||
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
checkUserSession: () => dispatch(checkUserSession()),
|
||||
emailSignInStart: (email, password) =>
|
||||
dispatch(emailSignInStart({ email, password })),
|
||||
signOutStart: () => dispatch(signOutStart()),
|
||||
@@ -89,11 +96,22 @@ const DrawerNavigator = () => (
|
||||
</Drawer.Navigator>
|
||||
);
|
||||
|
||||
export function ScreenMainComponent({ currentUser }) {
|
||||
export function ScreenMainComponent({ checkUserSession, currentUser }) {
|
||||
useEffect(() => {
|
||||
checkUserSession();
|
||||
}, [checkUserSession]);
|
||||
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<NavigationContainer>
|
||||
{currentUser.authorized ? <DrawerNavigator /> : <ScreenSignIn />}
|
||||
{currentUser.authorized === null ? (
|
||||
<ScreenSplash />
|
||||
) : currentUser.authorized ? (
|
||||
<DrawerNavigator />
|
||||
) : (
|
||||
<ScreenSignIn />
|
||||
)}
|
||||
</NavigationContainer>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3,31 +3,28 @@ import {
|
||||
Button,
|
||||
Container,
|
||||
Content,
|
||||
Form,
|
||||
H1,
|
||||
Input,
|
||||
Item,
|
||||
H1,
|
||||
Label,
|
||||
Text,
|
||||
} from "native-base";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { StyleSheet, View, ActivityIndicator, Image } from "react-native";
|
||||
import { ActivityIndicator, Image, StyleSheet, View } from "react-native";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import Logo from "../../assets/logo240.png";
|
||||
import { emailSignInStart } from "../../redux/user/user.actions";
|
||||
import {
|
||||
selectCurrentUser,
|
||||
selectSignInError,
|
||||
selectSigningIn,
|
||||
} from "../../redux/user/user.selectors";
|
||||
import SignInErrorAlertComponent from "../sign-in-error-alert/sign-in-error-alert.component";
|
||||
import styles from "../styles";
|
||||
import Logo from "../../assets/logo240.png";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
signInError: selectSignInError,
|
||||
signingIn: selectSigningIn,
|
||||
});
|
||||
|
||||
@@ -36,7 +33,7 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
dispatch(emailSignInStart({ email, password })),
|
||||
});
|
||||
|
||||
export function SignIn({ emailSignInStart, signInError, signingIn }) {
|
||||
export function SignIn({ emailSignInStart, signingIn }) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const formSubmit = (values) => {
|
||||
|
||||
32
components/screen-splash/screen-splash.component.jsx
Normal file
32
components/screen-splash/screen-splash.component.jsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import React from "react";
|
||||
import { StyleSheet, Image } from "react-native";
|
||||
import Logo from "../../assets/logo240.png";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { H1, Container, Content } from "native-base";
|
||||
import styles from "../styles";
|
||||
|
||||
export default function ScreenSplash() {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Container>
|
||||
<Content
|
||||
contentContainerStyle={[
|
||||
styles.contentContainer__centered,
|
||||
localStyles.middleAlign,
|
||||
]}
|
||||
>
|
||||
<Image style={localStyles.logo} source={Logo} />
|
||||
<H1>{t("app.title")}</H1>
|
||||
</Content>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
const localStyles = StyleSheet.create({
|
||||
middleAlign: {
|
||||
alignItems: "center",
|
||||
},
|
||||
content: {
|
||||
paddingBottom: 150,
|
||||
},
|
||||
logo: { width: 100, height: 100, margin: 20 },
|
||||
});
|
||||
Reference in New Issue
Block a user