native-pytech 1.0.4 → 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,9 +1,16 @@
|
|
|
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;
|
|
@@ -18,22 +18,28 @@ export const getAbbreviatedName = ({ first_name, last_name, mail }) => {
|
|
|
18
18
|
return name.toUpperCase();
|
|
19
19
|
};
|
|
20
20
|
export const handleSubmitLogIn = async ({ username, router }) => {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
const identifier = username.trim();
|
|
22
|
+
/*username = username.trim()
|
|
23
|
+
const mail = username.includes('@') ? username : `${username}@pytech.com`
|
|
24
|
+
|
|
23
25
|
// Obtengo el user_id
|
|
24
|
-
const { data: dataUsers, error: errorUsers } = await supabase.client.schema('admin').from('users').select('id').eq('mail', mail)
|
|
25
|
-
if (errorUsers)
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return { succeded: false, message: 'Revisa la información de la cuenta que ingresaste y vuelve a intentarlo.' };
|
|
26
|
+
const { data: dataUsers, error: errorUsers } = await supabase.client.schema('admin').from('users').select('id').eq('mail', mail)
|
|
27
|
+
if (errorUsers) return {succeded: false, message: errorUsers.message}
|
|
28
|
+
if (dataUsers.length === 0) return {succeded: false, message: 'Revisa la información de la cuenta que ingresaste y vuelve a intentarlo.'}
|
|
29
|
+
|
|
29
30
|
// Obtengo los datos del perfil
|
|
30
|
-
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
|
-
if (error)
|
|
32
|
-
|
|
33
|
-
|
|
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)
|
|
32
|
+
if (error) return {succeded: false, message: error.message}
|
|
33
|
+
if (data.length === 0) return {succeded: false, message: 'Revisa la información de la cuenta que ingresaste y vuelve a intentarlo.'}*/
|
|
34
|
+
const data = await supabase.execFunction({
|
|
35
|
+
name: 'login',
|
|
36
|
+
args: { p_identifier: identifier }
|
|
37
|
+
});
|
|
38
|
+
console.log('login', data);
|
|
39
|
+
if (!data)
|
|
34
40
|
return { succeded: false, message: 'Revisa la información de la cuenta que ingresaste y vuelve a intentarlo.' };
|
|
35
41
|
// Success
|
|
36
|
-
router.push({ pathname: '/login/inicio/perfil', params:
|
|
42
|
+
router.push({ pathname: '/login/inicio/perfil', params: data });
|
|
37
43
|
return { succeded: true, message: '' };
|
|
38
44
|
};
|
|
39
45
|
export const handleSubmitLogInPerfil = async ({ mail, password }) => {
|