@fto-consult/expo-ui 7.8.1 → 7.8.4
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/package.json +2 -2
- package/src/screens/Auth/Profile.js +18 -5
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fto-consult/expo-ui",
|
3
|
-
"version": "7.8.
|
3
|
+
"version": "7.8.4",
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
5
5
|
"scripts": {
|
6
6
|
"clear-npx-cache": "npx clear-npx-cache",
|
@@ -72,7 +72,7 @@
|
|
72
72
|
"@expo/vector-icons": "^13.0.0",
|
73
73
|
"@faker-js/faker": "^8.0.2",
|
74
74
|
"@fto-consult/common": "^3.75.1",
|
75
|
-
"@fto-consult/electron-gen": "^1.3.
|
75
|
+
"@fto-consult/electron-gen": "^1.3.5",
|
76
76
|
"@pchmn/expo-material3-theme": "^1.3.1",
|
77
77
|
"@react-native-async-storage/async-storage": "1.18.2",
|
78
78
|
"@react-native-community/datetimepicker": "7.2.0",
|
@@ -11,7 +11,7 @@ import useContext from "$econtext/hooks";
|
|
11
11
|
import PropTypes from "prop-types";
|
12
12
|
import APP from "$capp/instance";
|
13
13
|
import {isElectron} from "$cplatform";
|
14
|
-
import {isValidUrl} from "$cutils
|
14
|
+
import {isValidUrl} from "$cutils";
|
15
15
|
import {screenName} from "./utils";
|
16
16
|
|
17
17
|
export default function UserProfileScreen({fields,...p}){
|
@@ -34,6 +34,17 @@ export default function UserProfileScreen({fields,...p}){
|
|
34
34
|
})
|
35
35
|
const p2 = {...p,fields};
|
36
36
|
const props = typeof profilePropsMutator =='function'? extendObj({},p,profilePropsMutator(p2)) : p2;
|
37
|
+
const {changeElectronAppUrlPerm} = props;
|
38
|
+
const changeElectronUrl = React.useMemo(()=>{
|
39
|
+
if(!isElectron() || !window?.ELECTRON || typeof ELECTRON?.setAppUrl !=='function' || typeof ELECTRON?.getAppUrl !=='function') return false;
|
40
|
+
if(typeof changeElectronAppUrlPerm ==='string'){
|
41
|
+
return Auth.isAllowedFromStr(changeElectronAppUrlPerm);
|
42
|
+
} else if(typeof changeElectronAppUrlPerm =='function'){
|
43
|
+
return !!canChangeElectronAppUrl(props);
|
44
|
+
}
|
45
|
+
return Auth.isMasterAdmin();
|
46
|
+
|
47
|
+
},[changeElectronAppUrlPerm])
|
37
48
|
const user = defaultObj(props.user,Auth.getLoggedUser());
|
38
49
|
const testID = defaultStr(props.testID,"RN_UserProfile_FormData");
|
39
50
|
const themeRef = React.useRef(defaultObj(user.theme));
|
@@ -67,7 +78,7 @@ export default function UserProfileScreen({fields,...p}){
|
|
67
78
|
if(args.value === user.avatar) return;
|
68
79
|
hasChangeRef.current = true;
|
69
80
|
}
|
70
|
-
if(
|
81
|
+
if(changeElectronUrl){
|
71
82
|
fields.mainElectronAppUrl = {
|
72
83
|
label : "Url de l'application",
|
73
84
|
onValidatorValid : ({value})=>{
|
@@ -75,7 +86,7 @@ export default function UserProfileScreen({fields,...p}){
|
|
75
86
|
return "Vous devez spécifier une adresse url valide";
|
76
87
|
}
|
77
88
|
},
|
78
|
-
defaultValue : ELECTRON.
|
89
|
+
defaultValue : ELECTRON.getAppUrl(),
|
79
90
|
};
|
80
91
|
}
|
81
92
|
const onSaveProfile = ({data,goBack,...rest})=>{
|
@@ -83,8 +94,8 @@ export default function UserProfileScreen({fields,...p}){
|
|
83
94
|
Preloader.open("Modification en cours...");
|
84
95
|
const toSave = {...user,...data};
|
85
96
|
return Auth.upsertUser(toSave,true).then((response)=>{
|
86
|
-
if(
|
87
|
-
ELECTRON.
|
97
|
+
if(changeElectronUrl){
|
98
|
+
ELECTRON.setAppUrl(data.mainElectronAppUrl);
|
88
99
|
}
|
89
100
|
setTimeout(()=>{
|
90
101
|
APP.trigger(APP.EVENTS.UPDATE_THEME,user.theme);
|
@@ -95,6 +106,8 @@ export default function UserProfileScreen({fields,...p}){
|
|
95
106
|
return goBack(true);
|
96
107
|
}
|
97
108
|
navigate('Home');
|
109
|
+
}).catch(e=>{
|
110
|
+
console.log(e," is ssssssssssssssssss");
|
98
111
|
}).finally(()=>{
|
99
112
|
setTimeout(()=>{
|
100
113
|
Preloader.close();
|