diff --git a/app.json b/app.json index f17801e..71c1336 100644 --- a/app.json +++ b/app.json @@ -3,24 +3,22 @@ "name": "imexmobile", "slug": "imexmobile", "version": "1.0.0", - "orientation": "portrait", - "icon": "./assets/icon.png", + "orientation": "both", + "icon": "./assets/icon240.png", "splash": { - "image": "./assets/splash.png", + "image": "./assets/logo1024.png", "resizeMode": "contain", "backgroundColor": "#ffffff" }, "updates": { "fallbackToCacheTimeout": 0 }, - "assetBundlePatterns": [ - "**/*" - ], + "assetBundlePatterns": ["**/*"], "ios": { "supportsTablet": true }, "web": { - "favicon": "./assets/favicon.png" + "favicon": "./assets/logo240.png" } } } diff --git a/assets/logo1024.png b/assets/logo1024.png new file mode 100644 index 0000000..ad76341 Binary files /dev/null and b/assets/logo1024.png differ diff --git a/assets/logo240.png b/assets/logo240.png new file mode 100644 index 0000000..07fffbe Binary files /dev/null and b/assets/logo240.png differ diff --git a/babel-translations.babel b/babel-translations.babel index 5a0bee0..62ee034 100644 --- a/babel-translations.babel +++ b/babel-translations.babel @@ -21,6 +21,32 @@ translation + + app + + + title + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + general @@ -200,6 +226,74 @@ + + errors + + + emailformat + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + usernotfound + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + wrongpassword + false + + + + + + en-US + false + + + es-MX + false + + + fr-CA + false + + + + + fields diff --git a/components/screen-sign-in/screen-sign-in.component.jsx b/components/screen-sign-in/screen-sign-in.component.jsx index 00f0c61..ed6ecd6 100644 --- a/components/screen-sign-in/screen-sign-in.component.jsx +++ b/components/screen-sign-in/screen-sign-in.component.jsx @@ -1,26 +1,34 @@ import { Formik } from "formik"; import { - Input, - Header, - Item, - Label, - Form, Button, - Text, Container, Content, + Form, + Input, + Item, + H1, + Label, + Text, } from "native-base"; import React from "react"; import { useTranslation } from "react-i18next"; -import { SafeAreaView, TextInput, View } from "react-native"; +import { StyleSheet, View, ActivityIndicator, Image } from "react-native"; import { connect } from "react-redux"; import { createStructuredSelector } from "reselect"; -import { emailSignInStart, signOutStart } from "../../redux/user/user.actions"; -import { selectCurrentUser } from "../../redux/user/user.selectors"; -import { StyleSheet } from "react-native"; +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, }); const mapDispatchToProps = (dispatch) => ({ @@ -28,7 +36,7 @@ const mapDispatchToProps = (dispatch) => ({ dispatch(emailSignInStart({ email, password })), }); -export function SignIn({ emailSignInStart }) { +export function SignIn({ emailSignInStart, signInError, signingIn }) { const { t } = useTranslation(); const formSubmit = (values) => { @@ -39,42 +47,45 @@ export function SignIn({ emailSignInStart }) { return ( + + +

{t("app.title")}

+
{({ handleChange, handleBlur, handleSubmit, values }) => ( -
- - - - - - - - - - - -
+ + + + + + + + + +
)}
@@ -83,19 +94,11 @@ export function SignIn({ emailSignInStart }) { ); } -const styles = StyleSheet.create({ - contentContainer: { - justifyContent: "center", - flex: 1, - }, +const localStyles = StyleSheet.create({ content: { paddingBottom: 150, - // flex: 1, - // backgroundColor: "#fff", - // alignItems: "center", - //justifyContent: "space-between", - // //justifyContent: "center", }, + logo: { width: 100, height: 100 }, }); export default connect(mapStateToProps, mapDispatchToProps)(SignIn); diff --git a/components/sign-in-error-alert/sign-in-error-alert.component.jsx b/components/sign-in-error-alert/sign-in-error-alert.component.jsx new file mode 100644 index 0000000..51c047f --- /dev/null +++ b/components/sign-in-error-alert/sign-in-error-alert.component.jsx @@ -0,0 +1,52 @@ +import React, { useState, useEffect } from "react"; +import { useTranslation } from "react-i18next"; +import { Container, Content, Text } from "native-base"; +import { View, StyleSheet } from "react-native"; +import { connect } from "react-redux"; +import { createStructuredSelector } from "reselect"; +import { selectSignInError } from "../../redux/user/user.selectors"; +const mapStateToProps = createStructuredSelector({ + signInError: selectSignInError, +}); + +export function SignInErrorAlertComponent({ signInError }) { + const [errorText, setErrorText] = useState(""); + const { t } = useTranslation(); + + useEffect(() => { + let text; + if (signInError && signInError.code) + switch (signInError.code) { + case "auth/user-not-found": + text = t("signin.errors.usernotfound"); + break; + case "auth/invalid-email": + text = t("signin.errors.emailformat"); + break; + case "auth/wrong-password": + text = t("signin.errors.wrongpassword"); + break; + default: + text = signInError.code + " " + signInError.message; + break; + } + + setErrorText(text); + }, [signInError, setErrorText]); + return ( + + {errorText ? {errorText} : null} + + ); +} + +export default connect(mapStateToProps, null)(SignInErrorAlertComponent); + +const localStyles = StyleSheet.create({ + alert: { + color: "red", + textAlign: "center", + margin: 15, + padding: 15, + }, +}); diff --git a/components/styles.js b/components/styles.js new file mode 100644 index 0000000..8032c61 --- /dev/null +++ b/components/styles.js @@ -0,0 +1,15 @@ +import { StyleSheet } from "react-native"; +import { Row } from "native-base"; + +export default StyleSheet.create({ + contentContainer__centered: { + justifyContent: "center", + flex: 1, + }, + + evenlySpacedRow: { + flexDirection: "row", + justifyContent: "space-evenly", + alignItems: "center", + }, +}); diff --git a/redux/user/user.reducer.js b/redux/user/user.reducer.js index c320b81..69eab5f 100644 --- a/redux/user/user.reducer.js +++ b/redux/user/user.reducer.js @@ -6,39 +6,23 @@ const INITIAL_STATE = { }, bodyshop: null, fingerprint: null, + signingIn: false, error: null, conflict: false, - passwordreset: { - email: null, - error: null, - success: false, - }, }; const userReducer = (state = INITIAL_STATE, action) => { switch (action.type) { - // case UserActionTypes.VALIDATE_PASSWORD_RESET_START: - // case UserActionTypes.SEND_PASSWORD_RESET_EMAIL_START: - // return { - // ...state, - // passwordreset: { - // email: action.payload, - // error: null, - // success: false, - // }, - // }; - // case UserActionTypes.VALIDATE_PASSWORD_RESET_FAILURE: - // case UserActionTypes.SEND_PASSWORD_RESET_EMAIL_FAILURE: - // return { ...state, passwordreset: { error: action.payload } }; - // case UserActionTypes.VALIDATE_PASSWORD_RESET_SUCCESS: - // case UserActionTypes.SEND_PASSWORD_RESET_EMAIL_SUCCESS: - // return { - // ...state, - // passwordreset: { ...state.passwordreset, success: true }, - // }; + case UserActionTypes.EMAIL_SIGN_IN_START: + return { + ...state, + signingIn: true, + error: null, + }; case UserActionTypes.SIGN_IN_SUCCESS: return { ...state, + signingIn: false, currentUser: action.payload, error: null, }; @@ -54,11 +38,7 @@ const userReducer = (state = INITIAL_STATE, action) => { error: null, currentUser: { authorized: false }, }; - // case UserActionTypes.SET_USER_LANGUAGE: - // return { - // ...state, - // language: action.payload, - // }; + case UserActionTypes.UPDATE_USER_DETAILS_SUCCESS: return { ...state, @@ -75,6 +55,7 @@ const userReducer = (state = INITIAL_STATE, action) => { case UserActionTypes.EMAIL_SIGN_UP_FAILURE: return { ...state, + signingIn: false, error: action.payload, }; default: diff --git a/redux/user/user.selectors.js b/redux/user/user.selectors.js index 6d4a0bc..b6b762a 100644 --- a/redux/user/user.selectors.js +++ b/redux/user/user.selectors.js @@ -26,3 +26,8 @@ export const selectPasswordReset = createSelector( [selectUser], (user) => user.passwordreset ); + +export const selectSigningIn = createSelector( + [selectUser], + (user) => user.signingIn +); diff --git a/redux/user/user.types.js b/redux/user/user.types.js index e394beb..faa717c 100644 --- a/redux/user/user.types.js +++ b/redux/user/user.types.js @@ -1,6 +1,5 @@ const UserActionTypes = { SET_CURRENT_USER: "SET_CURRENT_USER", - GOOGLE_SIGN_IN_START: "GOOGLE_SIGN_IN_START", SIGN_IN_SUCCESS: "SIGN_IN_SUCCESS", SIGN_IN_FAILURE: "SIGN_IN_FAILURE", EMAIL_SIGN_IN_START: "EMAIL_SIGN_IN_START", diff --git a/translations/en-US/common.json b/translations/en-US/common.json index 2fcdee3..3d41e62 100644 --- a/translations/en-US/common.json +++ b/translations/en-US/common.json @@ -1,5 +1,8 @@ { "translation": { + "app": { + "title": "ImEX Mobile" + }, "general": { "actions": { "signout": "Sign Out" @@ -27,6 +30,11 @@ "actions": { "signin": "Sign In" }, + "errors": { + "emailformat": "The email you have entered is not formatted correctly. ", + "usernotfound": "No user found.", + "wrongpassword": "The password you entered is not correct." + }, "fields": { "email": "Email", "password": "Password" diff --git a/translations/es-MX/common.json b/translations/es-MX/common.json index 6e47227..d0409db 100644 --- a/translations/es-MX/common.json +++ b/translations/es-MX/common.json @@ -1,5 +1,8 @@ { "translation": { + "app": { + "title": "" + }, "general": { "actions": { "signout": "" @@ -27,6 +30,11 @@ "actions": { "signin": "" }, + "errors": { + "emailformat": "", + "usernotfound": "", + "wrongpassword": "" + }, "fields": { "email": "Email", "password": "" diff --git a/translations/fr-CA/common.json b/translations/fr-CA/common.json index 6e47227..d0409db 100644 --- a/translations/fr-CA/common.json +++ b/translations/fr-CA/common.json @@ -1,5 +1,8 @@ { "translation": { + "app": { + "title": "" + }, "general": { "actions": { "signout": "" @@ -27,6 +30,11 @@ "actions": { "signin": "" }, + "errors": { + "emailformat": "", + "usernotfound": "", + "wrongpassword": "" + }, "fields": { "email": "Email", "password": ""