| import { Ionicons } from "@expo/vector-icons"; | import { Ionicons } from "@expo/vector-icons"; | ||||
| import { useDispatch } from "react-redux"; | import { useDispatch } from "react-redux"; | ||||
| import { logoutUser } from "../../store/actions/login/loginActions"; | import { logoutUser } from "../../store/actions/login/loginActions"; | ||||
| import useAuthHook from "../../utils/hooks/useAuthHook"; | |||||
| import useAuthHook from "../../hooks/useAuthHook"; | |||||
| const CustomDrawer = (props) => { | const CustomDrawer = (props) => { | ||||
| import React from "react"; | import React from "react"; | ||||
| import * as Google from "expo-auth-session/providers/google"; | import * as Google from "expo-auth-session/providers/google"; | ||||
| import { getData } from "../../service/asyncStorage"; | |||||
| import { ACCESS_TOKEN } from "../../constants/localStorage"; | |||||
| import { getData } from "../service/asyncStorage"; | |||||
| import { ACCESS_TOKEN } from "../constants/localStorage"; | |||||
| import { revokeAsync } from "expo-auth-session"; | import { revokeAsync } from "expo-auth-session"; | ||||
| import variables from "../variables"; | |||||
| import variables from "../utils/variables"; | |||||
| const useAuthHook = () => { | const useAuthHook = () => { | ||||
| const [request, response, promptAsync] = Google.useAuthRequest({ | const [request, response, promptAsync] = Google.useAuthRequest({ |
| import { selectIsLoadingByActionType } from "../store/selectors/loadingSelectors"; | import { selectIsLoadingByActionType } from "../store/selectors/loadingSelectors"; | ||||
| import { LOGIN_USER_SCOPE } from "../store/actions/login/loginActionConstants"; | import { LOGIN_USER_SCOPE } from "../store/actions/login/loginActionConstants"; | ||||
| import { fetchAuthProvider } from "../store/actions/authProvider/authProviderActions"; | import { fetchAuthProvider } from "../store/actions/authProvider/authProviderActions"; | ||||
| import useAuthHook from "../utils/hooks/useAuthHook"; | |||||
| import useAuthHook from "../hooks/useAuthHook"; | |||||
| import { storeData } from "../service/asyncStorage"; | import { storeData } from "../service/asyncStorage"; | ||||
| import { ACCESS_TOKEN } from "../constants/localStorage"; | import { ACCESS_TOKEN } from "../constants/localStorage"; | ||||
| clearRegisterErrors, | clearRegisterErrors, | ||||
| registerUser, | registerUser, | ||||
| } from "../store/actions/register/registerActions"; | } from "../store/actions/register/registerActions"; | ||||
| import useAuthHook from "../utils/hooks/useAuthHook"; | |||||
| import useAuthHook from "../hooks/useAuthHook"; | |||||
| import { fetchAuthProvider } from "../store/actions/authProvider/authProviderActions"; | import { fetchAuthProvider } from "../store/actions/authProvider/authProviderActions"; | ||||
| import { ACCESS_TOKEN } from "../constants/localStorage"; | import { ACCESS_TOKEN } from "../constants/localStorage"; | ||||
| import { storeData } from "../service/asyncStorage"; | import { storeData } from "../service/asyncStorage"; |
| import React from 'react'; | import React from 'react'; | ||||
| import { View, Text, StyleSheet } from 'react-native'; | |||||
| import { View, Text, StyleSheet, TouchableOpacity } from 'react-native'; | |||||
| const SettingsScreen = () => { | |||||
| const SettingsScreen = ({navigation}) => { | |||||
| return ( | return ( | ||||
| <View style={styles.container}> | <View style={styles.container}> | ||||
| <Text>Settings</Text> | <Text>Settings</Text> | ||||
| <TouchableOpacity onPress={() => navigation.goBack()}> | |||||
| <Text>Go Back</Text> | |||||
| </TouchableOpacity> | |||||
| <TouchableOpacity onPress={() => navigation.openDrawer()}> | |||||
| <Text>Open drawer</Text> | |||||
| </TouchableOpacity> | |||||
| </View> | </View> | ||||
| ) | ) | ||||
| } | } |
| SUCCESS, | SUCCESS, | ||||
| UPDATE, | UPDATE, | ||||
| SUBMIT, | SUBMIT, | ||||
| } from '../actions/actionHelpers'; | |||||
| import { addLoader, removeLoader } from '../actions/app/appActions'; | |||||
| } from "../actions/actionHelpers"; | |||||
| import { addLoader, removeLoader } from "../actions/app/appActions"; | |||||
| const promiseTypes = [FETCH, UPDATE, DELETE, SUBMIT]; | const promiseTypes = [FETCH, UPDATE, DELETE, SUBMIT]; | ||||
| export default ({ dispatch }) => (next) => (action) => { | |||||
| const promiseType = promiseTypes.find((promiseType) => | |||||
| action.type.includes(promiseType), | |||||
| ); | |||||
| if (promiseType) { | |||||
| dispatch(addLoader(action.type)); | |||||
| return next(action); | |||||
| } | |||||
| export default ({ dispatch }) => | |||||
| (next) => | |||||
| (action) => { | |||||
| const promiseType = promiseTypes.find((promiseType) => | |||||
| action.type.includes(promiseType) | |||||
| ); | |||||
| if (promiseType) { | |||||
| dispatch(addLoader(action.type)); | |||||
| return next(action); | |||||
| } | |||||
| if (action.type.includes(SUCCESS) || action.type.includes(ERROR)) { | |||||
| // const actionType = action.type.includes(SUCCESS) | |||||
| // ? action.type.replace(SUCCESS, '[LOADING]') | |||||
| // : action.type.replace(ERROR, '[LOADING]'); | |||||
| dispatch(removeLoader(action.type)); | |||||
| return next(action); | |||||
| } | |||||
| next(action); | |||||
| }; | |||||
| if (action.type.includes(SUCCESS) || action.type.includes(ERROR)) { | |||||
| dispatch(removeLoader(action.type)); | |||||
| return next(action); | |||||
| } | |||||
| next(action); | |||||
| }; |