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 { getAbbreviatedName, handleSubmitLogInPerfil } from './utils';
5
+ import { handleSubmitLogInPerfil } from './utils';
6
6
  export default memo(({ routeOnSuccess, onSuccess }) => {
7
- const { user_id, mail, first_name, second_name, last_name, color } = useLocalSearchParams();
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={getAbbreviatedName({ first_name, last_name, mail })} 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,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
- username = username.trim();
22
- const mail = username.includes('@') ? username : `${username}@pytech.com`;
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
- return { succeded: false, message: errorUsers.message };
27
- if (dataUsers.length === 0)
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
- return { succeded: false, message: error.message };
33
- if (data.length === 0)
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: { ...data[0], user_id: dataUsers[0].id, mail: mail } });
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 }) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "native-pytech",
3
- "version": "1.0.4",
3
+ "version": "1.0.8",
4
4
  "description": "Libreria de React Native Pytech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",