|
@@ -35,11 +35,13 @@ import LoginForm from '../../components/Amicale/Login/LoginForm';
|
35
|
35
|
import { useFocusEffect, useNavigation } from '@react-navigation/native';
|
36
|
36
|
import { TabRoutes } from '../../navigation/TabNavigator';
|
37
|
37
|
import { useShouldShowMascot } from '../../context/preferencesContext';
|
|
38
|
+import { useLogin } from '../../context/loginContext';
|
38
|
39
|
|
39
|
40
|
type Props = StackScreenProps<MainStackParamsList, 'login'>;
|
40
|
41
|
|
41
|
42
|
function LoginScreen(props: Props) {
|
42
|
43
|
const navigation = useNavigation<StackNavigationProp<any>>();
|
|
44
|
+ const { setLogin } = useLogin();
|
43
|
45
|
const [loading, setLoading] = useState(false);
|
44
|
46
|
const [nextScreen, setNextScreen] = useState<string | undefined>(undefined);
|
45
|
47
|
const [mascotDialogVisible, setMascotDialogVisible] = useState(false);
|
|
@@ -88,11 +90,12 @@ function LoginScreen(props: Props) {
|
88
|
90
|
* Navigates to the screen specified in navigation parameters or simply go back tha stack.
|
89
|
91
|
* Saves in user preferences to not show the login banner again.
|
90
|
92
|
*/
|
91
|
|
- const handleSuccess = () => {
|
|
93
|
+ const handleSuccess = (token: string) => {
|
92
|
94
|
// Do not show the home login banner again
|
93
|
95
|
if (homeMascot.shouldShow) {
|
94
|
96
|
homeMascot.setShouldShow(false);
|
95
|
97
|
}
|
|
98
|
+ setLogin(token);
|
96
|
99
|
if (!nextScreen) {
|
97
|
100
|
navigation.goBack();
|
98
|
101
|
} else {
|
|
@@ -138,7 +141,10 @@ function LoginScreen(props: Props) {
|
138
|
141
|
emotion={MASCOT_STYLE.NORMAL}
|
139
|
142
|
/>
|
140
|
143
|
<ErrorDialog
|
141
|
|
- visible={currentError.status !== REQUEST_STATUS.SUCCESS}
|
|
144
|
+ visible={
|
|
145
|
+ currentError.status !== REQUEST_STATUS.SUCCESS ||
|
|
146
|
+ currentError.code !== undefined
|
|
147
|
+ }
|
142
|
148
|
onDismiss={hideErrorDialog}
|
143
|
149
|
status={currentError.status}
|
144
|
150
|
code={currentError.code}
|