@fto-consult/expo-ui 1.1.35 → 1.1.37

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.
package/babel.config.js CHANGED
@@ -25,7 +25,6 @@ module.exports = function(api,opts) {
25
25
  }
26
26
  }
27
27
  const alias = require("./babel.config.alias")(options);
28
- console.log("showing alias ",alias);
29
28
  return {
30
29
  presets: [
31
30
  ['babel-preset-expo'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "1.1.35",
3
+ "version": "1.1.37",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -61,7 +61,7 @@
61
61
  "@expo/html-elements": "^0.2.0",
62
62
  "@expo/metro-config": "^0.4.0",
63
63
  "@expo/webpack-config": "^0.17.2",
64
- "@fto-consult/common": "^1.1.28",
64
+ "@fto-consult/common": "^1.1.29",
65
65
  "@gorhom/portal": "^1.0.14",
66
66
  "@react-native-async-storage/async-storage": "~1.17.3",
67
67
  "@react-native-community/datetimepicker": "6.2.0",
package/src/auth/Login.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import React from "$react";
2
- import {isNonNullString,defaultNumber,defaultStr,uniqid,extendObj,isFunction} from "$utils";
2
+ import {isNonNullString,isObj,defaultNumber,defaultStr,uniqid,extendObj,isFunction} from "$utils";
3
3
  import {navigate} from "$cnavigation";
4
4
  import FormData from "$ecomponents/Form/FormData/FormData";
5
5
  import {getForm} from "$ecomponents/Form/utils";
@@ -37,7 +37,12 @@ export default function LoginComponent(props){
37
37
  const _getForm = x=> getForm(formName);
38
38
 
39
39
  const auth = useAuth();
40
- const notifyUser = (message)=> notify.error({message,position:'top'})
40
+ const notifyUser = (message,title)=> {
41
+ if(isObj(message)){
42
+ return notify.error({...message,position:'top'})
43
+ } else if(typeof message =='object') return false;
44
+ return notify.error({message,title,position:'top'});
45
+ }
41
46
  const [state,setState] = React.useState({
42
47
  step : defaultNumber(step,1),
43
48
  data : defaultObj(props.data),
@@ -77,6 +82,9 @@ export default function LoginComponent(props){
77
82
  const {header,children,data:loginData,canGoToNext,keyboardEvents,onSuccess:onLoginSuccess,canSubmit:canSubmitForm,onStepChange,...loginProps} = defaultObj(getProps({
78
83
  ...state,
79
84
  state,
85
+ showError : notifyUser,
86
+ notifyUser,
87
+ notify,
80
88
  getForm,
81
89
  getData,
82
90
  focusField,
@@ -118,18 +126,24 @@ export default function LoginComponent(props){
118
126
  return
119
127
  }
120
128
  }
121
- if(canSubmit(args) && step > 1){
122
- Preloader.open("vérification ...");
123
- return auth.signIn(data).then((a)=>{
124
- if(typeof onLoginSuccess =='function' && onLoginSuccess(a)=== false) return;
125
- if(isFunction(onSuccess)){
126
- onSuccess(data);
127
- } else {
128
- navigate("Home");
129
- }
130
- }).finally(()=>{
131
- Preloader.close();
132
- })
129
+ if(step > 1){
130
+ if(!form.isValid()){
131
+ notifyUser(form.getErrorText());
132
+ return;
133
+ }
134
+ if(canSubmit(args)){
135
+ Preloader.open("vérification ...");
136
+ return auth.signIn(data).then((a)=>{
137
+ if(typeof onLoginSuccess =='function' && onLoginSuccess(a)=== false) return;
138
+ if(isFunction(onSuccess)){
139
+ onSuccess(data);
140
+ } else {
141
+ navigate("Home");
142
+ }
143
+ }).finally(()=>{
144
+ Preloader.close();
145
+ })
146
+ }
133
147
  } else {
134
148
  setState({...state,step:step+1,data})
135
149
  }
@@ -777,7 +777,7 @@ export default class Field extends AppComponent {
777
777
  const isFilter = this.isFilter();
778
778
  rest = defaultObj(rest);
779
779
  data = defaultObj(data);
780
- label = defaultVal(label,text);
780
+ this.label = label = defaultVal(label,text);
781
781
  rest.name = this.name;
782
782
  rest.label = label;
783
783
  rest.data = data;
@@ -29,7 +29,6 @@ export default class FormComponent extends React.AppComponent {
29
29
  this.resetFields = this.resetFields.bind(this);
30
30
  this.getData = this.getData.bind(this);
31
31
  Forms.trigger("mount",props.name,this);
32
-
33
32
  }
34
33
  getErrorText(){
35
34
  return defaultStr(this.___errorText);