native-pytech 1.0.8 → 1.0.10
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.
|
@@ -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={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'}/>}/>);
|
|
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,10 +1,5 @@
|
|
|
1
1
|
import { Router } from 'expo-router';
|
|
2
2
|
import { PerfilColorType } from '../constants';
|
|
3
|
-
export declare const getAbbreviatedName: ({ first_name, last_name, mail }: {
|
|
4
|
-
first_name?: string;
|
|
5
|
-
last_name?: string;
|
|
6
|
-
mail: string;
|
|
7
|
-
}) => string;
|
|
8
3
|
export type LoginData = {
|
|
9
4
|
first_name: string;
|
|
10
5
|
gradient_text: string;
|
|
@@ -1,45 +1,14 @@
|
|
|
1
1
|
import supabase from "../../../../libs/supabase";
|
|
2
|
-
export const getAbbreviatedName = ({ first_name, last_name, mail }) => {
|
|
3
|
-
// Si tiene "firstname" y "lastname", se usa la primera letra de cada uno
|
|
4
|
-
// Si solo tiene firstname, se usa las primeras dos letras de "firstname"
|
|
5
|
-
// Si solo tiene lastname, se usa las primeras dos letras de "lastname"
|
|
6
|
-
// No tiene ninguno, se usa las primeras dos letras de "mail"
|
|
7
|
-
const f = first_name?.[0] ?? '';
|
|
8
|
-
const l = last_name?.[0] ?? '';
|
|
9
|
-
let name = '';
|
|
10
|
-
if (f && l)
|
|
11
|
-
name = f + l;
|
|
12
|
-
else if (f)
|
|
13
|
-
name = f + (first_name?.[1] ?? f);
|
|
14
|
-
else if (l)
|
|
15
|
-
name = l + (last_name?.[1] ?? l);
|
|
16
|
-
else
|
|
17
|
-
name = mail?.slice(0, 2) ?? '';
|
|
18
|
-
return name.toUpperCase();
|
|
19
|
-
};
|
|
20
2
|
export const handleSubmitLogIn = async ({ username, router }) => {
|
|
21
3
|
const identifier = username.trim();
|
|
22
|
-
/*username = username.trim()
|
|
23
|
-
const mail = username.includes('@') ? username : `${username}@pytech.com`
|
|
24
|
-
|
|
25
|
-
// Obtengo el user_id
|
|
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
|
-
|
|
30
|
-
// Obtengo los datos del perfil
|
|
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
4
|
const data = await supabase.execFunction({
|
|
35
5
|
name: 'login',
|
|
36
6
|
args: { p_identifier: identifier }
|
|
37
7
|
});
|
|
38
|
-
|
|
39
|
-
if (!data)
|
|
8
|
+
if (!data || data.length === 0)
|
|
40
9
|
return { succeded: false, message: 'Revisa la información de la cuenta que ingresaste y vuelve a intentarlo.' };
|
|
41
10
|
// Success
|
|
42
|
-
router.push({ pathname: '/login/inicio/perfil', params: data });
|
|
11
|
+
router.push({ pathname: '/login/inicio/perfil', params: data[0] });
|
|
43
12
|
return { succeded: true, message: '' };
|
|
44
13
|
};
|
|
45
14
|
export const handleSubmitLogInPerfil = async ({ mail, password }) => {
|