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