native-pytech 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,9 +2,9 @@ import { useLocalSearchParams, useRouter } from 'expo-router';
|
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
import { memo } from 'react';
|
|
4
4
|
import Screen from '../Screen';
|
|
5
|
-
import {
|
|
5
|
+
import { handleSubmitLogInPerfil } from './utils';
|
|
6
6
|
export default memo(({ routeOnSuccess, onSuccess }) => {
|
|
7
|
-
const {
|
|
7
|
+
const { mail, first_name, gradient_text, color } = useLocalSearchParams();
|
|
8
8
|
const router = useRouter();
|
|
9
9
|
const handleSubmit = async ({ value }) => {
|
|
10
10
|
const { succeded, message } = await handleSubmitLogInPerfil({ mail, password: value });
|
|
@@ -15,5 +15,5 @@ export default memo(({ routeOnSuccess, onSuccess }) => {
|
|
|
15
15
|
}
|
|
16
16
|
return { succeded, message };
|
|
17
17
|
};
|
|
18
|
-
return (<Screen iconPage={<Screen.Gradient text={
|
|
18
|
+
return (<Screen iconPage={<Screen.Gradient text={gradient_text} color={color}/>} title={`¡Hola${first_name ? ` ${first_name}` : ''}!`} bottomElements={<Screen.Input placeholder='Contraseña' keyboardType='default' secureTextEntry={true} autoComplete='password' handleSubmit={handleSubmit} autoFocus={Platform.OS === 'web'}/>}/>);
|
|
19
19
|
});
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import { Router } from 'expo-router';
|
|
2
|
+
import { PerfilColorType } from '../constants';
|
|
2
3
|
export declare const getAbbreviatedName: ({ first_name, last_name, mail }: {
|
|
3
4
|
first_name?: string;
|
|
4
5
|
last_name?: string;
|
|
5
6
|
mail: string;
|
|
6
7
|
}) => string;
|
|
8
|
+
export type LoginData = {
|
|
9
|
+
first_name: string;
|
|
10
|
+
gradient_text: string;
|
|
11
|
+
color: PerfilColorType;
|
|
12
|
+
mail: string;
|
|
13
|
+
};
|
|
7
14
|
export declare const handleSubmitLogIn: ({ username, router }: {
|
|
8
15
|
username: string;
|
|
9
16
|
router: Router;
|
|
10
17
|
}) => Promise<{
|
|
11
18
|
succeded: boolean;
|
|
12
|
-
message:
|
|
19
|
+
message: string;
|
|
13
20
|
}>;
|
|
14
21
|
export declare const handleSubmitLogInPerfil: ({ mail, password }: {
|
|
15
22
|
mail: string;
|
|
@@ -18,6 +18,7 @@ export const getAbbreviatedName = ({ first_name, last_name, mail }) => {
|
|
|
18
18
|
return name.toUpperCase();
|
|
19
19
|
};
|
|
20
20
|
export const handleSubmitLogIn = async ({ username, router }) => {
|
|
21
|
+
const identifier = username.trim();
|
|
21
22
|
/*username = username.trim()
|
|
22
23
|
const mail = username.includes('@') ? username : `${username}@pytech.com`
|
|
23
24
|
|
|
@@ -30,17 +31,15 @@ export const handleSubmitLogIn = async ({ username, router }) => {
|
|
|
30
31
|
const { data, error } = await supabase.client.schema('admin').from('profiles').select('first_name,second_name,last_name,color').eq('user_id', dataUsers[0].id)
|
|
31
32
|
if (error) return {succeded: false, message: error.message}
|
|
32
33
|
if (data.length === 0) return {succeded: false, message: 'Revisa la información de la cuenta que ingresaste y vuelve a intentarlo.'}*/
|
|
33
|
-
const
|
|
34
|
+
const data = await supabase.execFunction({
|
|
34
35
|
name: 'login',
|
|
35
|
-
args: { p_identifier:
|
|
36
|
+
args: { p_identifier: identifier }
|
|
36
37
|
});
|
|
37
38
|
console.log('login', data);
|
|
38
|
-
if (error)
|
|
39
|
-
return { succeded: false, message: error.message };
|
|
40
39
|
if (!data)
|
|
41
40
|
return { succeded: false, message: 'Revisa la información de la cuenta que ingresaste y vuelve a intentarlo.' };
|
|
42
41
|
// Success
|
|
43
|
-
router.push({ pathname: '/login/inicio/perfil', params:
|
|
42
|
+
router.push({ pathname: '/login/inicio/perfil', params: data });
|
|
44
43
|
return { succeded: true, message: '' };
|
|
45
44
|
};
|
|
46
45
|
export const handleSubmitLogInPerfil = async ({ mail, password }) => {
|