Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
beasy-mobile
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
4
Issues
4
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
G
beasy-mobile
Commits
e9fa692c
Commit
e9fa692c
authored
May 07, 2024
by
G
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user can login with valid credentials and be redirected to the home screen
parent
c43baa54
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
4 deletions
+44
-4
UserLoginScreen.tsx
src/screens/UserLoginScreen.tsx
+44
-4
No files found.
src/screens/UserLoginScreen.tsx
View file @
e9fa692c
import
{
useUserAuthenticationContext
}
from
"@/contexts/UserAuthenticationContext"
;
import
type
{
UnloggedUserStackScreenComponentProps
}
from
"@/navigations/Types"
;
import
authenticateUser
from
"@/utils/requests/authenticateUser"
;
import
Button
from
"@components/Button"
;
import
ContainerBorderTopCurved
from
"@components/ContainerBorderTopCurved"
;
import
Input
from
"@components/Input"
;
...
...
@@ -7,6 +9,8 @@ import Box from "@components/bases/Box";
import
Text
from
"@components/bases/Text"
;
import
{
Fontisto
}
from
"@expo/vector-icons"
;
import
{
containers
}
from
"@styles/Commons"
;
import
{
useMutation
}
from
"@tanstack/react-query"
;
import
{
useCallback
,
useState
}
from
"react"
;
import
{
KeyboardAvoidingView
,
Platform
,
TouchableOpacity
,
View
}
from
"react-native"
;
import
{
useSafeAreaInsets
}
from
"react-native-safe-area-context"
;
...
...
@@ -14,12 +18,34 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen">
navigation
,
})
=>
{
const
insets
=
useSafeAreaInsets
();
const
{
setAuthenticationData
}
=
useUserAuthenticationContext
();
const
[
email
,
setEmail
]
=
useState
(
""
);
const
[
password
,
setPassword
]
=
useState
(
""
);
const
authenticationMutation
=
useMutation
({
mutationFn
:
authenticateUser
,
onSuccess
:
(
data
)
=>
{
setAuthenticationData
(
data
);
navigation
.
navigate
(
"bottomTabs"
);
},
onError
:
(
error
)
=>
{
console
.
error
(
"error :: "
,
error
);
},
});
const
submit
=
useCallback
(()
=>
{
authenticationMutation
.
mutate
({
username
:
email
,
password
:
password
,
});
},
[
email
,
password
,
authenticationMutation
]);
return
(
<
BackgroundDefault
>
<
View
style=
{
[
containers
.
containerFull
,
{
paddingTop
:
insets
.
top
}]
}
>
<
KeyboardAvoidingView
behavior=
{
Platform
.
OS
===
"ios"
?
"
height"
:
"height
"
}
behavior=
{
Platform
.
OS
===
"ios"
?
"
padding"
:
"position
"
}
style=
{
{
flex
:
1
}
}
>
<
Box
style=
{
{
height
:
"20%"
}
}
px=
{
"l"
}
>
...
...
@@ -48,8 +74,19 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen">
</
Box
>
<
Box
gap=
{
"m"
}
>
<
Input
label=
"Email"
/>
<
Input
label=
"Mot de passe"
secureTextEntry=
{
true
}
/>
<
Input
label=
"Email"
// value={email}
textContentType=
"emailAddress"
onChangeText=
{
setEmail
}
/>
<
Input
label=
"Mot de passe"
secureTextEntry=
{
true
}
textContentType=
"oneTimeCode"
// value={password}
onChangeText=
{
setPassword
}
/>
</
Box
>
</
Box
>
<
Box
p=
{
"s"
}
>
...
...
@@ -57,7 +94,10 @@ const UserLoginScreen: UnloggedUserStackScreenComponentProps<"userLoginScreen">
variant=
{
"full"
}
textVariants=
{
"primary"
}
label=
"Se connecter"
onPress=
{
()
=>
navigation
.
navigate
(
"bottomTabs"
)
}
onPress=
{
()
=>
{
// navigation.navigate("bottomTabs");
submit
();
}
}
/>
<
Button
variant=
{
"lightGray"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment