Compare commits
39 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d41a78dad | ||
|
|
564e30ce07 | ||
|
|
cabe183f27 | ||
|
|
b2cb5182bc | ||
|
|
665cd3f3ea | ||
|
|
aedc74c50a | ||
|
|
68ea08d7a8 | ||
|
|
c62d048fba | ||
|
|
01506e126d | ||
|
|
d309c699c1 | ||
|
|
0bca8542ef | ||
|
|
17ae639c1b | ||
|
|
8931694c33 | ||
|
|
0ef471e175 | ||
|
|
66784532b4 | ||
|
|
30cda93bde | ||
|
|
a1e6083f7e | ||
|
|
182c56b72c | ||
|
|
9aa660fdb2 | ||
|
|
038220c569 | ||
|
|
8d9d117323 | ||
|
|
fbf5ba4ae7 | ||
|
|
34358f52b1 | ||
|
|
6ae2a44629 | ||
|
|
e3ee53bcd5 | ||
|
|
9527502024 | ||
|
|
b438596c9f | ||
|
|
2009925fb2 | ||
|
|
dae7b0efd2 | ||
|
|
7d80af326b | ||
|
|
b52795e588 | ||
|
|
918e20a72b | ||
|
|
64c324d30a | ||
|
|
d418f1312f | ||
|
|
ce52471941 | ||
|
|
f9a66aff00 | ||
|
|
2ca1167c57 | ||
|
|
9e178a24bb | ||
|
|
8d3a99fde4 |
88 changed files with 20223 additions and 15244 deletions
21
.editorconfig
Normal file
21
.editorconfig
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
charset = utf-8
|
||||||
|
end_of_line = lf
|
||||||
|
insert_final_newline = true
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 4
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
||||||
|
|
||||||
|
[*.{yml,yaml}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[*.{vue,js}]
|
||||||
|
indent_size = 2
|
||||||
|
|
||||||
|
[docker-compose.yml]
|
||||||
|
indent_size = 4
|
||||||
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
.vscode/*
|
||||||
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
9
.idea/com-app.iml
generated
Normal file
9
.idea/com-app.iml
generated
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/com-app.iml" filepath="$PROJECT_DIR$/.idea/com-app.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
23
.vscode/settings.json
vendored
Normal file
23
.vscode/settings.json
vendored
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"workbench.colorCustomizations": {
|
||||||
|
"activityBar.activeBackground": "#3e8040",
|
||||||
|
"activityBar.activeBorder": "#ffffff",
|
||||||
|
"activityBar.background": "#3e8040",
|
||||||
|
"activityBar.foreground": "#e7e7e7",
|
||||||
|
"activityBar.inactiveForeground": "#e7e7e799",
|
||||||
|
"activityBarBadge.background": "#aaa9d5",
|
||||||
|
"activityBarBadge.foreground": "#15202b",
|
||||||
|
"sash.hoverBorder": "#3e8040",
|
||||||
|
"statusBar.background": "#2d5e2f",
|
||||||
|
"statusBar.foreground": "#e7e7e7",
|
||||||
|
"statusBarItem.hoverBackground": "#3e8040",
|
||||||
|
"statusBarItem.remoteBackground": "#2d5e2f",
|
||||||
|
"statusBarItem.remoteForeground": "#e7e7e7",
|
||||||
|
"titleBar.activeBackground": "#8d1800",
|
||||||
|
"titleBar.activeForeground": "#e7e7e7",
|
||||||
|
"titleBar.inactiveBackground": "#2d5e2f99",
|
||||||
|
"titleBar.inactiveForeground": "#e7e7e799",
|
||||||
|
"commandCenter.border": "#e7e7e799"
|
||||||
|
},
|
||||||
|
"peacock.remoteColor": "#2d5e2f"
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
module.exports = {
|
module.exports = {
|
||||||
arrowParens: 'avoid',
|
arrowParens: 'avoid',
|
||||||
bracketSameLine: true,
|
bracketSameLine: true,
|
||||||
bracketSpacing: false,
|
bracketSpacing: true,
|
||||||
singleQuote: true,
|
singleQuote: true,
|
||||||
trailingComma: 'all',
|
trailingComma: 'all',
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,55 @@
|
||||||
# 2.0.0
|
# CHANGELOG
|
||||||
## Bug
|
|
||||||
|
## 4.0.0
|
||||||
|
|
||||||
|
### Évolution - 4.0.0
|
||||||
|
|
||||||
|
- Delete store.ldc.fr dependance
|
||||||
|
- Remove useless MySpace feature
|
||||||
|
|
||||||
|
## 3.2.1
|
||||||
|
|
||||||
|
### Évolution - 3.2.1
|
||||||
|
|
||||||
|
- Update select and select multiple fields to get list in alphabetical order
|
||||||
|
|
||||||
|
## 3.1.1
|
||||||
|
|
||||||
|
### Évolution - 3.1.1
|
||||||
|
|
||||||
|
- Update Install and Download docs call to handle tenant changes
|
||||||
|
|
||||||
|
## 3.0.1
|
||||||
|
|
||||||
|
### Bug - 3.0.1
|
||||||
|
|
||||||
|
- Fix sendBrochure call, put data into data axios object instead of params
|
||||||
|
|
||||||
|
## 3.0.0
|
||||||
|
|
||||||
|
### Bug - 3.0.0
|
||||||
|
|
||||||
|
- Fix add contact from HomeScreen Error
|
||||||
|
- Fixed appID was not properly setup `com.comapp.ldc`
|
||||||
|
- Lint du Code, Ajout de définitions
|
||||||
|
- L'ordre d'affichage des contacts est respecté
|
||||||
|
- Tri des contact lors de l'envoi d'un contact
|
||||||
|
|
||||||
|
### Évolution - 3.0.0
|
||||||
|
|
||||||
|
- Ajout d'une synchronisation users discrete on Login (pour sync les news users apres que l'app ai déjà été installé)
|
||||||
|
- Changed les Formulaires sont dynamiques
|
||||||
|
- La synchro utilise 3 méthodes pour les contacts
|
||||||
|
- Ajout de timestamp sur contact pour définir le contact le plus a jour a conserver (pour un utilisateur)
|
||||||
|
|
||||||
|
## 2.0.0
|
||||||
|
|
||||||
|
### Bug - 2.0.0
|
||||||
|
|
||||||
- Fix format vidéo lors de la rotation de l'écran
|
- Fix format vidéo lors de la rotation de l'écran
|
||||||
## Évolution
|
|
||||||
|
### Évolution - 2.0.0
|
||||||
|
|
||||||
- Bump React Native 0.70.1 -> 0.70.6
|
- Bump React Native 0.70.1 -> 0.70.6
|
||||||
- Amélioration de l'usage de Redux avec reducers, actions, etc.
|
- Amélioration de l'usage de Redux avec reducers, actions, etc.
|
||||||
- Amélioration sur l'arborescence du projet.
|
- Amélioration sur l'arborescence du projet.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,18 @@
|
||||||
# ComApp
|
# ComApp
|
||||||
|
|
||||||
|
# Run with Windows + WSL
|
||||||
|
|
||||||
|
- Install Android studio and create a Virtual Device
|
||||||
|
- Launch emulator
|
||||||
|
- In WSL :
|
||||||
|
```bash
|
||||||
|
adb reverse tcp:8081 tcp:8081
|
||||||
|
npx react-native start // TO start metro
|
||||||
|
npx react-native run-android --deviceId emulator-5554 // TO build and run to this Emulator
|
||||||
|
```
|
||||||
|
|
||||||
|
You can set internet proxy in emulator params
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
- i18n-js
|
- i18n-js
|
||||||
- @react-native-community/netinfo
|
- @react-native-community/netinfo
|
||||||
|
|
@ -26,3 +40,7 @@
|
||||||
- react-native-flash-message
|
- react-native-flash-message
|
||||||
- @react-native-picker/picker
|
- @react-native-picker/picker
|
||||||
- vcard-parser
|
- vcard-parser
|
||||||
|
- react-native-email-link
|
||||||
|
- buffer
|
||||||
|
- react-native-sectioned-multi-select
|
||||||
|
- react-native-uuid
|
||||||
|
|
|
||||||
|
|
@ -35,12 +35,12 @@ android_library(
|
||||||
|
|
||||||
android_build_config(
|
android_build_config(
|
||||||
name = "build_config",
|
name = "build_config",
|
||||||
package = "com.comapp",
|
package = "com.comapp.ldc",
|
||||||
)
|
)
|
||||||
|
|
||||||
android_resource(
|
android_resource(
|
||||||
name = "res",
|
name = "res",
|
||||||
package = "com.comapp",
|
package = "com.comapp.ldc",
|
||||||
res = "src/main/res",
|
res = "src/main/res",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ android {
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "2.0.0"
|
versionName "4.0.0"
|
||||||
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
||||||
|
|
||||||
if (isNewArchitectureEnabled()) {
|
if (isNewArchitectureEnabled()) {
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
* <p>This source code is licensed under the MIT license found in the LICENSE file in the root
|
||||||
* directory of this source tree.
|
* directory of this source tree.
|
||||||
*/
|
*/
|
||||||
package com.comapp;
|
package com.comapp.ldc;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import com.facebook.flipper.android.AndroidFlipperClient;
|
import com.facebook.flipper.android.AndroidFlipperClient;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.comapp">
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.comapp.ldc">
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
<uses-permission android:name="android.permission.CAMERA"/>
|
<uses-permission android:name="android.permission.CAMERA"/>
|
||||||
<application
|
<application
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.comapp;
|
package com.comapp.ldc;
|
||||||
|
|
||||||
import expo.modules.ReactActivityDelegateWrapper;
|
import expo.modules.ReactActivityDelegateWrapper;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.comapp;
|
package com.comapp.ldc;
|
||||||
|
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import expo.modules.ApplicationLifecycleDispatcher;
|
import expo.modules.ApplicationLifecycleDispatcher;
|
||||||
|
|
@ -13,7 +13,7 @@ import com.facebook.react.ReactNativeHost;
|
||||||
import com.facebook.react.ReactPackage;
|
import com.facebook.react.ReactPackage;
|
||||||
import com.facebook.react.config.ReactFeatureFlags;
|
import com.facebook.react.config.ReactFeatureFlags;
|
||||||
import com.facebook.soloader.SoLoader;
|
import com.facebook.soloader.SoLoader;
|
||||||
import com.comapp.newarchitecture.MainApplicationReactNativeHost;
|
import com.comapp.ldc.newarchitecture.MainApplicationReactNativeHost;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -81,7 +81,7 @@ public class MainApplication extends Application implements ReactApplication {
|
||||||
We use reflection here to pick up the class that initializes Flipper,
|
We use reflection here to pick up the class that initializes Flipper,
|
||||||
since Flipper library is not available in release mode
|
since Flipper library is not available in release mode
|
||||||
*/
|
*/
|
||||||
Class<?> aClass = Class.forName("com.comapp.ReactNativeFlipper");
|
Class<?> aClass = Class.forName("com.comapp.ldc.ReactNativeFlipper");
|
||||||
aClass
|
aClass
|
||||||
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
|
.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class)
|
||||||
.invoke(null, context, reactInstanceManager);
|
.invoke(null, context, reactInstanceManager);
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.comapp.newarchitecture;
|
package com.comapp.ldc.newarchitecture;
|
||||||
|
|
||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
@ -19,9 +19,9 @@ import com.facebook.react.fabric.CoreComponentsRegistry;
|
||||||
import com.facebook.react.fabric.FabricJSIModuleProvider;
|
import com.facebook.react.fabric.FabricJSIModuleProvider;
|
||||||
import com.facebook.react.fabric.ReactNativeConfig;
|
import com.facebook.react.fabric.ReactNativeConfig;
|
||||||
import com.facebook.react.uimanager.ViewManagerRegistry;
|
import com.facebook.react.uimanager.ViewManagerRegistry;
|
||||||
import com.comapp.BuildConfig;
|
import com.comapp.ldc.BuildConfig;
|
||||||
import com.comapp.newarchitecture.components.MainComponentsRegistry;
|
import com.comapp.ldc.newarchitecture.components.MainComponentsRegistry;
|
||||||
import com.comapp.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
|
import com.comapp.ldc.newarchitecture.modules.MainApplicationTurboModuleManagerDelegate;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.comapp.newarchitecture.components;
|
package com.comapp.ldc.newarchitecture.components;
|
||||||
|
|
||||||
import com.facebook.jni.HybridData;
|
import com.facebook.jni.HybridData;
|
||||||
import com.facebook.proguard.annotations.DoNotStrip;
|
import com.facebook.proguard.annotations.DoNotStrip;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package com.comapp.newarchitecture.modules;
|
package com.comapp.ldc.newarchitecture.modules;
|
||||||
|
|
||||||
import com.facebook.jni.HybridData;
|
import com.facebook.jni.HybridData;
|
||||||
import com.facebook.react.ReactPackage;
|
import com.facebook.react.ReactPackage;
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,5 @@ newArchEnabled=false
|
||||||
|
|
||||||
MYAPP_UPLOAD_STORE_FILE=upload.keystore
|
MYAPP_UPLOAD_STORE_FILE=upload.keystore
|
||||||
MYAPP_UPLOAD_KEY_ALIAS=app-native-1
|
MYAPP_UPLOAD_KEY_ALIAS=app-native-1
|
||||||
MYAPP_UPLOAD_STORE_PASSWORD=9LjCAts7qtetVqMT
|
MYAPP_UPLOAD_STORE_PASSWORD=
|
||||||
MYAPP_UPLOAD_KEY_PASSWORD=9LjCAts7qtetVqMT
|
MYAPP_UPLOAD_KEY_PASSWORD=
|
||||||
|
|
|
||||||
1481
ComApp/package-lock.json
generated
1481
ComApp/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -11,16 +11,17 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@react-native-community/netinfo": "^9.3.7",
|
"@react-native-community/netinfo": "^9.3.7",
|
||||||
"@react-native-community/slider": "^4.3.2",
|
"@react-native-community/slider": "4.2.4",
|
||||||
"@react-native-picker/picker": "^2.4.6",
|
"@react-native-picker/picker": "^2.4.6",
|
||||||
"@react-navigation/native": "^6.0.13",
|
"@react-navigation/native": "^6.0.13",
|
||||||
"@react-navigation/native-stack": "^6.9.0",
|
"@react-navigation/native-stack": "^6.9.0",
|
||||||
"@rneui/base": "^0.0.0-edge.2",
|
"@rneui/base": "^4.0.0-rc.7",
|
||||||
"@rneui/themed": "^0.0.0-edge.2",
|
"@rneui/themed": "^4.0.0-rc.7",
|
||||||
"@sentry/react-native": "^4.12.0",
|
"@sentry/react-native": "^4.12.0",
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
|
"buffer": "^6.0.3",
|
||||||
"expo": "^47.0.10",
|
"expo": "^47.0.10",
|
||||||
"expo-av": "^13.0.2",
|
"expo-av": "~13.0.3",
|
||||||
"expo-barcode-scanner": "^11.4.0",
|
"expo-barcode-scanner": "^11.4.0",
|
||||||
"expo-splash-screen": "^0.16.2",
|
"expo-splash-screen": "^0.16.2",
|
||||||
"expo-video-player": "^2.2.0",
|
"expo-video-player": "^2.2.0",
|
||||||
|
|
@ -33,13 +34,16 @@
|
||||||
"react-native-animated-tree-view": "^0.1.4",
|
"react-native-animated-tree-view": "^0.1.4",
|
||||||
"react-native-b-crypt-bridge": "file:react-native-b-crypt-bridge-2.1.0.tgz",
|
"react-native-b-crypt-bridge": "file:react-native-b-crypt-bridge-2.1.0.tgz",
|
||||||
"react-native-blob-util": "^0.16.2",
|
"react-native-blob-util": "^0.16.2",
|
||||||
|
"react-native-email-link": "^1.14.6",
|
||||||
"react-native-flash-message": "^0.3.1",
|
"react-native-flash-message": "^0.3.1",
|
||||||
"react-native-gesture-handler": "^2.7.0",
|
"react-native-gesture-handler": "^2.7.0",
|
||||||
"react-native-pdf": "^6.6.2",
|
"react-native-pdf": "^6.6.2",
|
||||||
"react-native-progress": "^5.0.0",
|
"react-native-progress": "^5.0.0",
|
||||||
"react-native-safe-area-context": "^4.4.1",
|
"react-native-safe-area-context": "^4.4.1",
|
||||||
"react-native-screens": "^3.18.0",
|
"react-native-screens": "^3.18.0",
|
||||||
|
"react-native-sectioned-multi-select": "^0.10.0",
|
||||||
"react-native-svg": "^13.2.0",
|
"react-native-svg": "^13.2.0",
|
||||||
|
"react-native-uuid": "^2.0.1",
|
||||||
"react-native-vector-icons": "^9.2.0",
|
"react-native-vector-icons": "^9.2.0",
|
||||||
"react-redux": "^8.0.4",
|
"react-redux": "^8.0.4",
|
||||||
"realm": "^11.0.0-rc.2",
|
"realm": "^11.0.0-rc.2",
|
||||||
|
|
@ -54,9 +58,11 @@
|
||||||
"eslint": "^7.32.0",
|
"eslint": "^7.32.0",
|
||||||
"jest": "^26.6.3",
|
"jest": "^26.6.3",
|
||||||
"metro-react-native-babel-preset": "^0.72.3",
|
"metro-react-native-babel-preset": "^0.72.3",
|
||||||
|
"patch-package": "^8.0.0",
|
||||||
"react-test-renderer": "18.1.0"
|
"react-test-renderer": "18.1.0"
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "react-native"
|
"preset": "react-native"
|
||||||
}
|
},
|
||||||
|
"postinstall": "patch-package"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
290
ComApp/patches/expo-modules-core+1.1.0.patch
Normal file
290
ComApp/patches/expo-modules-core+1.1.0.patch
Normal file
File diff suppressed because one or more lines are too long
13
ComApp/patches/react-native+0.70.6.patch
Normal file
13
ComApp/patches/react-native+0.70.6.patch
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
diff --git a/node_modules/react-native/ReactAndroid/build.gradle b/node_modules/react-native/ReactAndroid/build.gradle
|
||||||
|
index 3be8b26..3f7bba8 100644
|
||||||
|
--- a/node_modules/react-native/ReactAndroid/build.gradle
|
||||||
|
+++ b/node_modules/react-native/ReactAndroid/build.gradle
|
||||||
|
@@ -61,7 +61,7 @@ task createNativeDepsDirectories {
|
||||||
|
}
|
||||||
|
|
||||||
|
task downloadBoost(dependsOn: createNativeDepsDirectories, type: Download) {
|
||||||
|
- src("https://boostorg.jfrog.io/artifactory/main/release/${BOOST_VERSION.replace("_", ".")}/source/boost_${BOOST_VERSION}.tar.gz")
|
||||||
|
+ src("https://archives.boost.io/release/${BOOST_VERSION.replace("_", ".")}/source/boost_${BOOST_VERSION}.tar.gz")
|
||||||
|
onlyIfNewer(true)
|
||||||
|
overwrite(false)
|
||||||
|
dest(new File(downloadsDir, "boost_${BOOST_VERSION}.tar.gz"))
|
||||||
|
|
@ -1,49 +1,58 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
// Sentry
|
// Sentry
|
||||||
import * as Sentry from "@sentry/react-native";
|
import * as Sentry from '@sentry/react-native';
|
||||||
// Redux
|
// Redux
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { store } from './App/Store/ConfigureStore';
|
|
||||||
import { initDocuments } from './App/Store/Actions/documents';
|
import { initDocuments } from './App/Store/Actions/documents';
|
||||||
|
import { store } from './App/Store/ConfigureStore';
|
||||||
// Deps
|
// Deps
|
||||||
import 'react-native-gesture-handler';
|
|
||||||
import { NavigationContainer } from '@react-navigation/native';
|
import { NavigationContainer } from '@react-navigation/native';
|
||||||
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
import { createNativeStackNavigator } from '@react-navigation/native-stack';
|
||||||
import { navigationRef, navigate } from './Navigation';
|
|
||||||
import { TouchableOpacity, View, Image, Text, TextInput, Alert, DrawerLayoutAndroid, Button } from 'react-native';
|
|
||||||
import Icon from 'react-native-vector-icons/FontAwesome5';
|
|
||||||
import FlashMessage, { showMessage } from 'react-native-flash-message';
|
|
||||||
import * as SplashScreen from 'expo-splash-screen';
|
import * as SplashScreen from 'expo-splash-screen';
|
||||||
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
DrawerLayoutAndroid,
|
||||||
|
Image,
|
||||||
|
Text,
|
||||||
|
TextInput,
|
||||||
|
TouchableOpacity,
|
||||||
|
View,
|
||||||
|
} from 'react-native';
|
||||||
|
import FlashMessage, { showMessage } from 'react-native-flash-message';
|
||||||
|
import 'react-native-gesture-handler';
|
||||||
|
import Icon from 'react-native-vector-icons/FontAwesome5';
|
||||||
|
import { navigate, navigationRef } from './Navigation';
|
||||||
// Application infos
|
// Application infos
|
||||||
import * as Application from 'expo-application';
|
import * as Application from 'expo-application';
|
||||||
// i18n
|
// i18n
|
||||||
import i18n from "./I18n";
|
import i18n from './I18n';
|
||||||
// FileSytem
|
// FileSytem
|
||||||
import * as FileSystem from 'expo-file-system';
|
import * as FileSystem from 'expo-file-system';
|
||||||
// Views
|
// Views
|
||||||
|
import ContactDetailsScreen from './App/Views/ContactDetailsScreen';
|
||||||
|
import ContactScreen from './App/Views/ContactScreen';
|
||||||
|
import DirectoriesScreen from './App/Views/DirectoriesScreen';
|
||||||
|
import HomeScreen from './App/Views/HomeScreen';
|
||||||
import InstallScreen from './App/Views/InstallScreen';
|
import InstallScreen from './App/Views/InstallScreen';
|
||||||
import LoginScreen from './App/Views/LoginScreen';
|
import LoginScreen from './App/Views/LoginScreen';
|
||||||
import SyncScreen from './App/Views/SyncScreen';
|
|
||||||
import HomeScreen from './App/Views/HomeScreen';
|
|
||||||
import DirectoriesScreen from './App/Views/DirectoriesScreen';
|
|
||||||
import PDFScreen from './App/Views/PDFScreen';
|
|
||||||
import VideoScreen from './App/Views/VideoScreen';
|
|
||||||
import OnlyVideosScreen from './App/Views/OnlyVideosScreen';
|
import OnlyVideosScreen from './App/Views/OnlyVideosScreen';
|
||||||
import ContactScreen from './App/Views/ContactScreen';
|
import PDFScreen from './App/Views/PDFScreen';
|
||||||
import ContactDetailsScreen from './App/Views/ContactDetailsScreen';
|
import SearchScreen from './App/Views/SearchScreen';
|
||||||
import SearchScreen from "./App/Views/SearchScreen";
|
import SyncScreen from './App/Views/SyncScreen';
|
||||||
import MySpaceScreen from './App/Views/MySpaceScreen';
|
import VideoScreen from './App/Views/VideoScreen';
|
||||||
// Style
|
// Style
|
||||||
|
import Helpers from './App/Lib/Helpers';
|
||||||
import styles from './Resources/Styles/NavigationStyle';
|
import styles from './Resources/Styles/NavigationStyle';
|
||||||
// Controllers
|
// Controllers
|
||||||
import SyncController from './App/Controllers/SyncController';
|
import SyncController from './App/Controllers/SyncController';
|
||||||
|
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn: "https://ab87e8d840324f41873c95b06903b0bf@o4504314935640064.ingest.sentry.io/4504441255886848",
|
dsn: 'https://ab87e8d840324f41873c95b06903b0bf@o4504314935640064.ingest.sentry.io/4504441255886848',
|
||||||
});
|
});
|
||||||
|
|
||||||
Sentry.setContext("app", {
|
Sentry.setContext('app', {
|
||||||
boUrl: SyncController.getUrlBo()
|
boUrl: SyncController.getUrlBo(),
|
||||||
});
|
});
|
||||||
|
|
||||||
SplashScreen.preventAutoHideAsync(); //Keep
|
SplashScreen.preventAutoHideAsync(); //Keep
|
||||||
|
|
@ -61,7 +70,7 @@ class App extends React.Component {
|
||||||
searchTxt: '',
|
searchTxt: '',
|
||||||
sendEmail: '',
|
sendEmail: '',
|
||||||
mainColor: '',
|
mainColor: '',
|
||||||
drawerRef: React.createRef()
|
drawerRef: React.createRef(),
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|
@ -69,7 +78,7 @@ class App extends React.Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
isSetup: store.getState().app.isSetup,
|
isSetup: store.getState().app.isSetup,
|
||||||
isLogged: store.getState().app.logged,
|
isLogged: store.getState().app.logged,
|
||||||
mainColor: store.getState().app.mainColor
|
mainColor: store.getState().app.mainColor,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,9 +86,8 @@ class App extends React.Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
isSetup: store.getState().app.isSetup,
|
isSetup: store.getState().app.isSetup,
|
||||||
isLogged: store.getState().app.logged,
|
isLogged: store.getState().app.logged,
|
||||||
mainColor: store.getState().app.mainColor
|
mainColor: store.getState().app.mainColor,
|
||||||
}); // to force re-rendering
|
}); // to force re-rendering
|
||||||
console.log("state changed")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
navigationView = () => (
|
navigationView = () => (
|
||||||
|
|
@ -89,16 +97,23 @@ class App extends React.Component {
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.state.drawerRef.current.closeDrawer();
|
this.state.drawerRef.current.closeDrawer();
|
||||||
store.dispatch({ type: 'EDIT_LOCALE' });
|
store.dispatch({ type: 'EDIT_LOCALE' });
|
||||||
store.dispatch(initDocuments(store.getState().locale.locale, store.getState().directories.global))
|
store.dispatch(
|
||||||
|
initDocuments(
|
||||||
|
store.getState().locale.locale,
|
||||||
|
store.getState().directories.global,
|
||||||
|
),
|
||||||
|
);
|
||||||
}}
|
}}
|
||||||
style={styles.drawer.btn}>
|
style={styles.drawer.btn}>
|
||||||
<Image source={this.renderFlag()} style={{ width: 25, height: 25 }} />
|
<Image source={this.renderFlag()} style={{ width: 25, height: 25 }} />
|
||||||
<Text style={styles.drawer.btnText}>{i18n.t('global.change_lang')}</Text>
|
<Text style={styles.drawer.btnText}>
|
||||||
|
{i18n.t('global.change_lang')}
|
||||||
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.state.drawerRef.current.closeDrawer();
|
this.state.drawerRef.current.closeDrawer();
|
||||||
navigate('SyncScreen')
|
navigate('SyncScreen');
|
||||||
}}
|
}}
|
||||||
style={styles.drawer.btn}>
|
style={styles.drawer.btn}>
|
||||||
<Icon name="sync-alt" size={20} />
|
<Icon name="sync-alt" size={20} />
|
||||||
|
|
@ -115,7 +130,9 @@ class App extends React.Component {
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
<View>
|
<View>
|
||||||
<Text style={{ marginBottom: 10 }}>Version : {Application.nativeApplicationVersion}</Text>
|
<Text style={{ marginBottom: 10 }}>
|
||||||
|
Version : {Application.nativeApplicationVersion}
|
||||||
|
</Text>
|
||||||
<Button
|
<Button
|
||||||
title={i18n.t('global.close')}
|
title={i18n.t('global.close')}
|
||||||
color={this.state.mainColor}
|
color={this.state.mainColor}
|
||||||
|
|
@ -132,45 +149,58 @@ class App extends React.Component {
|
||||||
<DrawerLayoutAndroid
|
<DrawerLayoutAndroid
|
||||||
ref={this.state.drawerRef}
|
ref={this.state.drawerRef}
|
||||||
drawerWidth={300}
|
drawerWidth={300}
|
||||||
drawerPosition={"right"}
|
drawerPosition={'right'}
|
||||||
drawerLockMode={'locked-open'}
|
drawerLockMode={'locked-open'}
|
||||||
renderNavigationView={this.navigationView}
|
renderNavigationView={this.navigationView}>
|
||||||
>
|
|
||||||
<Stack.Navigator initialRouteName="HomeScreen">
|
<Stack.Navigator initialRouteName="HomeScreen">
|
||||||
{this.state.isSetup === false &&
|
{this.state.isSetup === false && (
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="InstallScreen"
|
name="InstallScreen"
|
||||||
component={InstallScreen}
|
component={InstallScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, i18n.t('install.installation'), false),
|
headerTitle: () =>
|
||||||
|
this.LogoTitle(
|
||||||
|
navigation,
|
||||||
|
i18n.t('install.installation'),
|
||||||
|
false,
|
||||||
|
),
|
||||||
headerRight: () => (
|
headerRight: () => (
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View
|
||||||
|
style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
store.dispatch({ type: 'EDIT_LOCALE' });
|
store.dispatch({ type: 'EDIT_LOCALE' });
|
||||||
}}
|
}}
|
||||||
style={{ marginRight: 15 }}>
|
style={{ marginRight: 15 }}>
|
||||||
<Image source={this.renderFlag()} style={{ width: 25, height: 25 }} />
|
<Image
|
||||||
|
source={this.renderFlag()}
|
||||||
|
style={{ width: 25, height: 25 }}
|
||||||
|
/>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
),
|
),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
}
|
)}
|
||||||
{this.state.isLogged === false ? (
|
{this.state.isLogged === false ? (
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="LoginScreen"
|
name="LoginScreen"
|
||||||
component={LoginScreen}
|
component={LoginScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, i18n.t('global.login'), false),
|
headerTitle: () =>
|
||||||
|
this.LogoTitle(navigation, i18n.t('global.login'), false),
|
||||||
headerRight: () => (
|
headerRight: () => (
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View
|
||||||
|
style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
store.dispatch({ type: 'EDIT_LOCALE' });
|
store.dispatch({ type: 'EDIT_LOCALE' });
|
||||||
}}
|
}}
|
||||||
style={{ marginRight: 15 }}>
|
style={{ marginRight: 15 }}>
|
||||||
<Image source={this.renderFlag()} style={{ width: 25, height: 25 }} />
|
<Image
|
||||||
|
source={this.renderFlag()}
|
||||||
|
style={{ width: 25, height: 25 }}
|
||||||
|
/>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
),
|
),
|
||||||
|
|
@ -181,18 +211,28 @@ class App extends React.Component {
|
||||||
name="HomeScreen"
|
name="HomeScreen"
|
||||||
component={HomeScreen}
|
component={HomeScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, i18n.t('global.home')),
|
headerTitle: () =>
|
||||||
|
this.LogoTitle(navigation, i18n.t('global.home')),
|
||||||
headerRight: () => (
|
headerRight: () => (
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View
|
||||||
|
style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<View style={{ flexDirection: 'row', marginRight: 50 }}>
|
<View style={{ flexDirection: 'row', marginRight: 50 }}>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={{ ...styles.searchInput, borderColor: this.state.mainColor }}
|
style={{
|
||||||
|
...styles.searchInput,
|
||||||
|
borderColor: this.state.mainColor,
|
||||||
|
}}
|
||||||
placeholder={i18n.t('global.search')}
|
placeholder={i18n.t('global.search')}
|
||||||
value={this.state.searchTxt}
|
value={this.state.searchTxt}
|
||||||
onChangeText={(text) => this.setState({ searchTxt: text })}
|
onChangeText={text =>
|
||||||
|
this.setState({ searchTxt: text })
|
||||||
|
}
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={{ ...styles.btnSearch, backgroundColor: this.state.mainColor }}
|
style={{
|
||||||
|
...styles.btnSearch,
|
||||||
|
backgroundColor: this.state.mainColor,
|
||||||
|
}}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (this.state.searchTxt.length > 0) {
|
if (this.state.searchTxt.length > 0) {
|
||||||
navigation.navigation.navigate('SearchScreen', {
|
navigation.navigation.navigate('SearchScreen', {
|
||||||
|
|
@ -205,23 +245,18 @@ class App extends React.Component {
|
||||||
<Icon name={'search'} size={20} color={'white'} />
|
<Icon name={'search'} size={20} color={'white'} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
{store.getState().app.ShowIsActive === '1' && (
|
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => navigation.navigation.navigate('MySpaceScreen')}
|
onPress={() =>
|
||||||
style={{ marginRight: 25 }}>
|
navigation.navigation.navigate('ContactScreen', {
|
||||||
<Icon name="user-circle" size={25} />
|
|
||||||
</TouchableOpacity>
|
|
||||||
)}
|
|
||||||
<TouchableOpacity
|
|
||||||
onPress={() => navigation.navigation.navigate('ContactScreen', {
|
|
||||||
action: 'add',
|
action: 'add',
|
||||||
})}
|
})
|
||||||
|
}
|
||||||
style={{ marginRight: 25 }}>
|
style={{ marginRight: 25 }}>
|
||||||
<Icon name="user-plus" size={20} />
|
<Icon name="user-plus" size={20} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.state.drawerRef.current.openDrawer()
|
this.state.drawerRef.current.openDrawer();
|
||||||
}}
|
}}
|
||||||
style={{ marginRight: 25 }}>
|
style={{ marginRight: 25 }}>
|
||||||
<Icon name="sliders-h" size={20} />
|
<Icon name="sliders-h" size={20} />
|
||||||
|
|
@ -236,25 +271,46 @@ class App extends React.Component {
|
||||||
component={SyncScreen}
|
component={SyncScreen}
|
||||||
initialParams={{ forceSync: false }}
|
initialParams={{ forceSync: false }}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, i18n.t('global.synchronization'))
|
headerTitle: () =>
|
||||||
|
this.LogoTitle(
|
||||||
|
navigation,
|
||||||
|
i18n.t('global.synchronization'),
|
||||||
|
),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="DirectoriesScreen"
|
name="DirectoriesScreen"
|
||||||
component={DirectoriesScreen}
|
component={DirectoriesScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, i18n.t('app.folders'))
|
headerTitle: () =>
|
||||||
|
this.LogoTitle(navigation, i18n.t('app.folders')),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="OnlyVideosScreen"
|
name="OnlyVideosScreen"
|
||||||
component={OnlyVideosScreen}
|
component={OnlyVideosScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, i18n.t('global.videos')),
|
headerTitle: () =>
|
||||||
|
this.LogoTitle(navigation, i18n.t('global.videos')),
|
||||||
headerRight: () => (
|
headerRight: () => (
|
||||||
<View style={{ flexDirection: 'row', marginRight: 5 }}>
|
<View style={{ flexDirection: 'row', marginRight: 5 }}>
|
||||||
<TextInput style={{ ...styles.searchInput, borderColor: this.state.mainColor }} placeholder={i18n.t('global.search')} value={this.state.searchTxt} onChangeText={(text) => this.setState({ searchTxt: text })} />
|
<TextInput
|
||||||
<TouchableOpacity style={{ ...styles.btnSearch, backgroundColor: this.state.mainColor }} onPress={() => {
|
style={{
|
||||||
|
...styles.searchInput,
|
||||||
|
borderColor: this.state.mainColor,
|
||||||
|
}}
|
||||||
|
placeholder={i18n.t('global.search')}
|
||||||
|
value={this.state.searchTxt}
|
||||||
|
onChangeText={text =>
|
||||||
|
this.setState({ searchTxt: text })
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{
|
||||||
|
...styles.btnSearch,
|
||||||
|
backgroundColor: this.state.mainColor,
|
||||||
|
}}
|
||||||
|
onPress={() => {
|
||||||
if (this.state.searchTxt.length > 0) {
|
if (this.state.searchTxt.length > 0) {
|
||||||
navigation.navigation.navigate('SearchScreen', {
|
navigation.navigation.navigate('SearchScreen', {
|
||||||
needle: this.state.searchTxt,
|
needle: this.state.searchTxt,
|
||||||
|
|
@ -273,9 +329,10 @@ class App extends React.Component {
|
||||||
name="VideoScreen"
|
name="VideoScreen"
|
||||||
component={VideoScreen}
|
component={VideoScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, i18n.t('app.video')),
|
headerTitle: () =>
|
||||||
|
this.LogoTitle(navigation, i18n.t('app.video')),
|
||||||
headerRight: () => this.SendEmail(),
|
headerRight: () => this.SendEmail(),
|
||||||
orientation: 'landscape'
|
orientation: 'landscape',
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
|
|
@ -283,14 +340,15 @@ class App extends React.Component {
|
||||||
component={PDFScreen}
|
component={PDFScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, 'PDF'),
|
headerTitle: () => this.LogoTitle(navigation, 'PDF'),
|
||||||
headerRight: () => this.SendEmail()
|
headerRight: () => this.SendEmail(),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="ContactScreen"
|
name="ContactScreen"
|
||||||
component={ContactScreen}
|
component={ContactScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, i18n.t('global.contacts'))
|
headerTitle: () =>
|
||||||
|
this.LogoTitle(navigation, i18n.t('global.contacts')),
|
||||||
})}
|
})}
|
||||||
initialParams={{ contactAdded: false }}
|
initialParams={{ contactAdded: false }}
|
||||||
/>
|
/>
|
||||||
|
|
@ -298,33 +356,16 @@ class App extends React.Component {
|
||||||
name="ContactDetailsScreen"
|
name="ContactDetailsScreen"
|
||||||
component={ContactDetailsScreen}
|
component={ContactDetailsScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, i18n.t('app.contact_details'))
|
headerTitle: () =>
|
||||||
|
this.LogoTitle(navigation, i18n.t('app.contact_details')),
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
<Stack.Screen
|
<Stack.Screen
|
||||||
name="SearchScreen"
|
name="SearchScreen"
|
||||||
component={SearchScreen}
|
component={SearchScreen}
|
||||||
options={(navigation, route) => ({
|
options={(navigation, route) => ({
|
||||||
headerTitle: () => this.LogoTitle(navigation, i18n.t('app.results_search'))
|
headerTitle: () =>
|
||||||
})}
|
this.LogoTitle(navigation, i18n.t('app.results_search')),
|
||||||
/>
|
|
||||||
<Stack.Screen
|
|
||||||
name="MySpaceScreen"
|
|
||||||
component={MySpaceScreen}
|
|
||||||
options={(navigation, route) => ({
|
|
||||||
headerTitle: () => this.LogoTitle(navigation, i18n.t('app.my_space')),
|
|
||||||
headerRight: () => (
|
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
|
||||||
<TouchableOpacity
|
|
||||||
onPress={() => {
|
|
||||||
const folder = store.getState().directories.treeview.filter(tmp => tmp.id === 1);
|
|
||||||
navigation.navigation.navigate('DirectoriesScreen', { folder: folder })
|
|
||||||
}}
|
|
||||||
style={{ marginRight: 15 }}>
|
|
||||||
<Icon name="briefcase" size={20} />
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
|
||||||
),
|
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
</Stack.Navigator>
|
</Stack.Navigator>
|
||||||
|
|
@ -338,15 +379,18 @@ class App extends React.Component {
|
||||||
LogoTitle(navigation, title, wantBtn = true) {
|
LogoTitle(navigation, title, wantBtn = true) {
|
||||||
return (
|
return (
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<TouchableOpacity onPress={() => {
|
<TouchableOpacity
|
||||||
|
onPress={() => {
|
||||||
if (wantBtn) {
|
if (wantBtn) {
|
||||||
navigation.navigation.navigate('HomeScreen')
|
navigation.navigation.navigate('HomeScreen');
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
{this.state.isSetup ? (
|
{this.state.isSetup ? (
|
||||||
<Image
|
<Image
|
||||||
style={{ width: 100, height: 50, resizeMode: 'stretch' }}
|
style={{ width: 100, height: 50, resizeMode: 'stretch' }}
|
||||||
source={{ uri: FileSystem.documentDirectory + 'RectangleLogo.png' }}
|
source={{
|
||||||
|
uri: FileSystem.documentDirectory + 'RectangleLogo.png',
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Image
|
<Image
|
||||||
|
|
@ -362,30 +406,42 @@ class App extends React.Component {
|
||||||
|
|
||||||
SendEmail() {
|
SendEmail() {
|
||||||
return (
|
return (
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center', marginRight: 10 }}>
|
<View
|
||||||
<TextInput style={{ ...styles.searchInput, borderColor: this.state.mainColor }} placeholder={i18n.t('global.email')} value={this.state.sendEmail} onChangeText={(text) => this.setState({ sendEmail: text })} />
|
style={{ flexDirection: 'row', alignItems: 'center', marginRight: 10 }}>
|
||||||
<TouchableOpacity style={{ ...styles.btnSearch, backgroundColor: this.state.mainColor }} onPress={() => {
|
<TextInput
|
||||||
|
style={{ ...styles.searchInput, borderColor: this.state.mainColor }}
|
||||||
|
placeholder={i18n.t('global.email')}
|
||||||
|
value={this.state.sendEmail}
|
||||||
|
onChangeText={text => this.setState({ sendEmail: text })}
|
||||||
|
/>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{ ...styles.btnSearch, backgroundColor: this.state.mainColor }}
|
||||||
|
onPress={() => {
|
||||||
if (this.state.sendEmail.length > 0) {
|
if (this.state.sendEmail.length > 0) {
|
||||||
if (Helpers.isEmailValid(this.state.sendEmail)) {
|
if (Helpers.isEmailValid(this.state.sendEmail)) {
|
||||||
const email = {
|
const email = {
|
||||||
email: this.state.sendEmail,
|
email: this.state.sendEmail,
|
||||||
subject: i18n.t('app.file_sharing'),
|
subject: i18n.t('app.file_sharing'),
|
||||||
message: '',
|
message: '',
|
||||||
documents: JSON.stringify([store.getState().currentOpenedDoc]),
|
documents: JSON.stringify([
|
||||||
user_id: store.getState().currentUser.id
|
store.getState().app.currentOpenedDoc,
|
||||||
|
]),
|
||||||
|
app_user_id: store.getState().app.currentUser.id,
|
||||||
};
|
};
|
||||||
store.dispatch({ type: 'SEND_BROCHURE', data: email });
|
store.dispatch({ type: 'SEND_BROCHURE', data: email });
|
||||||
showMessage({
|
showMessage({
|
||||||
message: i18n.t('global.message_sent') + '.',
|
message: i18n.t('global.message_sent') + '.',
|
||||||
description: i18n.t('global.message_will_be_sent_after_sync') + '.',
|
description:
|
||||||
|
i18n.t('global.message_will_be_sent_after_sync') + '.',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
duration: 1500,
|
duration: 1500,
|
||||||
});
|
});
|
||||||
this.setState({ sendEmail: '' });
|
this.setState({ sendEmail: '' });
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(i18n.t('global.warning') + ' !', i18n.t('error.invalid_email_address') + '.', [
|
Alert.alert(
|
||||||
{ text: 'OK' },
|
i18n.t('global.warning') + ' !',
|
||||||
],
|
i18n.t('error.invalid_email_address') + '.',
|
||||||
|
[{ text: 'OK' }],
|
||||||
{ cancelable: false },
|
{ cancelable: false },
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -400,22 +456,21 @@ class App extends React.Component {
|
||||||
renderFlag() {
|
renderFlag() {
|
||||||
let flag;
|
let flag;
|
||||||
switch (store.getState().locale.locale) {
|
switch (store.getState().locale.locale) {
|
||||||
case "fr":
|
case 'fr':
|
||||||
flag = require('./assets/img/flags/fr.png');
|
flag = require('./assets/img/flags/fr.png');
|
||||||
break;
|
break;
|
||||||
case "en":
|
case 'en':
|
||||||
flag = require('./assets/img/flags/en.png');
|
flag = require('./assets/img/flags/en.png');
|
||||||
break;
|
break;
|
||||||
case "de":
|
case 'de':
|
||||||
flag = require('./assets/img/flags/de.png');
|
flag = require('./assets/img/flags/de.png');
|
||||||
break;
|
break;
|
||||||
case "es":
|
case 'es':
|
||||||
flag = require('./assets/img/flags/es.png');
|
flag = require('./assets/img/flags/es.png');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Sentry.wrap(App);
|
export default Sentry.wrap(App);
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,23 @@
|
||||||
import { Alert } from "react-native";
|
import { Alert } from 'react-native';
|
||||||
// Lodash
|
// Lodash
|
||||||
import _ from 'lodash';
|
|
||||||
// Http Client
|
// Http Client
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
// Network Infos
|
// Network Infos
|
||||||
import NetInfo from "@react-native-community/netinfo";
|
import NetInfo from '@react-native-community/netinfo';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from "../../I18n";
|
import i18n from '../../I18n';
|
||||||
// Database
|
// Database
|
||||||
import { Setting } from "../../Database";
|
import { Setting } from '../../Database';
|
||||||
|
|
||||||
const api_token = 'G9Q62jt8eL8gN4Ls';
|
const api_token = 'G9Q62jt8eL8gN4Ls';
|
||||||
class InstallController {
|
class InstallController {
|
||||||
|
|
||||||
async getConfig(url) {
|
async getConfig(url) {
|
||||||
return axios({
|
return axios({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: url + '/api/settings',
|
url: url + '/api/settings',
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
params: {
|
params: {
|
||||||
token: api_token
|
token: api_token,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -32,32 +30,43 @@ class InstallController {
|
||||||
url: url + '/api/app',
|
url: url + '/api/app',
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
params: {
|
params: {
|
||||||
token: api_token
|
token: api_token,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
if (response.data.status === "OK") {
|
if (response.data.status === 'OK') {
|
||||||
Setting.upsert({ key: 'HomeFolders', value: JSON.stringify(response.data.datas.folders) });
|
Setting.upsert({
|
||||||
|
key: 'HomeFolders',
|
||||||
|
value: JSON.stringify(response.data.datas.folders),
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
Alert.alert(
|
||||||
|
i18n.t('alert.error'),
|
||||||
|
i18n.t('error.error_has_occurred'),
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.log(error)
|
console.error(error);
|
||||||
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
Alert.alert(
|
||||||
|
i18n.t('alert.error'),
|
||||||
|
i18n.t('error.error_has_occurred'),
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
})
|
});
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(i18n.t("alert.error"), i18n.t("error.tablet_not_connected_internet"));
|
Alert.alert(
|
||||||
|
i18n.t('alert.error'),
|
||||||
|
i18n.t('error.tablet_not_connected_internet'),
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new InstallController();
|
export default new InstallController();
|
||||||
|
|
@ -1,15 +1,11 @@
|
||||||
// Database
|
// Database
|
||||||
import { Setting } from "../../Database";
|
import { Setting } from '../../Database';
|
||||||
// BCrypt
|
// BCrypt
|
||||||
import { verify } from 'react-native-b-crypt-bridge';
|
import { verify } from 'react-native-b-crypt-bridge';
|
||||||
|
|
||||||
class LoginController {
|
class LoginController {
|
||||||
|
async verify(user, password) {
|
||||||
verify(user, password) {
|
return await verify(password, user.password);
|
||||||
return verify(
|
|
||||||
password,
|
|
||||||
user.password
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
login(user) {
|
login(user) {
|
||||||
|
|
|
||||||
|
|
@ -1,30 +1,19 @@
|
||||||
// Lodash
|
// Lodash
|
||||||
import _ from 'lodash';
|
|
||||||
// Http Client
|
// Http Client
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
// Network Infos
|
// Network Infos
|
||||||
import NetInfo from "@react-native-community/netinfo";
|
import NetInfo from '@react-native-community/netinfo';
|
||||||
// Application infos
|
|
||||||
import * as Application from 'expo-application';
|
|
||||||
// Database
|
// Database
|
||||||
import { Setting, Contact, SendBrochure, Document } from '../../Database';
|
import { Contact, Document, SendBrochure, Setting } from '../../Database';
|
||||||
|
import { ContactData } from '../Models/Contact';
|
||||||
|
|
||||||
const api_token = 'G9Q62jt8eL8gN4Ls';
|
const api_token = 'G9Q62jt8eL8gN4Ls';
|
||||||
|
|
||||||
class SyncController {
|
class SyncController {
|
||||||
|
|
||||||
getUrlBo() {
|
getUrlBo() {
|
||||||
const test = Setting.get('bo_url');
|
const test = Setting.get('bo_url');
|
||||||
if (test === false || test === undefined) {
|
if (test === null) {
|
||||||
return "noset";
|
return 'noset';
|
||||||
}
|
|
||||||
return test.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
getAppStoreUUID() {
|
|
||||||
const test = Setting.get('AppStoreUUID');
|
|
||||||
if (test === false || test === undefined) {
|
|
||||||
return "noset";
|
|
||||||
}
|
}
|
||||||
return test.value;
|
return test.value;
|
||||||
}
|
}
|
||||||
|
|
@ -33,65 +22,107 @@ class SyncController {
|
||||||
return NetInfo.fetch();
|
return NetInfo.fetch();
|
||||||
}
|
}
|
||||||
|
|
||||||
async getVersion() {
|
|
||||||
return axios({
|
|
||||||
method: 'GET',
|
|
||||||
url: this.getUrlBo() + '/api/version',
|
|
||||||
responseType: 'json',
|
|
||||||
params: {
|
|
||||||
token: api_token,
|
|
||||||
app_uuid: this.getAppStoreUUID(),
|
|
||||||
app_version: Application.nativeApplicationVersion
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async getUsers() {
|
async getUsers() {
|
||||||
return axios({
|
return axios({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
// * users.index
|
||||||
url: this.getUrlBo() + '/api/users',
|
url: this.getUrlBo() + '/api/users',
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
params: {
|
params: {
|
||||||
token: api_token
|
token: api_token,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getContacts(userId) {
|
/**
|
||||||
let contacts = Contact.getAll();
|
* @param {number} app_user_id
|
||||||
|
*/
|
||||||
|
async getContacts(app_user_id) {
|
||||||
|
// * We retrieve all contacts avec upsert and destroy
|
||||||
return axios({
|
return axios({
|
||||||
method: 'POST',
|
method: 'GET',
|
||||||
url: this.getUrlBo() + '/api/contacts',
|
// * contacts.index
|
||||||
|
url: this.getUrlBo() + `/api/contacts/${app_user_id}`,
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
params: {
|
params: {
|
||||||
token: api_token
|
token: api_token,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} app_user_id
|
||||||
|
*/
|
||||||
|
async upsertContacts(app_user_id) {
|
||||||
|
const contacts = Contact.getAll(app_user_id).map(contact => {
|
||||||
|
// * This casts contact to a simple Object
|
||||||
|
// * Realm object does not support changing prop type
|
||||||
|
/** @type {ContactData} */
|
||||||
|
contact = contact.toJSON();
|
||||||
|
// * Convert to UTC timestamp
|
||||||
|
contact.timestamp = contact.timestamp.toUTCString();
|
||||||
|
|
||||||
|
// * Unstringify complex Fields
|
||||||
|
contact.data = JSON.parse(contact.data);
|
||||||
|
contact.visits = JSON.parse(contact.visits);
|
||||||
|
return contact;
|
||||||
|
});
|
||||||
|
return axios({
|
||||||
|
method: 'POST',
|
||||||
|
// * contacts.index
|
||||||
|
url: this.getUrlBo() + `/api/contacts/${app_user_id}`,
|
||||||
|
responseType: 'json',
|
||||||
|
params: {
|
||||||
|
token: api_token,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
contacts: contacts,
|
contacts: contacts,
|
||||||
userId: userId,
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} app_user_id
|
||||||
|
*/
|
||||||
|
async deleteContacts(app_user_id) {
|
||||||
|
const contactsToDelete = Contact.getAllToDelete(app_user_id);
|
||||||
|
return axios({
|
||||||
|
method: 'DELETE',
|
||||||
|
// * contacts.index
|
||||||
|
url: this.getUrlBo() + `/api/contacts/${app_user_id}`,
|
||||||
|
responseType: 'json',
|
||||||
|
params: {
|
||||||
|
token: api_token,
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
contactUuidList: contactsToDelete.map(contact => contact.id),
|
||||||
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendBrochure(brochure) {
|
async sendBrochure(brochure) {
|
||||||
return axios({
|
return axios({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
// * send-flyers
|
||||||
url: this.getUrlBo() + '/api/sendBrochure',
|
url: this.getUrlBo() + '/api/sendBrochure',
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
params: {
|
params: {
|
||||||
token: api_token,
|
token: api_token,
|
||||||
emails: brochure,
|
|
||||||
},
|
},
|
||||||
|
data: {
|
||||||
|
emails: brochure,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getDirectories() {
|
async getDirectories() {
|
||||||
return axios({
|
return axios({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
// * directories.index
|
||||||
url: this.getUrlBo() + '/api/directories',
|
url: this.getUrlBo() + '/api/directories',
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
params: {
|
params: {
|
||||||
token: api_token
|
token: api_token,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -99,6 +130,7 @@ class SyncController {
|
||||||
async getDocuments() {
|
async getDocuments() {
|
||||||
return axios({
|
return axios({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
|
// * documents.index
|
||||||
url: this.getUrlBo() + '/api/documents',
|
url: this.getUrlBo() + '/api/documents',
|
||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
params: {
|
params: {
|
||||||
|
|
@ -107,31 +139,29 @@ class SyncController {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getFormularies() {
|
||||||
|
return axios({
|
||||||
|
method: 'GET',
|
||||||
|
// * formularies.index
|
||||||
|
url: this.getUrlBo() + '/api/formularies',
|
||||||
|
responseType: 'json',
|
||||||
|
params: {
|
||||||
|
token: api_token,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
updateLastModificationDoc(id, date) {
|
updateLastModificationDoc(id, date) {
|
||||||
Document.update({ id: id, updated_at: date.toString() }, true);
|
Document.update({ id: id, updated_at: date.toString() }, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVersion(version) {
|
/**
|
||||||
const localVersion = Setting.get('version');
|
* @param {number} app_user_id
|
||||||
if (localVersion === false || localVersion === undefined) {
|
* @returns
|
||||||
Setting.add({ key: 'version', value: version });
|
*/
|
||||||
} else {
|
isSynced(app_user_id) {
|
||||||
Setting.update({ id: localVersion.id, key: 'version', value: version });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
updateShowIsActive(value) {
|
|
||||||
const local = Setting.get('ShowIsActive');
|
|
||||||
if (local === false || local === undefined) {
|
|
||||||
Setting.add({ key: 'ShowIsActive', value: value });
|
|
||||||
} else {
|
|
||||||
Setting.update({ id: local.id, key: 'ShowIsActive', value: value });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isSynced() {
|
|
||||||
const brochures = SendBrochure.getAll();
|
const brochures = SendBrochure.getAll();
|
||||||
const Contacts = Contact.getAll();
|
const Contacts = Contact.getAll(app_user_id);
|
||||||
|
|
||||||
if (brochures !== undefined && Contacts !== undefined) {
|
if (brochures !== undefined && Contacts !== undefined) {
|
||||||
const noSynced = Contacts.filtered('synced = false');
|
const noSynced = Contacts.filtered('synced = false');
|
||||||
|
|
@ -145,12 +175,7 @@ class SyncController {
|
||||||
isLogged() {
|
isLogged() {
|
||||||
const logged = Setting.get('isLogged');
|
const logged = Setting.get('isLogged');
|
||||||
const loggedTime = Setting.get('loggedTime');
|
const loggedTime = Setting.get('loggedTime');
|
||||||
if (
|
if (logged !== null && loggedTime !== null) {
|
||||||
logged !== false &&
|
|
||||||
loggedTime !== false &&
|
|
||||||
logged !== undefined &&
|
|
||||||
loggedTime !== undefined
|
|
||||||
) {
|
|
||||||
let seconds =
|
let seconds =
|
||||||
Math.abs(new Date(Number(loggedTime.value)) - Date.now()) / 1000;
|
Math.abs(new Date(Number(loggedTime.value)) - Date.now()) / 1000;
|
||||||
if (seconds < 14400) {
|
if (seconds < 14400) {
|
||||||
|
|
@ -162,48 +187,17 @@ class SyncController {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
needSync(callback) {
|
|
||||||
NetInfo.fetch().then(state => {
|
|
||||||
if (state.isConnected) {
|
|
||||||
axios({
|
|
||||||
method: 'get',
|
|
||||||
url: this.getUrlBo() + '/version',
|
|
||||||
responseType: 'json',
|
|
||||||
params: {
|
|
||||||
token: api_token,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
.then(response => {
|
|
||||||
const localVersion = Setting.get('version');
|
|
||||||
if (
|
|
||||||
localVersion === undefined ||
|
|
||||||
localVersion === false ||
|
|
||||||
localVersion.value !== response.data.version
|
|
||||||
) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
setInstalled(remove = false) {
|
setInstalled(remove = false) {
|
||||||
if (remove) {
|
if (remove) {
|
||||||
Setting.delete('installed');
|
Setting.delete('installed');
|
||||||
} else {
|
} else {
|
||||||
Setting.add({ key: 'installed', value: "true" });
|
Setting.add({ key: 'installed', value: 'true' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
isInstalled() {
|
isInstalled() {
|
||||||
const test = Setting.get('installed');
|
const test = Setting.get('installed');
|
||||||
if (test === false || test === undefined) {
|
if (test === null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
17
ComApp/src/App/Enums/InputStatus.js
Normal file
17
ComApp/src/App/Enums/InputStatus.js
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
/** InputStatusEnum */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {keyof InputStatusKeys} InputStatus
|
||||||
|
*/
|
||||||
|
export const InputStatus = {
|
||||||
|
SYSTEM: 1,
|
||||||
|
LOCKED: 2,
|
||||||
|
DEFAULT: 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const InputStatusKeys = {
|
||||||
|
1: 'SYSTEM',
|
||||||
|
2: 'LOCKED',
|
||||||
|
3: 'DEFAULT',
|
||||||
|
};
|
||||||
25
ComApp/src/App/Enums/InputType.js
Normal file
25
ComApp/src/App/Enums/InputType.js
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
/** InputTypeEnum */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {keyof InputTypeKeys} InputType
|
||||||
|
*/
|
||||||
|
export const InputType = {
|
||||||
|
TEXT: 1,
|
||||||
|
EMAIL: 2,
|
||||||
|
PHONE: 3,
|
||||||
|
RADIO: 4,
|
||||||
|
SELECT: 5,
|
||||||
|
SELECT_MULTIPLE: 6,
|
||||||
|
CHECKBOX: 7,
|
||||||
|
};
|
||||||
|
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
const InputTypeKeys = {
|
||||||
|
1: 'TEXT',
|
||||||
|
2: 'EMAIL',
|
||||||
|
3: 'PHONE',
|
||||||
|
4: 'RADIO',
|
||||||
|
5: 'SELECT',
|
||||||
|
6: 'SELECT_MULTIPLE',
|
||||||
|
7: 'CHECKBOX',
|
||||||
|
};
|
||||||
|
|
@ -5,10 +5,8 @@ class Helpers {
|
||||||
// property doesn't exist on either object
|
// property doesn't exist on either object
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
const varA = (typeof a[key] === 'string')
|
const varA = typeof a[key] === 'string' ? a[key].toUpperCase() : a[key];
|
||||||
? a[key].toUpperCase() : a[key];
|
const varB = typeof b[key] === 'string' ? b[key].toUpperCase() : b[key];
|
||||||
const varB = (typeof b[key] === 'string')
|
|
||||||
? b[key].toUpperCase() : b[key];
|
|
||||||
|
|
||||||
let comparison = 0;
|
let comparison = 0;
|
||||||
if (varA > varB) {
|
if (varA > varB) {
|
||||||
|
|
@ -16,35 +14,65 @@ class Helpers {
|
||||||
} else if (varA < varB) {
|
} else if (varA < varB) {
|
||||||
comparison = -1;
|
comparison = -1;
|
||||||
}
|
}
|
||||||
return (
|
return order === 'desc' ? comparison * -1 : comparison;
|
||||||
(order === 'desc') ? (comparison * -1) : comparison
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
isEmailValid(email) {
|
isEmailValid(email) {
|
||||||
const expression = /(?!.*\.{2})^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([\t]*\r\n)?[\t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([\t]*\r\n)?[\t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
|
const expression =
|
||||||
|
/(?!.*\.{2})^([a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+(\.[a-z\d!#$%&'*+\-\/=?^_`{|}~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+)*|"((([\t]*\r\n)?[\t]+)?([\x01-\x08\x0b\x0c\x0e-\x1f\x7f\x21\x23-\x5b\x5d-\x7e\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|\\[\x01-\x09\x0b\x0c\x0d-\x7f\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))*(([\t]*\r\n)?[\t]+)?")@(([a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\d\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.)+([a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]|[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF][a-z\d\-._~\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]*[a-z\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])\.?$/i;
|
||||||
return expression.test(String(email).toLowerCase());
|
return expression.test(String(email).toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test url is valid
|
||||||
|
* @param {string} value Url to test.
|
||||||
|
* @returns {boolean}
|
||||||
|
*/
|
||||||
isUrlValid(value) {
|
isUrlValid(value) {
|
||||||
return /^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(value.toLowerCase());
|
const re_weburl = new RegExp(
|
||||||
}
|
'^' +
|
||||||
|
// protocol identifier (optional)
|
||||||
generateUUID() { // Public Domain/MIT
|
// short syntax // still required
|
||||||
let d = new Date().getTime();//Timestamp
|
'(?:(?:(?:https?|ftp):)?\\/\\/)' +
|
||||||
let d2 = new Date().getUTCMilliseconds() + Math.random();//Time in microseconds since page-load or 0 if unsupported
|
// user:pass BasicAuth (optional)
|
||||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
|
'(?:\\S+(?::\\S*)?@)?' +
|
||||||
let r = Math.random() * 16;//random number between 0 and 16
|
'(?:' +
|
||||||
if(d > 0){//Use timestamp until depleted
|
// IP address exclusion
|
||||||
r = (d + r)%16 | 0;
|
// private & local networks
|
||||||
d = Math.floor(d/16);
|
'(?!(?:10|127)(?:\\.\\d{1,3}){3})' +
|
||||||
} else {//Use microseconds since page-load if supported
|
'(?!(?:169\\.254|192\\.168)(?:\\.\\d{1,3}){2})' +
|
||||||
r = (d2 + r)%16 | 0;
|
'(?!172\\.(?:1[6-9]|2\\d|3[0-1])(?:\\.\\d{1,3}){2})' +
|
||||||
d2 = Math.floor(d2/16);
|
// IP address dotted notation octets
|
||||||
}
|
// excludes loopback network 0.0.0.0
|
||||||
return (c === 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
// excludes reserved space >= 224.0.0.0
|
||||||
});
|
// excludes network & broadcast addresses
|
||||||
|
// (first & last IP address of each class)
|
||||||
|
'(?:[1-9]\\d?|1\\d\\d|2[01]\\d|22[0-3])' +
|
||||||
|
'(?:\\.(?:1?\\d{1,2}|2[0-4]\\d|25[0-5])){2}' +
|
||||||
|
'(?:\\.(?:[1-9]\\d?|1\\d\\d|2[0-4]\\d|25[0-4]))' +
|
||||||
|
'|' +
|
||||||
|
// host & domain names, may end with dot
|
||||||
|
// can be replaced by a shortest alternative
|
||||||
|
// (?![-_])(?:[-\\w\\u00a1-\\uffff]{0,63}[^-_]\\.)+
|
||||||
|
'(?:' +
|
||||||
|
'(?:' +
|
||||||
|
'[a-z0-9\\u00a1-\\uffff]' +
|
||||||
|
'[a-z0-9\\u00a1-\\uffff_-]{0,62}' +
|
||||||
|
')?' +
|
||||||
|
'[a-z0-9\\u00a1-\\uffff]\\.' +
|
||||||
|
')+' +
|
||||||
|
// TLD identifier name, may end with dot
|
||||||
|
'(?:[a-z\\u00a1-\\uffff]{2,}\\.?)' +
|
||||||
|
')' +
|
||||||
|
// port number (optional)
|
||||||
|
'(?::\\d{2,5})?' +
|
||||||
|
// resource path (optional)
|
||||||
|
'(?:[/?#]\\S*)?' +
|
||||||
|
'$',
|
||||||
|
'i',
|
||||||
|
);
|
||||||
|
return re_weburl.test(value.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export default new Helpers();
|
export default new Helpers();
|
||||||
|
|
|
||||||
|
|
@ -1,107 +1,195 @@
|
||||||
|
import { default as UuidGenerator } from 'react-native-uuid';
|
||||||
|
import { UpdateMode } from 'realm';
|
||||||
|
import { InputType } from './../Enums/InputType';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {typeof ContactData} ContactData
|
||||||
|
*/
|
||||||
|
export const ContactData = {
|
||||||
|
/** @type {string|undefined} */
|
||||||
|
id: undefined,
|
||||||
|
/** @type {string} */
|
||||||
|
email: undefined,
|
||||||
|
/** @type {string|null} */
|
||||||
|
lastname: null,
|
||||||
|
/** @type {string|null} */
|
||||||
|
firstname: null,
|
||||||
|
/** @type {string|null} */
|
||||||
|
phone: null,
|
||||||
|
/** @type {Array<InputDataType>} */
|
||||||
|
data: [],
|
||||||
|
/** @type {string|null} */
|
||||||
|
notes: null,
|
||||||
|
/** @type {Array<Record<string,string>>|null} */
|
||||||
|
visits: null,
|
||||||
|
/** @type {Date} */
|
||||||
|
timestamp: null,
|
||||||
|
/** @type {number} The app user id */
|
||||||
|
app_user_id: undefined,
|
||||||
|
/** @type {number|null} The app user id that should receive this contact on sync */
|
||||||
|
send_to_app_user_id: null,
|
||||||
|
/** @type {boolean} If this model is to delete */
|
||||||
|
to_delete: false,
|
||||||
|
/** @type {boolean} This model need sync */
|
||||||
|
synced: true,
|
||||||
|
};
|
||||||
|
|
||||||
export const ContactsSchema = {
|
export const ContactsSchema = {
|
||||||
name: 'Contacts',
|
name: 'Contacts',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
id: 'int',
|
...ContactData,
|
||||||
|
...{
|
||||||
|
id: 'string',
|
||||||
email: 'string',
|
email: 'string',
|
||||||
type: 'string',
|
lastname: { type: 'string', optional: true },
|
||||||
other: { type: 'string', optional: true },
|
firstname: { type: 'string', optional: true },
|
||||||
select1: { type: 'string', optional: true },
|
phone: { type: 'string', optional: true },
|
||||||
select2: { type: 'string', optional: true },
|
/** Json encoded string of ContactData.data */
|
||||||
name: 'string',
|
data: { type: 'string', default: '[]' },
|
||||||
firstname: 'string',
|
|
||||||
company: { type: 'string', optional: true },
|
|
||||||
address: { type: 'string', optional: true },
|
|
||||||
phone: 'string',
|
|
||||||
products: { type: 'string', optional: true },
|
|
||||||
// TODO : card_url ?
|
|
||||||
notes: { type: 'string', optional: true },
|
notes: { type: 'string', optional: true },
|
||||||
visits: { type: 'string', optional: true },
|
/** Json encoded string of ContactData.visists */
|
||||||
user_id: 'int',
|
visits: { type: 'string', default: '[]' },
|
||||||
uniq_id: 'string',
|
timestamp: 'date',
|
||||||
|
send_to_app_user_id: { type: 'int', optional: true, default: null },
|
||||||
|
app_user_id: 'int',
|
||||||
to_delete: { type: 'bool', default: false },
|
to_delete: { type: 'bool', default: false },
|
||||||
synced: { type: 'bool', default: true },
|
synced: { type: 'bool', default: true },
|
||||||
},
|
},
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {typeof InputData} InputDataType
|
||||||
|
*/
|
||||||
|
export const InputData = {
|
||||||
|
title: '',
|
||||||
|
formSlug: '',
|
||||||
|
/** @type {import('./../Enums/InputType').InputType} */
|
||||||
|
type: InputType.TEXT,
|
||||||
|
/** @type {string|Array<number,string>} */
|
||||||
|
value: '',
|
||||||
|
required: false,
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Unmanaged<typeof ContactData> & import('realm').Object} Contact
|
||||||
|
*/
|
||||||
|
|
||||||
class ContactModel {
|
class ContactModel {
|
||||||
|
/**
|
||||||
|
* ContactModel
|
||||||
|
* @param {Realm} realm
|
||||||
|
*/
|
||||||
constructor(realm) {
|
constructor(realm) {
|
||||||
|
/** @type string */
|
||||||
this.schema = 'Contacts';
|
this.schema = 'Contacts';
|
||||||
|
/** @type {Realm} */
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
add(data) {
|
/** @return {Unmanaged<typeof ContactData>} */
|
||||||
data.uniq_id = data.id;
|
new() {
|
||||||
data.id = undefined;
|
return Object.assign({}, ContactData);
|
||||||
this.realm.write(() => {
|
|
||||||
if (data.id === undefined) {
|
|
||||||
let id = this.realm.objects(this.schema).max('id');
|
|
||||||
data.id = id === undefined ? 1 : id + 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set contact
|
||||||
|
* ! We can use only set since all contacts are dropped and redownloaded on sync
|
||||||
|
* @param {Contact} data
|
||||||
|
*/
|
||||||
|
set(data) {
|
||||||
|
const isNew = typeof data.id !== 'string' || !data.id?.length;
|
||||||
|
if (isNew) {
|
||||||
|
console.debug('is new', data);
|
||||||
|
// * Set Local UUID until it get synced
|
||||||
|
//* it will be ignore and new one will be generated by BO
|
||||||
|
data.id = UuidGenerator.v4();
|
||||||
|
}
|
||||||
|
this.realm.write(() => {
|
||||||
try {
|
try {
|
||||||
this.realm.create(this.schema, data, 'never');
|
this.realm.create(
|
||||||
|
this.schema,
|
||||||
|
data,
|
||||||
|
isNew ? UpdateMode.Never : UpdateMode.Modified,
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('db setting add', e);
|
console.error('db contact set', e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
upsert(data) {
|
/**
|
||||||
let tmp = this.get(data.key);
|
* get contact with uuid
|
||||||
if (tmp === false || tmp === undefined) {
|
* @param {number} app_user_id App User id
|
||||||
this.add(data);
|
* @param {string} uuid
|
||||||
} else {
|
* @returns {Contact?}
|
||||||
if (data.id === undefined) {
|
*/
|
||||||
data.id = tmp.id;
|
get(app_user_id, uuid) {
|
||||||
}
|
/** @type {import('realm').Results<Contact>} */
|
||||||
this.realm.write(() => {
|
const tmp = this.realm
|
||||||
this.realm.create(this.schema, data, 'modified');
|
.objects(this.schema)
|
||||||
});
|
.filtered(`app_user_id = ${app_user_id}`);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
update(data) {
|
|
||||||
this.realm.write(() => {
|
|
||||||
this.realm.create(this.schema, data, 'modified');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
get(id) {
|
|
||||||
let tmp = this.realm.objects(this.schema);
|
|
||||||
if (tmp.length === 0) {
|
if (tmp.length === 0) {
|
||||||
return false;
|
return null;
|
||||||
} else {
|
|
||||||
tmp = tmp.filtered('id = ' + id)[0];
|
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp.filtered(`id = '${uuid}'`)[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getByUser(userId) {
|
/**
|
||||||
let tmp = this.realm.objects(this.schema);
|
* @param {number} app_user_id App User id
|
||||||
tmp = tmp.filtered('to_delete = false AND user_id = ' + userId);
|
* @returns {import('realm').Results<Contact>}
|
||||||
return tmp;
|
*/
|
||||||
|
getAll(app_user_id) {
|
||||||
|
return this.realm
|
||||||
|
.objects(this.schema)
|
||||||
|
.filtered(`to_delete = false AND app_user_id = ${app_user_id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll() {
|
/**
|
||||||
let tmp = this.realm.objects(this.schema);
|
* @param {number} app_user_id App User id
|
||||||
return tmp;
|
* @returns {import('realm').Results<Contact>}
|
||||||
|
*/
|
||||||
|
getAllEditable(app_user_id) {
|
||||||
|
return this.realm
|
||||||
|
.objects(this.schema)
|
||||||
|
.filtered(
|
||||||
|
`to_delete = false AND send_to_app_user_id = null AND app_user_id = ${app_user_id}`,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
clear() {
|
/**
|
||||||
|
* @param {number} app_user_id App User id
|
||||||
|
* @returns {import('realm').Results<Contact>}
|
||||||
|
*/
|
||||||
|
getAllToDelete(app_user_id) {
|
||||||
|
return this.realm
|
||||||
|
.objects(this.schema)
|
||||||
|
.filtered(`to_delete = true AND app_user_id = ${app_user_id}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* delete contact with id
|
||||||
|
* @param {number} app_user_id App User id
|
||||||
|
* @param {string} uuid
|
||||||
|
*/
|
||||||
|
delete(app_user_id, uuid) {
|
||||||
|
const contact = this.get(app_user_id, uuid);
|
||||||
|
if (typeof contact === 'object') {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(this.getAll());
|
this.realm.delete(contact);
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
delete(key) {
|
|
||||||
const tmp = this.get(key);
|
|
||||||
if (typeof tmp === 'object') {
|
|
||||||
this.realm.write(() => {
|
|
||||||
this.realm.delete(tmp);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {number} app_user_id App User id
|
||||||
|
*/
|
||||||
|
clear(app_user_id) {
|
||||||
|
this.realm.write(() => {
|
||||||
|
this.realm.delete(this.getAll(app_user_id));
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ContactModel;
|
export default ContactModel;
|
||||||
|
|
|
||||||
|
|
@ -2,58 +2,91 @@ export const DirectoriesSchema = {
|
||||||
name: 'Directories',
|
name: 'Directories',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
|
/** @type {number} */
|
||||||
id: 'int',
|
id: 'int',
|
||||||
name: 'string',
|
name: 'string',
|
||||||
|
/** @type {number|null} */
|
||||||
parent: { type: 'int', optional: true },
|
parent: { type: 'int', optional: true },
|
||||||
|
/** @type {number} */
|
||||||
order: 'int',
|
order: 'int',
|
||||||
|
/** @type {number} */
|
||||||
needAuthorization: 'int',
|
needAuthorization: 'int',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Unmanaged<typeof DirectoriesSchema.properties> & import('realm').Object} Directory
|
||||||
|
*/
|
||||||
|
|
||||||
class DirectoryModel {
|
class DirectoryModel {
|
||||||
|
/**
|
||||||
|
* DirectoryModel
|
||||||
|
* @param {Realm} realm
|
||||||
|
*/
|
||||||
constructor(realm) {
|
constructor(realm) {
|
||||||
|
/** @type string */
|
||||||
this.schema = 'Directories';
|
this.schema = 'Directories';
|
||||||
|
/** @type {Realm} */
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Directory} data
|
||||||
|
*/
|
||||||
add(data) {
|
add(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.create(this.schema, data);
|
this.realm.create(this.schema, data);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Directory} data
|
||||||
|
*/
|
||||||
update(data) {
|
update(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.create(this.schema, data, 'modified');
|
this.realm.create(this.schema, data, 'modified');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get directory with id
|
||||||
|
* @param {number} id
|
||||||
|
* @returns {Directory?}
|
||||||
|
*/
|
||||||
get(id) {
|
get(id) {
|
||||||
let tmp = this.realm.objects(this.schema);
|
/** @type {import('realm').Results<Directory>} */
|
||||||
|
const tmp = this.realm.objects(this.schema);
|
||||||
if (tmp.length === 0) {
|
if (tmp.length === 0) {
|
||||||
return false;
|
return null;
|
||||||
} else {
|
|
||||||
tmp = tmp.filtered('id = ' + id)[0];
|
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp.filtered('id = ' + id)[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
getAll(role, authorizedFolders, format, lang) {
|
/**
|
||||||
if (authorizedFolders !== null && authorizedFolders !== undefined) {
|
* @param {string} role
|
||||||
authorizedFolders = JSON.parse(authorizedFolders);
|
* @param {string} authorizedDirs JSON array of {Directory}
|
||||||
}
|
* @param {boolean} format
|
||||||
|
* @param {string} lang
|
||||||
|
* @returns {import('realm').Results<Directory>}
|
||||||
|
*/
|
||||||
|
getAll(role, authorizedDirs, format, lang) {
|
||||||
|
/** @type {Array<Directory>} */
|
||||||
|
const allowedDirs =
|
||||||
|
authorizedDirs !== null && authorizedDirs !== undefined
|
||||||
|
? JSON.parse(authorizedDirs)
|
||||||
|
: [];
|
||||||
|
/** @type {import('realm').Results<Directory>} */
|
||||||
let tmp = this.realm.objects(this.schema);
|
let tmp = this.realm.objects(this.schema);
|
||||||
if (role === 'USER') {
|
if (role === 'USER') {
|
||||||
if (authorizedFolders.length > 0) {
|
if (allowedDirs.length > 0) {
|
||||||
tmp = tmp.filtered(
|
tmp = tmp.filtered(
|
||||||
'needAuthorization = 0 OR ' +
|
'needAuthorization = 0 OR ' +
|
||||||
authorizedFolders
|
allowedDirs
|
||||||
.map(folder => ' id = "' + folder.id + '"')
|
.map(directory => ' id = "' + directory.id + '"')
|
||||||
.join(' OR '),
|
.join(' OR '),
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
tmp = tmp.filtered(
|
tmp = tmp.filtered('needAuthorization = 0');
|
||||||
'needAuthorization = 0'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (format) {
|
if (format) {
|
||||||
|
|
@ -62,18 +95,28 @@ class DirectoryModel {
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Delete all */
|
||||||
clear() {
|
clear() {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(this.realm.objects(this.schema));
|
this.realm.delete(this.realm.objects(this.schema));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursive Dir filter
|
||||||
|
*
|
||||||
|
* @param {import('realm').Results<Directory>} list
|
||||||
|
* @param {string} lang
|
||||||
|
* @param {DirectoryData} parent
|
||||||
|
* @returns {DirectoryData[]}
|
||||||
|
*/
|
||||||
_recursiveDir(list, lang, parent = null) {
|
_recursiveDir(list, lang, parent = null) {
|
||||||
let root = list.filter(e => e.parent === parent);
|
const root = list.filter(e => e.parent === parent);
|
||||||
let tmp = [];
|
const tmp = [];
|
||||||
for (let i = 0; i < root.length; i++) {
|
for (let i = 0; i < root.length; i++) {
|
||||||
let childs = this._recursiveDir(list, lang, root[i].id);
|
const childs = this._recursiveDir(list, lang, root[i].id);
|
||||||
let name = JSON.parse(root[i].name);
|
/** @type {Object<string,string>} */
|
||||||
|
const name = JSON.parse(root[i].name);
|
||||||
tmp[i] = {};
|
tmp[i] = {};
|
||||||
tmp[i].id = root[i].id;
|
tmp[i].id = root[i].id;
|
||||||
tmp[i].name = this.getI18nName(lang, name);
|
tmp[i].name = this.getI18nName(lang, name);
|
||||||
|
|
@ -89,19 +132,26 @@ class DirectoryModel {
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get i18n name
|
||||||
|
* @param {string} lang
|
||||||
|
* @param {Record<string,string>} name
|
||||||
|
* @returns {string}
|
||||||
|
*/
|
||||||
getI18nName(lang, name) {
|
getI18nName(lang, name) {
|
||||||
let tmp = undefined;
|
/** @type {string} */
|
||||||
|
let tmp;
|
||||||
switch (lang) {
|
switch (lang) {
|
||||||
case "fr":
|
case 'fr':
|
||||||
tmp = name.fr;
|
tmp = name.fr;
|
||||||
break;
|
break;
|
||||||
case "en":
|
case 'en':
|
||||||
tmp = name.en;
|
tmp = name.en;
|
||||||
break;
|
break;
|
||||||
case "de":
|
case 'de':
|
||||||
tmp = name.de;
|
tmp = name.de;
|
||||||
break;
|
break;
|
||||||
case "es":
|
case 'es':
|
||||||
tmp = name.es;
|
tmp = name.es;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -110,7 +160,6 @@ class DirectoryModel {
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DirectoryModel;
|
export default DirectoryModel;
|
||||||
|
|
|
||||||
|
|
@ -2,57 +2,94 @@ export const DocumentsSchema = {
|
||||||
name: 'Documents',
|
name: 'Documents',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
|
/** @type {number} */
|
||||||
id: 'int',
|
id: 'int',
|
||||||
uuid: 'string',
|
uuid: 'string',
|
||||||
title: 'string',
|
title: 'string',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
path: 'string',
|
path: 'string',
|
||||||
|
/** @type {number} */
|
||||||
directory: 'int',
|
directory: 'int',
|
||||||
lang: 'string',
|
lang: 'string',
|
||||||
updated_at: 'string',
|
updated_at: 'string',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Unmanaged<typeof DocumentsSchema.properties> & import('realm').Object} Document
|
||||||
|
*/
|
||||||
|
|
||||||
class DocumentModel {
|
class DocumentModel {
|
||||||
|
/**
|
||||||
|
* DocumentModel
|
||||||
|
* @param {Realm} realm
|
||||||
|
*/
|
||||||
constructor(realm) {
|
constructor(realm) {
|
||||||
|
/** @type string */
|
||||||
this.schema = 'Documents';
|
this.schema = 'Documents';
|
||||||
|
/** @type {Realm} */
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
add(document) {
|
/**
|
||||||
|
* @param {Document} data
|
||||||
|
*/
|
||||||
|
add(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.create(this.schema, document, 'never');
|
this.realm.create(this.schema, data, 'never');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update(document, updatedAtChange = false) {
|
/**
|
||||||
let tmp = this.get(document.id);
|
* @param {Document} data
|
||||||
if (tmp === undefined) {
|
* @param {boolean} updatedAtChange
|
||||||
this.add(document);
|
*/
|
||||||
|
update(data, updatedAtChange = false) {
|
||||||
|
const tmp = this.get(data.id);
|
||||||
|
if (tmp === null) {
|
||||||
|
this.add(data);
|
||||||
} else {
|
} else {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
if (updatedAtChange === false) {
|
if (updatedAtChange === false) {
|
||||||
this.realm.create(this.schema, {
|
this.realm.create(
|
||||||
|
this.schema,
|
||||||
|
{
|
||||||
id: tmp.id,
|
id: tmp.id,
|
||||||
uuid: document.uuid,
|
uuid: data.uuid,
|
||||||
title: document.title,
|
title: data.title,
|
||||||
type: document.type,
|
type: data.type,
|
||||||
path: document.path,
|
path: data.path,
|
||||||
directory: document.directory
|
directory: data.directory,
|
||||||
}, 'modified');
|
},
|
||||||
|
'modified',
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this.realm.create(this.schema, document, 'modified');
|
this.realm.create(this.schema, data, 'modified');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get document with id
|
||||||
|
* @param {number} id
|
||||||
|
* @returns {Document?}
|
||||||
|
*/
|
||||||
get(id) {
|
get(id) {
|
||||||
let tmp = this.realm.objects(this.schema).filtered('id = ' + id)[0];
|
/** @type {Realm.Results<Document>} */
|
||||||
return tmp;
|
const tmp = this.realm.objects(this.schema);
|
||||||
|
if (tmp.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return tmp.filtered('id = ' + id)[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Array<import("./Directory").Directory>} authorizedDirs
|
||||||
|
* @returns {import('realm').Results<Document>}
|
||||||
|
*/
|
||||||
getAll(authorizedDirs = false) {
|
getAll(authorizedDirs = false) {
|
||||||
|
/** @type {Realm.Results<Document>} */
|
||||||
let tmp = this.realm.objects(this.schema);
|
let tmp = this.realm.objects(this.schema);
|
||||||
if (authorizedDirs) {
|
if (authorizedDirs) {
|
||||||
authorizedDirs = authorizedDirs.map(item => item.id);
|
authorizedDirs = authorizedDirs.map(item => item.id);
|
||||||
|
|
@ -61,10 +98,20 @@ class DocumentModel {
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef { { uuid: typeof DocumentsSchema.properties.uuid, type: typeof DocumentsSchema.properties.type } } DocumentCleared
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Delete all
|
||||||
|
* @param {Array<Document>} docs
|
||||||
|
* @param {Array<DocumentCleared>} toDelete
|
||||||
|
* @returns {Array<DocumentCleared>}
|
||||||
|
*/
|
||||||
clear(docs, toDelete = []) {
|
clear(docs, toDelete = []) {
|
||||||
const localDocs = this.getAll();
|
const localDocs = this.getAll();
|
||||||
localDocs.forEach(doc => {
|
localDocs.forEach(doc => {
|
||||||
let tmp = docs.filter(item => item.uuid === doc.uuid);
|
const tmp = docs.filter(item => item.uuid === doc.uuid);
|
||||||
if (tmp.length === 0) {
|
if (tmp.length === 0) {
|
||||||
toDelete.push({ uuid: doc.uuid, type: doc.type });
|
toDelete.push({ uuid: doc.uuid, type: doc.type });
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
|
|
|
||||||
107
ComApp/src/App/Models/Form.js
Normal file
107
ComApp/src/App/Models/Form.js
Normal file
|
|
@ -0,0 +1,107 @@
|
||||||
|
import { UpdateMode } from 'realm';
|
||||||
|
|
||||||
|
export const FormData = {
|
||||||
|
/** @type {number} */
|
||||||
|
id: undefined,
|
||||||
|
/** @type {import('./../Enums/InputType').InputType} */
|
||||||
|
type: undefined,
|
||||||
|
/** @type {string} */
|
||||||
|
name: undefined,
|
||||||
|
/** @type {string} */
|
||||||
|
slug: undefined,
|
||||||
|
|
||||||
|
/** @type {import('realm').Dictionary<string>} list of translated placeholders Map<string,string> */
|
||||||
|
placeholder: {},
|
||||||
|
/** @type {import('realm').List<string>} list of json encoded translated details, list of Map<string,string> */
|
||||||
|
details: [],
|
||||||
|
/** @type {boolean} */
|
||||||
|
is_visible: false,
|
||||||
|
/** @type {boolean} */
|
||||||
|
required: false,
|
||||||
|
/** @type {import('./../Enums/InputStatus').InputStatus} */
|
||||||
|
status: 0,
|
||||||
|
/** @type {number} */
|
||||||
|
order: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
export const FormsSchema = {
|
||||||
|
name: 'Formularies',
|
||||||
|
primaryKey: 'id',
|
||||||
|
properties: {
|
||||||
|
id: 'int',
|
||||||
|
type: 'int',
|
||||||
|
name: 'string',
|
||||||
|
slug: 'string',
|
||||||
|
placeholder: { type: 'dictionary', objectType: 'string' },
|
||||||
|
details: { type: 'list', objectType: 'string' },
|
||||||
|
is_visible: 'bool',
|
||||||
|
required: 'bool',
|
||||||
|
status: 'int',
|
||||||
|
order: 'int',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Unmanaged<typeof FormData> & import('realm').Object} Form
|
||||||
|
*/
|
||||||
|
|
||||||
|
class FormModel {
|
||||||
|
/**
|
||||||
|
* DocumentModel
|
||||||
|
* @param {Realm} realm
|
||||||
|
*/
|
||||||
|
constructor(realm) {
|
||||||
|
/** @type string */
|
||||||
|
this.schema = 'Formularies';
|
||||||
|
/** @type {Realm} */
|
||||||
|
this.realm = realm;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Form} data
|
||||||
|
*/
|
||||||
|
add(data) {
|
||||||
|
this.realm.write(() => {
|
||||||
|
this.realm.create(this.schema, data, UpdateMode.Never);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get document with id
|
||||||
|
* @param {number} id
|
||||||
|
* @returns {Form?}
|
||||||
|
*/
|
||||||
|
get(id) {
|
||||||
|
/** @type {Realm.Results<Form>} */
|
||||||
|
const tmp = this.realm.objects(this.schema);
|
||||||
|
if (tmp.length === 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return tmp.filtered(`id = ${id}`)[0] ?? null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('./../Enums/InputStatus').InputStatus|null} status
|
||||||
|
* @returns {import('realm').Results<Form>}
|
||||||
|
*/
|
||||||
|
getAll(status = null) {
|
||||||
|
const objects = this.realm.objects(this.schema);
|
||||||
|
if (status !== null) {
|
||||||
|
return objects.filtered(`status = ${status}`);
|
||||||
|
}
|
||||||
|
return objects;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef { { uuid: typeof FormsSchema.properties.uuid, type: typeof FormsSchema.properties.type } } DocumentCleared
|
||||||
|
*/
|
||||||
|
|
||||||
|
/** Delete all */
|
||||||
|
clear() {
|
||||||
|
this.realm.write(() => {
|
||||||
|
this.realm.delete(this.getAll());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default FormModel;
|
||||||
|
|
@ -2,21 +2,36 @@ export const SendBrochuresSchema = {
|
||||||
name: 'SendBrochures',
|
name: 'SendBrochures',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
|
/** @type {number} */
|
||||||
id: 'int',
|
id: 'int',
|
||||||
email: 'string',
|
email: 'string',
|
||||||
subject: 'string',
|
subject: 'string',
|
||||||
message: 'string',
|
message: 'string',
|
||||||
documents: 'string',
|
documents: 'string',
|
||||||
user_id: 'int'
|
/** @type {number} */
|
||||||
|
app_user_id: 'int',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Unmanaged<typeof SendBrochuresSchema.properties> & import('realm').Object} SendBrochure
|
||||||
|
*/
|
||||||
|
|
||||||
class SendBrochureModel {
|
class SendBrochureModel {
|
||||||
|
/**
|
||||||
|
* SendBrochureModel
|
||||||
|
* @param {Realm} realm
|
||||||
|
*/
|
||||||
constructor(realm) {
|
constructor(realm) {
|
||||||
|
/** @type string */
|
||||||
this.schema = 'SendBrochures';
|
this.schema = 'SendBrochures';
|
||||||
|
/** @type {Realm} */
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {SendBrochure} data
|
||||||
|
*/
|
||||||
add(data) {
|
add(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
if (data.id === undefined) {
|
if (data.id === undefined) {
|
||||||
|
|
@ -26,14 +41,17 @@ class SendBrochureModel {
|
||||||
try {
|
try {
|
||||||
this.realm.create(this.schema, data, 'never');
|
this.realm.create(this.schema, data, 'never');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('db setting add', e);
|
console.error('db setting add', e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {SendBrochure} data
|
||||||
|
*/
|
||||||
upsert(data) {
|
upsert(data) {
|
||||||
let tmp = this.get(data.key);
|
const tmp = this.get(data.key);
|
||||||
if (tmp === false || tmp === undefined) {
|
if (tmp === null) {
|
||||||
this.add(data);
|
this.add(data);
|
||||||
} else {
|
} else {
|
||||||
if (data.id === undefined) {
|
if (data.id === undefined) {
|
||||||
|
|
@ -45,42 +63,55 @@ class SendBrochureModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {SendBrochure} data
|
||||||
|
*/
|
||||||
update(data) {
|
update(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.create(this.schema, data, 'modified');
|
this.realm.create(this.schema, data, 'modified');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get sendBrochure with id
|
||||||
|
* @param {number} id
|
||||||
|
* @returns {SendBrochure?}
|
||||||
|
*/
|
||||||
get(id) {
|
get(id) {
|
||||||
let tmp = this.realm.objects(this.schema);
|
/** @type {import('realm').Results<SendBrochure>} */
|
||||||
|
const tmp = this.realm.objects(this.schema);
|
||||||
if (tmp.length === 0) {
|
if (tmp.length === 0) {
|
||||||
return false;
|
return null;
|
||||||
} else {
|
|
||||||
tmp = tmp.filtered('id = ' + id)[0];
|
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp.filtered('id = ' + id)[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {import('realm').Results<SendBrochure>}
|
||||||
|
*/
|
||||||
getAll() {
|
getAll() {
|
||||||
let tmp = this.realm.objects(this.schema);
|
return this.realm.objects(this.schema);
|
||||||
return tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Delete all */
|
||||||
clear() {
|
clear() {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(this.getAll());
|
this.realm.delete(this.getAll());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(key) {
|
/**
|
||||||
const tmp = this.get(key);
|
* delete sendBrochure with id
|
||||||
|
* @param {number} id id
|
||||||
|
*/
|
||||||
|
delete(id) {
|
||||||
|
const tmp = this.get(id);
|
||||||
if (typeof tmp === 'object') {
|
if (typeof tmp === 'object') {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(tmp);
|
this.realm.delete(tmp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SendBrochureModel;
|
export default SendBrochureModel;
|
||||||
|
|
|
||||||
|
|
@ -2,35 +2,52 @@ export const SettingsSchema = {
|
||||||
name: 'Settings',
|
name: 'Settings',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
|
/** @type {number} */
|
||||||
id: 'int',
|
id: 'int',
|
||||||
key: 'string',
|
key: 'string',
|
||||||
value: 'string',
|
value: 'string',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Unmanaged<typeof SettingsSchema.properties> & import('realm').Object} Setting
|
||||||
|
*/
|
||||||
|
|
||||||
class SettingModel {
|
class SettingModel {
|
||||||
|
/**
|
||||||
|
* SettingModel
|
||||||
|
* @param {Realm} realm
|
||||||
|
*/
|
||||||
constructor(realm) {
|
constructor(realm) {
|
||||||
|
/** @type string */
|
||||||
this.schema = 'Settings';
|
this.schema = 'Settings';
|
||||||
|
/** @type {Realm} */
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Setting} data
|
||||||
|
*/
|
||||||
add(data) {
|
add(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
if (data.id === undefined) {
|
if (data.id === undefined) {
|
||||||
let id = this.realm.objects(this.schema).max('id');
|
const id = this.realm.objects(this.schema).max('id');
|
||||||
data.id = id === undefined ? 1 : id + 1;
|
data.id = id === undefined ? 1 : id + 1;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
this.realm.create(this.schema, data, 'never');
|
this.realm.create(this.schema, data, 'never');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('db setting add', e);
|
console.error('db setting add', e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Setting} data
|
||||||
|
*/
|
||||||
upsert(data) {
|
upsert(data) {
|
||||||
let tmp = this.get(data.key);
|
const tmp = this.get(data.key);
|
||||||
if (tmp === false || tmp === undefined) {
|
if (tmp === null) {
|
||||||
this.add(data);
|
this.add(data);
|
||||||
} else {
|
} else {
|
||||||
if (data.id === undefined) {
|
if (data.id === undefined) {
|
||||||
|
|
@ -42,31 +59,41 @@ class SettingModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {Setting} data
|
||||||
|
*/
|
||||||
update(data) {
|
update(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.create(this.schema, data, 'modified');
|
this.realm.create(this.schema, data, 'modified');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get setting with key
|
||||||
|
* @param {string} key
|
||||||
|
* @returns {Setting?}
|
||||||
|
*/
|
||||||
get(key) {
|
get(key) {
|
||||||
let tmp = this.realm.objects(this.schema);
|
/** @type {import('realm').Results<Setting>} */
|
||||||
|
const tmp = this.realm.objects(this.schema);
|
||||||
if (tmp.length === 0) {
|
if (tmp.length === 0) {
|
||||||
return false;
|
return null;
|
||||||
} else {
|
|
||||||
tmp = tmp.filtered('key = "' + key + '"')[0];
|
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp.filtered('key = "' + key + '"')[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
delete(key) {
|
/**
|
||||||
const tmp = this.get(key);
|
* delete setting with id
|
||||||
|
* @param {number} id id
|
||||||
|
*/
|
||||||
|
delete(id) {
|
||||||
|
const tmp = this.get(id);
|
||||||
if (typeof tmp === 'object') {
|
if (typeof tmp === 'object') {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(tmp);
|
this.realm.delete(tmp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SettingModel;
|
export default SettingModel;
|
||||||
|
|
@ -1,23 +1,55 @@
|
||||||
|
/**
|
||||||
|
* @typedef {typeof UserData} UserData
|
||||||
|
*/
|
||||||
|
export const UserData = {
|
||||||
|
/** @type {string|undefined} */
|
||||||
|
id: undefined,
|
||||||
|
/** @type {string} */
|
||||||
|
surname: undefined,
|
||||||
|
/** @type {string|null} */
|
||||||
|
lastname: null,
|
||||||
|
/** @type {string|null} */
|
||||||
|
firstname: null,
|
||||||
|
/** @type {string|null} */
|
||||||
|
role: null,
|
||||||
|
/** @type {string|null} */
|
||||||
|
authorizedFolders: null,
|
||||||
|
};
|
||||||
export const UsersSchema = {
|
export const UsersSchema = {
|
||||||
name: 'Users',
|
name: 'Users',
|
||||||
primaryKey: 'id',
|
primaryKey: 'id',
|
||||||
properties: {
|
properties: {
|
||||||
|
/** @type {number} */
|
||||||
id: 'int',
|
id: 'int',
|
||||||
email: 'string',
|
email: 'string',
|
||||||
surname: 'string',
|
surname: 'string',
|
||||||
firstname: 'string',
|
firstname: 'string',
|
||||||
password: 'string',
|
password: 'string',
|
||||||
role: 'string',
|
role: 'string',
|
||||||
|
/** Json encoded string of {import('./Models/Directory').Directory[]} */
|
||||||
authorizedFolders: 'string',
|
authorizedFolders: 'string',
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {Unmanaged<typeof UsersSchema.properties> & import('realm').Object} User
|
||||||
|
*/
|
||||||
|
|
||||||
class UserModel {
|
class UserModel {
|
||||||
|
/**
|
||||||
|
* UserModel
|
||||||
|
* @param {Realm} realm
|
||||||
|
*/
|
||||||
constructor(realm) {
|
constructor(realm) {
|
||||||
|
/** @type string */
|
||||||
this.schema = 'Users';
|
this.schema = 'Users';
|
||||||
|
/** @type {Realm} */
|
||||||
this.realm = realm;
|
this.realm = realm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {User} data
|
||||||
|
*/
|
||||||
add(data) {
|
add(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
if (data.id === undefined) {
|
if (data.id === undefined) {
|
||||||
|
|
@ -27,13 +59,16 @@ class UserModel {
|
||||||
try {
|
try {
|
||||||
this.realm.create(this.schema, data, 'never');
|
this.realm.create(this.schema, data, 'never');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log('db setting add', e);
|
console.error('db setting add', e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {User} data
|
||||||
|
*/
|
||||||
upsert(data) {
|
upsert(data) {
|
||||||
let tmp = this.get(data.key);
|
const tmp = this.get(data.key);
|
||||||
if (tmp === false || tmp === undefined) {
|
if (tmp === false || tmp === undefined) {
|
||||||
this.add(data);
|
this.add(data);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -46,33 +81,42 @@ class UserModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {User} data
|
||||||
|
*/
|
||||||
update(data) {
|
update(data) {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.create(this.schema, data, 'modified');
|
this.realm.create(this.schema, data, 'modified');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get user with id
|
||||||
|
* @param {number} id
|
||||||
|
* @returns {User?}
|
||||||
|
*/
|
||||||
get(id) {
|
get(id) {
|
||||||
let tmp = this.realm.objects(this.schema);
|
/** @type {import('realm').Results<User>} */
|
||||||
|
const tmp = this.realm.objects(this.schema);
|
||||||
if (tmp.length === 0) {
|
if (tmp.length === 0) {
|
||||||
return false;
|
return null;
|
||||||
} else {
|
|
||||||
tmp = tmp.filtered('id = ' + id)[0];
|
|
||||||
}
|
}
|
||||||
return tmp;
|
return tmp.filtered('key = "' + id + '"')[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns {import('realm').Results<User>}
|
||||||
|
*/
|
||||||
getAll() {
|
getAll() {
|
||||||
let tmp = this.realm.objects(this.schema);
|
return this.realm.objects(this.schema);
|
||||||
return tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Delete all */
|
||||||
clear() {
|
clear() {
|
||||||
this.realm.write(() => {
|
this.realm.write(() => {
|
||||||
this.realm.delete(this.getAll());
|
this.realm.delete(this.getAll());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default UserModel;
|
export default UserModel;
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
// Locale
|
// Locale
|
||||||
export const INIT_LOCALE = "INIT_LOCALE";
|
export const INIT_LOCALE = 'INIT_LOCALE';
|
||||||
export const EDIT_LOCALE = "EDIT_LOCALE";
|
export const EDIT_LOCALE = 'EDIT_LOCALE';
|
||||||
// Users
|
// Users
|
||||||
export const INIT_USERS = "INIT_USERS";
|
export const INIT_USERS = 'INIT_USERS';
|
||||||
// Contacts
|
// Contacts
|
||||||
export const INIT_CONTACT = "INIT_CONTACT";
|
export const INIT_CONTACT = 'INIT_CONTACT';
|
||||||
export const ADD_CONTACT = "ADD_CONTACT";
|
export const SET_CONTACT = 'ADD_CONTACT';
|
||||||
export const EDIT_CONTACT = "EDIT_CONTACT";
|
export const DELETE_CONTACT = 'DELETE_CONTACT';
|
||||||
export const DELETE_CONTACT = "DELETE_CONTACT";
|
|
||||||
// Directories
|
// Directories
|
||||||
export const INIT_DIRECTORIES = "INIT_DIRECTORIES";
|
export const INIT_DIRECTORIES = 'INIT_DIRECTORIES';
|
||||||
// Documents
|
// Documents
|
||||||
export const INIT_DOCUMENTS = "INIT_DOCUMENTS";
|
export const INIT_DOCUMENTS = 'INIT_DOCUMENTS';
|
||||||
|
// Formularies
|
||||||
|
export const INIT_FORMS = 'INIT_FORMS';
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,13 @@
|
||||||
import { INIT_CONTACT, ADD_CONTACT, EDIT_CONTACT, DELETE_CONTACT } from "./actionType";
|
import { DELETE_CONTACT, INIT_CONTACT, SET_CONTACT } from './actionType';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef { {currentUser: import('../../Models/User').User, data: import('../../Models/Contact').Contact} } InitContactAction
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init contact
|
* Init contact
|
||||||
* @param {object} currentUser The currentUser
|
* @param {import('../../Models/User').User} currentUser The currentUser
|
||||||
* @param {object} data The contact data
|
* @param {import('../../Models/Contact').Contact} data The contact data
|
||||||
*/
|
*/
|
||||||
export const initContact = (currentUser, data) => {
|
export const initContact = (currentUser, data) => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -14,40 +18,35 @@ export const initContact = (currentUser, data) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add contact
|
* @typedef { {currentUser: import('../../Models/User').User, data: import('../../Models/Contact').Contact} } SetContactAction
|
||||||
* @param {object} currentUser The currentUser
|
|
||||||
* @param {object} data The contact data
|
|
||||||
*/
|
*/
|
||||||
export const addContact = (currentUser, data) => {
|
|
||||||
|
/**
|
||||||
|
* Add contact
|
||||||
|
* @param {import('../../Models/User').User} currentUser The currentUser
|
||||||
|
* @param {import('../../Models/Contact').Contact} data The contact data
|
||||||
|
*/
|
||||||
|
export const setContact = (currentUser, data) => {
|
||||||
return {
|
return {
|
||||||
type: ADD_CONTACT,
|
type: SET_CONTACT,
|
||||||
currentUser,
|
currentUser,
|
||||||
data,
|
data,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit contact
|
* @typedef { {currentUser: import('../../Models/User').User, uuid: string} } DeleteContactAction
|
||||||
* @param {object} currentUser The currentUser
|
|
||||||
* @param {object} data The contact data
|
|
||||||
*/
|
*/
|
||||||
export const editContact = (currentUser, data) => {
|
|
||||||
return {
|
|
||||||
type: EDIT_CONTACT,
|
|
||||||
currentUser,
|
|
||||||
data,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete contact
|
* Delete contact
|
||||||
* @param {object} currentUser The currentUser
|
* @param {import('../../Models/User').User} currentUser The currentUser
|
||||||
* @param {string} id The contact id
|
* @param {string} uuid The contact uuid
|
||||||
*/
|
*/
|
||||||
export const deleteContact = (currentUser, id) => {
|
export const deleteContact = (currentUser, uuid) => {
|
||||||
return {
|
return {
|
||||||
type: DELETE_CONTACT,
|
type: DELETE_CONTACT,
|
||||||
currentUser,
|
currentUser,
|
||||||
id,
|
uuid: uuid,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -1,10 +1,15 @@
|
||||||
import { INIT_DIRECTORIES } from "./actionType";
|
import { INIT_DIRECTORIES } from './actionType';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef { {type: typeof INIT_DIRECTORIES, lang: string, user: import('../../Models/User').User, data: import('../../Models/Directory').Directory} } InitDirectoryAction
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init
|
* Init
|
||||||
* @param {string} lang The lang
|
* @param {string} lang The lang
|
||||||
* @param {object} user User
|
* @param {import('../../Models/User').User} user
|
||||||
* @param {object} data The document data
|
* @param {import('../../Models/Directory').Directory} data The document data
|
||||||
|
* @returns {InitDirectoryAction}
|
||||||
*/
|
*/
|
||||||
export const initDirectories = (lang, user, data) => {
|
export const initDirectories = (lang, user, data) => {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
import { INIT_DOCUMENTS } from "./actionType";
|
import { INIT_DOCUMENTS } from './actionType';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef { {type: typeof INIT_DOCUMENTS, lang: string, directories: import('realm').Results<import('../../Models/Directory').Directory>, data: import('../../Models/Document').Document } } InitDocumentsAction
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init contact
|
* Init contact
|
||||||
* @param {string} lang The lang
|
* @param {string} lang The lang
|
||||||
* @param {object} directories Directories
|
* @param {Realm.Results<import('../../Models/Directory').Directory>} directories Directories
|
||||||
* @param {object} data The document data
|
* @param {import('../../Models/Document').Document} data The document data
|
||||||
*/
|
*/
|
||||||
export const initDocuments = (lang, directories, data) => {
|
export const initDocuments = (lang, directories, data) => {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
16
ComApp/src/App/Store/Actions/formularies.js
Normal file
16
ComApp/src/App/Store/Actions/formularies.js
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { INIT_FORMS } from './actionType';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef { {type: typeof INIT_FORMS, data: import('../../Models/Form').Form } } InitFormAction
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Init forms
|
||||||
|
* @param {import('../../Models/Form').Form} data The forms data
|
||||||
|
*/
|
||||||
|
export const initFormularies = data => {
|
||||||
|
return {
|
||||||
|
type: INIT_FORMS,
|
||||||
|
data,
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
import { INIT_LOCALE, EDIT_LOCALE } from "./actionType";
|
import { EDIT_LOCALE, INIT_LOCALE } from './actionType';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef { {type: typeof INIT_LOCALE, data: string } } InitLocaleAction
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init locale
|
* Init locale
|
||||||
* @param {object} data The locale data
|
* @param {string} data The locale data
|
||||||
*/
|
*/
|
||||||
export const initLocale = data => {
|
export const initLocale = data => {
|
||||||
return {
|
return {
|
||||||
|
|
@ -11,9 +15,13 @@ export const initLocale = data => {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef { {type: typeof EDIT_LOCALE, data: string } } EditLocaleAction
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit locale
|
* Edit locale
|
||||||
* @param {object} data The locale data
|
* @param {string} data The locale data
|
||||||
*/
|
*/
|
||||||
export const editLocale = data => {
|
export const editLocale = data => {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,12 @@
|
||||||
import { INIT_USERS } from "./actionType";
|
import { INIT_USERS } from './actionType';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef { {type: typeof INIT_USERS, data: import('../../Models/User').User } } InitUserAction
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Init users
|
* Init users
|
||||||
* @param {object} data The users data
|
* @param {import('../../Models/User').User} data The users data
|
||||||
*/
|
*/
|
||||||
export const initUsers = data => {
|
export const initUsers = data => {
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,12 @@
|
||||||
import { createStore, combineReducers } from "redux";
|
import { combineReducers, createStore } from 'redux';
|
||||||
|
|
||||||
import appReducer from "./Reducers/AppReducer";
|
import appReducer from './Reducers/AppReducer';
|
||||||
import contactsReducer from "./Reducers/contacts";
|
import contactsReducer from './Reducers/contacts';
|
||||||
import documentsReducer from "./Reducers/documents";
|
import directoriesReducer from './Reducers/directories';
|
||||||
import directoriesReducer from "./Reducers/directories";
|
import documentsReducer from './Reducers/documents';
|
||||||
import localesReducer from "./Reducers/locales";
|
import formulariesReducer from './Reducers/formularies';
|
||||||
import usersReducer from "./Reducers/users";
|
import localesReducer from './Reducers/locales';
|
||||||
|
import usersReducer from './Reducers/users';
|
||||||
|
|
||||||
const rootReducer = combineReducers({
|
const rootReducer = combineReducers({
|
||||||
app: appReducer,
|
app: appReducer,
|
||||||
|
|
@ -13,7 +14,8 @@ const rootReducer = combineReducers({
|
||||||
documents: documentsReducer,
|
documents: documentsReducer,
|
||||||
directories: directoriesReducer,
|
directories: directoriesReducer,
|
||||||
locale: localesReducer,
|
locale: localesReducer,
|
||||||
users: usersReducer
|
users: usersReducer,
|
||||||
|
formularies: formulariesReducer,
|
||||||
});
|
});
|
||||||
|
|
||||||
export const store = createStore(rootReducer);
|
export const store = createStore(rootReducer);
|
||||||
|
|
@ -1,56 +1,50 @@
|
||||||
import SyncController from "../../Controllers/SyncController";
|
import SyncController from '../../Controllers/SyncController';
|
||||||
// Database
|
// Database
|
||||||
import { Setting, SendBrochure } from '../../../Database';
|
import { SendBrochure, Setting } from '../../../Database';
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
isSetup: false,
|
isSetup: false,
|
||||||
locale: 'fr',
|
locale: 'fr',
|
||||||
currentUser: {},
|
currentUser: {},
|
||||||
logged: false,
|
logged: false,
|
||||||
syncVersion: 0,
|
|
||||||
forceSync: false,
|
forceSync: false,
|
||||||
currentOpenedDoc: {},
|
currentOpenedDoc: {},
|
||||||
ShowIsActive: 0,
|
|
||||||
HomeBtns: {},
|
HomeBtns: {},
|
||||||
mainColor: '#D4021D',
|
mainColor: '#D4021D',
|
||||||
FormSelect1: {},
|
|
||||||
FormSelect2: {},
|
|
||||||
FormCheck: [],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
let saved;
|
let saved;
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'INIT':
|
case 'INIT':
|
||||||
let ShowIsActive = Setting.get('ShowIsActive');
|
|
||||||
let MainColor = Setting.get('MainColor');
|
let MainColor = Setting.get('MainColor');
|
||||||
let FormSelect1 = Setting.get('FormSelect1');
|
|
||||||
let FormSelect2 = Setting.get('FormSelect2');
|
|
||||||
let FormCheck = Setting.get('FormCheck');
|
|
||||||
saved = Setting.get('isSetup');
|
saved = Setting.get('isSetup');
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
isSetup: saved === undefined ? false : saved.value === "true" ? true : false,
|
isSetup:
|
||||||
ShowIsActive: ShowIsActive === undefined ? false : ShowIsActive.value,
|
saved === undefined ? false : saved?.value === 'true' ? true : false,
|
||||||
mainColor: MainColor === undefined ? initialState.mainColor : MainColor === false ? initialState.mainColor : MainColor.value,
|
mainColor:
|
||||||
FormSelect1: FormSelect1 === undefined ? initialState.FormSelect1 : FormSelect1 === false ? initialState.FormSelect1 : JSON.parse(FormSelect1.value),
|
MainColor === undefined
|
||||||
FormSelect2: FormSelect2 === undefined ? initialState.FormSelect2 : FormSelect2 === false ? initialState.FormSelect2 : JSON.parse(FormSelect2.value),
|
? initialState.mainColor
|
||||||
FormCheck: FormCheck === undefined ? initialState.FormCheck : FormCheck === false ? initialState.FormCheck : JSON.parse(FormCheck.value),
|
: MainColor === null
|
||||||
|
? initialState.mainColor
|
||||||
|
: MainColor?.value,
|
||||||
};
|
};
|
||||||
case 'INIT_HOME_BTNS': {
|
case 'INIT_HOME_BTNS': {
|
||||||
let HomeFolders = Setting.get('HomeFolders');
|
let HomeFolders = Setting.get('HomeFolders');
|
||||||
let Btns = JSON.parse(HomeFolders.value);
|
let Btns = HomeFolders ? JSON.parse(HomeFolders?.value) : [];
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
HomeBtns: Btns
|
HomeBtns: Btns,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
case 'SET_ISSETUP':
|
case 'SET_ISSETUP':
|
||||||
Setting.upsert({ key: 'isSetup', value: "true" });
|
Setting.upsert({ key: 'isSetup', value: 'true' });
|
||||||
saved = Setting.get('isSetup');
|
saved = Setting.get('isSetup');
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
isSetup: saved === undefined ? false : saved.value === "true" ? true : false
|
isSetup:
|
||||||
|
saved === undefined ? false : saved?.value === 'true' ? true : false,
|
||||||
};
|
};
|
||||||
case 'SET_CURRENT_USER':
|
case 'SET_CURRENT_USER':
|
||||||
let user = false;
|
let user = false;
|
||||||
|
|
@ -58,14 +52,14 @@ const reducer = (state = initialState, action) => {
|
||||||
if (action.data === false) {
|
if (action.data === false) {
|
||||||
Setting.delete('isLogged');
|
Setting.delete('isLogged');
|
||||||
} else {
|
} else {
|
||||||
userObj = Setting.get('isLogged').value
|
let userObj = Setting.get('isLogged');
|
||||||
user = JSON.parse(userObj)
|
user = userObj ? JSON.parse(userObj?.value) : false;
|
||||||
isLogged = true
|
isLogged = true;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
currentUser: user !== false ? user : initialState.currentUser,
|
currentUser: user !== false ? user : initialState.currentUser,
|
||||||
logged: isLogged
|
logged: isLogged,
|
||||||
};
|
};
|
||||||
// case 'UPDATE_LOCALE':
|
// case 'UPDATE_LOCALE':
|
||||||
// let nxt;
|
// let nxt;
|
||||||
|
|
@ -101,18 +95,7 @@ const reducer = (state = initialState, action) => {
|
||||||
case 'SET_CURRENT_OPENED_DOC':
|
case 'SET_CURRENT_OPENED_DOC':
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
currentOpenedDoc: action.data
|
currentOpenedDoc: action.data,
|
||||||
};
|
|
||||||
case 'UPDATE_VERSION':
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
syncVersion: action.data,
|
|
||||||
};
|
|
||||||
case 'UPDATE_SHOW_IS_ACTIVE':
|
|
||||||
SyncController.updateShowIsActive(action.data);
|
|
||||||
return {
|
|
||||||
...state,
|
|
||||||
ShowIsActive: action.data,
|
|
||||||
};
|
};
|
||||||
case 'SEND_BROCHURE':
|
case 'SEND_BROCHURE':
|
||||||
SendBrochure.add(action.data);
|
SendBrochure.add(action.data);
|
||||||
|
|
@ -120,6 +103,6 @@ const reducer = (state = initialState, action) => {
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
export default reducer;
|
export default reducer;
|
||||||
|
|
@ -1,26 +1,32 @@
|
||||||
import { INIT_CONTACT, ADD_CONTACT, EDIT_CONTACT, DELETE_CONTACT } from "../Actions/actionType";
|
import {
|
||||||
|
DELETE_CONTACT,
|
||||||
|
INIT_CONTACT,
|
||||||
|
SET_CONTACT,
|
||||||
|
} from '../Actions/actionType';
|
||||||
// Models
|
// Models
|
||||||
import { Contact } from "../../../Database";
|
import { Contact } from '../../../Database';
|
||||||
|
|
||||||
|
/** @type {import('../../Models/Contact').Contact[]} */
|
||||||
const initialState = [];
|
const initialState = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {typeof initialState} state
|
||||||
|
* @param {import('../Actions/contacts').InitContactAction|import('../Actions/contacts').SetContactAction|import('../Actions/contacts').DeleteContactAction} action
|
||||||
|
* @returns {import('realm').Results<import('../../Models/Contact').Contact>}
|
||||||
|
*/
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INIT_CONTACT: {
|
case INIT_CONTACT: {
|
||||||
return Contact.getByUser(action.currentUser.id);
|
return Contact.getAllEditable(action.currentUser.id);
|
||||||
}
|
}
|
||||||
case ADD_CONTACT: {
|
case SET_CONTACT: {
|
||||||
action.data.user_id = action.currentUser.id;
|
action.data.app_user_id = action.currentUser.id;
|
||||||
Contact.add(action.data);
|
Contact.set(action.data);
|
||||||
return Contact.getByUser(action.currentUser.id);
|
return Contact.getAllEditable(action.currentUser.id);
|
||||||
}
|
|
||||||
case EDIT_CONTACT: {
|
|
||||||
Contact.update(action.data);
|
|
||||||
return Contact.getByUser(action.currentUser.id);
|
|
||||||
}
|
}
|
||||||
case DELETE_CONTACT: {
|
case DELETE_CONTACT: {
|
||||||
Contact.delete(action.id);
|
Contact.delete(action.currentUser.id, action.uuid);
|
||||||
return Contact.getByUser(action.currentUser.id);
|
return Contact.getAllEditable(action.currentUser.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,19 @@
|
||||||
import { INIT_DIRECTORIES } from "../Actions/actionType";
|
import { Directory } from '../../../Database';
|
||||||
|
import { INIT_DIRECTORIES } from '../Actions/actionType';
|
||||||
// Models
|
// Models
|
||||||
import { Directory } from "../../../Database";
|
|
||||||
|
|
||||||
const initialState = [];
|
const initialState = {
|
||||||
|
/** @type {Realm.Results<import('../../Models/Directory').Directory>} */
|
||||||
|
global: [],
|
||||||
|
/** @type {Realm.Results<import('../../Models/Directory').Directory>} */
|
||||||
|
treeview: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {typeof initialState} state
|
||||||
|
* @param {import('../Actions/directories').InitDirectoryAction} action
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INIT_DIRECTORIES: {
|
case INIT_DIRECTORIES: {
|
||||||
|
|
@ -12,15 +22,15 @@ const reducer = (state = initialState, action) => {
|
||||||
action.user.role,
|
action.user.role,
|
||||||
action.user.authorizedFolders,
|
action.user.authorizedFolders,
|
||||||
false,
|
false,
|
||||||
action.lang
|
action.lang,
|
||||||
),
|
),
|
||||||
treeview: Directory.getAll(
|
treeview: Directory.getAll(
|
||||||
action.user.role,
|
action.user.role,
|
||||||
action.user.authorizedFolders,
|
action.user.authorizedFolders,
|
||||||
true,
|
true,
|
||||||
action.lang
|
action.lang,
|
||||||
)
|
),
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,21 @@
|
||||||
import { INIT_DOCUMENTS } from "../Actions/actionType";
|
import { INIT_DOCUMENTS } from '../Actions/actionType';
|
||||||
// Models
|
// Models
|
||||||
import { Document } from "../../../Database";
|
import { Document } from '../../../Database';
|
||||||
|
|
||||||
|
/** @type {import('../../Models/Document').Document[]} */
|
||||||
const initialState = [];
|
const initialState = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {typeof initialState} state
|
||||||
|
* @param {import('../Actions/documents').InitDocumentsAction} action
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INIT_DOCUMENTS: {
|
case INIT_DOCUMENTS: {
|
||||||
let docs = Document.getAll(action.directories);
|
const docs = Document.getAll(action.directories);
|
||||||
if (docs.length === 0) {
|
if (docs.length === 0) {
|
||||||
return state
|
return state;
|
||||||
}
|
}
|
||||||
return docs.filter(item => item.lang === action.lang);
|
return docs.filter(item => item.lang === action.lang);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
30
ComApp/src/App/Store/Reducers/formularies.js
Normal file
30
ComApp/src/App/Store/Reducers/formularies.js
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { INIT_FORMS } from '../Actions/actionType';
|
||||||
|
// Models
|
||||||
|
import { Form } from '../../../Database';
|
||||||
|
|
||||||
|
const initialState = {
|
||||||
|
/** @type {Realm.Results<import('../../Models/Form').Form>} */
|
||||||
|
users: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {typeof initialState} state
|
||||||
|
* @param {import('../Actions/formularies').InitFormAction} action
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
const reducer = (state = initialState, action) => {
|
||||||
|
switch (action.type) {
|
||||||
|
case INIT_FORMS: {
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
forms: Form.getAll(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default reducer;
|
||||||
|
|
@ -1,26 +1,36 @@
|
||||||
import { INIT_LOCALE, EDIT_LOCALE } from "../Actions/actionType";
|
import { EDIT_LOCALE, INIT_LOCALE } from '../Actions/actionType';
|
||||||
// Models
|
// Models
|
||||||
import { Setting } from "../../../Database";
|
import { Setting } from '../../../Database';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from "../../../I18n";
|
import i18n from '../../../I18n';
|
||||||
|
|
||||||
const initialState = [];
|
const initialState = {
|
||||||
|
locale: 'fr',
|
||||||
|
};
|
||||||
|
const availableLocales = ['fr', 'en', 'de'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {typeof initialState} state
|
||||||
|
* @param {import('../Actions/locales').InitLocaleAction|import('../Actions/locales').EditLocaleAction} action
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INIT_LOCALE: {
|
case INIT_LOCALE: {
|
||||||
const savedLocale = Setting.get('locale');
|
const savedLocale = Setting.get('locale');
|
||||||
return {
|
return {
|
||||||
...state,
|
...state,
|
||||||
locale: savedLocale === undefined ? 'fr' : savedLocale === false ? 'fr' : savedLocale.value
|
locale: savedLocale === null ? initialState.locale : savedLocale.value,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
case EDIT_LOCALE: {
|
case EDIT_LOCALE: {
|
||||||
let nxt;
|
let nxt;
|
||||||
if (action.data === undefined) {
|
if (action.data === undefined) {
|
||||||
const availableLocales = ['fr', 'en', 'de'];
|
if (
|
||||||
if (availableLocales.indexOf(i18n.locale) === availableLocales.length - 1) {
|
availableLocales.indexOf(i18n.locale) ===
|
||||||
|
availableLocales.length - 1
|
||||||
|
) {
|
||||||
nxt = availableLocales[0];
|
nxt = availableLocales[0];
|
||||||
} else {
|
} else {
|
||||||
nxt = availableLocales[availableLocales.indexOf(i18n.locale) + 1];
|
nxt = availableLocales[availableLocales.indexOf(i18n.locale) + 1];
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,17 @@
|
||||||
import { INIT_USERS } from "../Actions/actionType";
|
import { INIT_USERS } from '../Actions/actionType';
|
||||||
// Models
|
// Models
|
||||||
import { User } from "../../../Database";
|
import { User } from '../../../Database';
|
||||||
|
|
||||||
const initialState = [];
|
const initialState = {
|
||||||
|
/** @type {Realm.Results<import('../../Models/User').User>} */
|
||||||
|
users: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {typeof initialState} state
|
||||||
|
* @param {import('../Actions/users').InitUserAction} action
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
const reducer = (state = initialState, action) => {
|
const reducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case INIT_USERS: {
|
case INIT_USERS: {
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,21 +1,24 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import {
|
||||||
View,
|
Alert,
|
||||||
Button,
|
Button,
|
||||||
FlatList,
|
FlatList,
|
||||||
|
Linking,
|
||||||
|
Platform,
|
||||||
Text,
|
Text,
|
||||||
TouchableOpacity,
|
|
||||||
Alert,
|
|
||||||
TextInput,
|
TextInput,
|
||||||
|
TouchableOpacity,
|
||||||
|
View,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
|
import { openComposer } from 'react-native-email-link';
|
||||||
|
|
||||||
// Reduxs
|
// Reduxs
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { editContact } from '../Store/Actions/contacts';
|
import { deleteContact, setContact } from '../Store/Actions/contacts';
|
||||||
import { deleteContact } from '../Store/Actions/contacts';
|
|
||||||
// Helpers
|
// Helpers
|
||||||
import Helpers from "../Lib/Helpers";
|
import Helpers from '../Lib/Helpers';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from "../../I18n";
|
import i18n from '../../I18n';
|
||||||
// Icons
|
// Icons
|
||||||
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
||||||
// Flash Messages
|
// Flash Messages
|
||||||
|
|
@ -33,15 +36,21 @@ function mapStateToProps(state) {
|
||||||
contacts: state.contacts,
|
contacts: state.contacts,
|
||||||
documents: state.documents,
|
documents: state.documents,
|
||||||
currentUser: state.app.currentUser,
|
currentUser: state.app.currentUser,
|
||||||
mainColor: state.app.mainColor
|
mainColor: state.app.mainColor,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @typedef {(user: import('./../Models/User').User, data: import('./../Models/Contact').Contact) => void} setContact
|
||||||
|
* @typedef {(user: import('./../Models/User').User, uuid: string ) => void} deleteContact
|
||||||
|
* @typedef {(email: string ) => void} sendBrochure
|
||||||
|
*/
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
editContact: (user, data) => dispatch(editContact(user, data)),
|
setContact: (user, data) => dispatch(setContact(user, data)),
|
||||||
deleteContact: (user, id) => dispatch(deleteContact(user, id)),
|
deleteContact: (user, id) => dispatch(deleteContact(user, id)),
|
||||||
sendBrochure: (email) => dispatch({ type: 'SEND_BROCHURE', data: email })
|
sendBrochure: email => dispatch({ type: 'SEND_BROCHURE', data: email }),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -51,9 +60,6 @@ class ContactScreen extends React.Component {
|
||||||
sortType: 'asc',
|
sortType: 'asc',
|
||||||
sortField: 'name',
|
sortField: 'name',
|
||||||
searchTxt: '',
|
searchTxt: '',
|
||||||
showTransferContact: false,
|
|
||||||
selectedTransferUser: 0,
|
|
||||||
contactToTransfer: {},
|
|
||||||
showSendBrochure: false,
|
showSendBrochure: false,
|
||||||
selectedDocument: -1,
|
selectedDocument: -1,
|
||||||
sendDocumentList: [],
|
sendDocumentList: [],
|
||||||
|
|
@ -63,9 +69,21 @@ class ContactScreen extends React.Component {
|
||||||
tmpSendBrochureMessage: '',
|
tmpSendBrochureMessage: '',
|
||||||
sortedDocuments: [],
|
sortedDocuments: [],
|
||||||
sortedEmails: [],
|
sortedEmails: [],
|
||||||
|
|
||||||
|
/** @type {number} The user index selected for transfert */
|
||||||
|
selectedTransferUserIndex: 0,
|
||||||
|
|
||||||
|
/** @type {import('./../Models/Contact').Contact|null} The contact to transfert */
|
||||||
|
contactToTransfer: null,
|
||||||
|
|
||||||
|
/** @type {boolean} Is tranfert contact model display ? */
|
||||||
|
showTransferContact: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// * --- ACTIONS
|
||||||
|
|
||||||
sendBrochure() {
|
sendBrochure() {
|
||||||
|
// FIXME: Si on n'a pas consulté les documents la liste des documents est vide apres initialisation
|
||||||
if (
|
if (
|
||||||
this.state.tmpSendBrochureEmail !== '' &&
|
this.state.tmpSendBrochureEmail !== '' &&
|
||||||
this.state.tmpSendBrochureSubject !== '' &&
|
this.state.tmpSendBrochureSubject !== '' &&
|
||||||
|
|
@ -73,14 +91,16 @@ class ContactScreen extends React.Component {
|
||||||
this.state.sendDocumentList.length > 0 &&
|
this.state.sendDocumentList.length > 0 &&
|
||||||
Helpers.isEmailValid(this.state.tmpSendBrochureEmail)
|
Helpers.isEmailValid(this.state.tmpSendBrochureEmail)
|
||||||
) {
|
) {
|
||||||
|
/** @type {sendBrochure} */
|
||||||
|
const sendBrochure = this.props.sendBrochure;
|
||||||
const email = {
|
const email = {
|
||||||
email: this.state.tmpSendBrochureEmail,
|
email: this.state.tmpSendBrochureEmail,
|
||||||
subject: this.state.tmpSendBrochureSubject,
|
subject: this.state.tmpSendBrochureSubject,
|
||||||
message: this.state.tmpSendBrochureMessage,
|
message: this.state.tmpSendBrochureMessage,
|
||||||
documents: JSON.stringify(this.state.sendDocumentList),
|
documents: JSON.stringify(this.state.sendDocumentList),
|
||||||
user_id: this.props.currentUser.id
|
app_user_id: this.props.currentUser.id,
|
||||||
};
|
};
|
||||||
this.props.sendBrochure(email);
|
sendBrochure(email);
|
||||||
this.setState({
|
this.setState({
|
||||||
showSendBrochure: false,
|
showSendBrochure: false,
|
||||||
tmpSendBrochureEmail: '',
|
tmpSendBrochureEmail: '',
|
||||||
|
|
@ -105,29 +125,27 @@ class ContactScreen extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
transferContact() {
|
transferContact() {
|
||||||
const nextUser = this.props.users.filter(user => user.id !== this.props.currentUser.id)[this.state.selectedTransferUser];
|
/** @type {import('./../Models/User').User} */
|
||||||
const transferContact = this.state.contactToTransfer;
|
const nextUser = this.props.users
|
||||||
const contact = {
|
.filter(user => user.id !== this.props.currentUser.id)
|
||||||
id: transferContact.id,
|
.sort(Helpers.compareValues('email', 'asc'))[
|
||||||
email: transferContact.email,
|
this.state.selectedTransferUserIndex
|
||||||
type: transferContact.type,
|
];
|
||||||
other: transferContact.other,
|
/** @type {import('./../Models/Contact').ContactData} cloned contact */
|
||||||
network: transferContact.network,
|
const transferContact = this.state.contactToTransfer.toJSON();
|
||||||
name: transferContact.name,
|
if (transferContact === null) {
|
||||||
firstname: transferContact.firstname,
|
throw new Error('No selected contact to transfert');
|
||||||
office: transferContact.office,
|
}
|
||||||
company: transferContact.company,
|
|
||||||
address: transferContact.address,
|
// * Assign cloned contact to another user
|
||||||
phone: transferContact.phone,
|
transferContact.send_to_app_user_id = nextUser.id;
|
||||||
products: transferContact.products,
|
transferContact.timestamp = new Date();
|
||||||
notes: transferContact.note,
|
transferContact.synced = false;
|
||||||
visits: transferContact.visits,
|
|
||||||
to_delete: false,
|
/** @type {setContact} */
|
||||||
synced: false,
|
const setContactHook = this.props.setContact;
|
||||||
user_id: nextUser.id,
|
setContactHook(this.props.currentUser, transferContact);
|
||||||
};
|
this.setState({ showTransferContact: false, contactToTransfer: null });
|
||||||
this.props.editContact(this.props.currentUser, contact);
|
|
||||||
this.setState({ showTransferContact: false });
|
|
||||||
showMessage({
|
showMessage({
|
||||||
message: i18n.t('contact_s.contact_transferred') + '.',
|
message: i18n.t('contact_s.contact_transferred') + '.',
|
||||||
description: i18n.t('contact_s.contact_will_be_sent_after_sync') + '.',
|
description: i18n.t('contact_s.contact_will_be_sent_after_sync') + '.',
|
||||||
|
|
@ -136,21 +154,30 @@ class ContactScreen extends React.Component {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteContactAction(id) {
|
/**
|
||||||
|
* Delete contact
|
||||||
|
* @param {import('../Models/Contact').Contact} contact
|
||||||
|
*/
|
||||||
|
deleteContactAction(contact) {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
i18n.t('global.confirmation'),
|
i18n.t('global.confirmation'),
|
||||||
i18n.t('contact_s.confirm_contact_delete'),
|
i18n.t('contact_s.confirm_contact_delete'),
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
text: i18n.t('global.no'),
|
text: i18n.t('global.no'),
|
||||||
onPress: () => console.log('Cancel Pressed'),
|
onPress: () => console.debug('Cancel Pressed'),
|
||||||
style: 'cancel',
|
style: 'cancel',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: i18n.t('global.yes'),
|
text: i18n.t('global.yes'),
|
||||||
onPress: () => {
|
onPress: () => {
|
||||||
this.setState({ contacts: [], sortedEmails: [] });
|
this.setState({ contacts: [], sortedEmails: [] });
|
||||||
this.props.deleteContact(this.props.currentUser, id);
|
/** @type {setContact} */
|
||||||
|
const setContactHook = this.props.setContact;
|
||||||
|
/** @type {import('./../Models/Contact').ContactData} */
|
||||||
|
const contactToDelete = contact.toJSON();
|
||||||
|
contactToDelete.to_delete = true;
|
||||||
|
setContactHook(this.props.currentUser, contactToDelete);
|
||||||
showMessage({
|
showMessage({
|
||||||
message: i18n.t('contact_s.contact_deleted') + '.',
|
message: i18n.t('contact_s.contact_deleted') + '.',
|
||||||
type: 'success',
|
type: 'success',
|
||||||
|
|
@ -163,27 +190,114 @@ class ContactScreen extends React.Component {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Item(item) {
|
/**
|
||||||
|
* Try to call the number
|
||||||
|
*
|
||||||
|
* @param {string} phone
|
||||||
|
*/
|
||||||
|
callNumberIfSupported(phone) {
|
||||||
|
let phoneNumber = phone;
|
||||||
|
if (Platform.OS !== 'android') {
|
||||||
|
phoneNumber = `telprompt:${phone}`;
|
||||||
|
} else {
|
||||||
|
phoneNumber = `tel:${phone}`;
|
||||||
|
}
|
||||||
|
Linking.canOpenURL(phoneNumber)
|
||||||
|
.then(supported => {
|
||||||
|
if (supported) {
|
||||||
|
return Linking.openURL(phoneNumber);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(err => console.error(err));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Write a new email to
|
||||||
|
*
|
||||||
|
* @param {string} email
|
||||||
|
*/
|
||||||
|
composeNewEmailTo(email) {
|
||||||
|
openComposer({
|
||||||
|
to: email,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// * END --- ACTIONS
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render the table header
|
||||||
|
|
||||||
|
* @returns {JSX.Element}
|
||||||
|
*/
|
||||||
|
HeaderItem() {
|
||||||
|
return (
|
||||||
|
<View style={styles.item}>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => {
|
||||||
|
this.sortContacts('lastname');
|
||||||
|
}}>
|
||||||
|
<Text style={{ ...styles.clickable, color: this.props.mainColor }}>
|
||||||
|
{i18n.t('global.lastname')} <FontAwesome5 name={'sort'} />
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => {
|
||||||
|
this.sortContacts('email');
|
||||||
|
}}>
|
||||||
|
<Text style={{ ...styles.clickable, color: this.props.mainColor }}>
|
||||||
|
{i18n.t('global.email')} <FontAwesome5 name={'sort'} />
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() => {
|
||||||
|
this.sortContacts('phone');
|
||||||
|
}}>
|
||||||
|
<Text style={{ ...styles.clickable, color: this.props.mainColor }}>
|
||||||
|
{i18n.t('global.phone')} <FontAwesome5 name={'sort'} />
|
||||||
|
</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<Text style={styles.buttons} />
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render a line of contact
|
||||||
|
* @param {import('../Models/Contact').Contact} contact
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
Item(contact) {
|
||||||
|
const displayName =
|
||||||
|
String(contact.lastname ?? '').toUpperCase() +
|
||||||
|
' ' +
|
||||||
|
(contact.firstname ?? '');
|
||||||
return (
|
return (
|
||||||
<View style={styles.item}>
|
<View style={styles.item}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
onPress={() =>
|
onPress={() =>
|
||||||
this.props.navigation.navigate('ContactDetailsScreen', {
|
this.props.navigation.navigate('ContactDetailsScreen', {
|
||||||
action: 'edit',
|
action: 'edit',
|
||||||
contactId: item.id,
|
contactId: contact.id,
|
||||||
})
|
})
|
||||||
}>
|
}>
|
||||||
<Text style={{ ...styles.clickable, color: this.props.mainColor }}>
|
<Text style={{ ...styles.clickable, color: this.props.mainColor }}>
|
||||||
{item.name.toUpperCase()} {item.firstname}
|
{contact.lastname || contact.firstname ? displayName : contact.id}
|
||||||
</Text>
|
</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<Text style={styles.company}>{item.company}</Text>
|
<TouchableOpacity onPress={() => this.composeNewEmailTo(contact.email)}>
|
||||||
<Text style={styles.email}>{item.email}</Text>
|
<Text style={{ ...styles.clickable }}>{contact.email}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity
|
||||||
|
onPress={() =>
|
||||||
|
contact.phone ? this.callNumberIfSupported(contact.phone) : false
|
||||||
|
}>
|
||||||
|
<Text style={{ ...styles.clickable }}>{contact.phone}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
<View style={styles.buttons}>
|
<View style={styles.buttons}>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.button}
|
style={styles.button}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.deleteContactAction(item.id);
|
this.deleteContactAction(contact);
|
||||||
}}>
|
}}>
|
||||||
<FontAwesome5 name="trash" size={20} color={this.props.mainColor} />
|
<FontAwesome5 name="trash" size={20} color={this.props.mainColor} />
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|
@ -192,10 +306,14 @@ class ContactScreen extends React.Component {
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
showTransferContact: true,
|
showTransferContact: true,
|
||||||
contactToTransfer: item,
|
contactToTransfer: contact,
|
||||||
});
|
});
|
||||||
}}>
|
}}>
|
||||||
<FontAwesome5 name="paper-plane" size={20} color={this.props.mainColor} />
|
<FontAwesome5
|
||||||
|
name="paper-plane"
|
||||||
|
size={20}
|
||||||
|
color={this.props.mainColor}
|
||||||
|
/>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -213,46 +331,67 @@ class ContactScreen extends React.Component {
|
||||||
sort = 'asc';
|
sort = 'asc';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.setState({ contacts: this.state.contacts.sort(Helpers.compareValues(field, sort)), sortType: sort, sortField: field });
|
this.setState({
|
||||||
}
|
contacts: this.state.contacts.sort(Helpers.compareValues(field, sort)),
|
||||||
|
sortType: sort,
|
||||||
HeaderItem() {
|
sortField: field,
|
||||||
return (
|
});
|
||||||
<View style={styles.item}>
|
|
||||||
<TouchableOpacity onPress={() => {
|
|
||||||
this.sortContacts('name');
|
|
||||||
}}>
|
|
||||||
<Text style={{ ...styles.clickable, color: this.props.mainColor }}>{i18n.t('global.name')} <FontAwesome5 name={'sort'} /></Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
<TouchableOpacity onPress={() => {
|
|
||||||
this.sortContacts('company');
|
|
||||||
}}>
|
|
||||||
<Text style={{ ...styles.clickable, color: this.props.mainColor }}>{i18n.t('global.company')} <FontAwesome5 name={'sort'} /></Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
<Text style={styles.email}>{i18n.t('global.email')}</Text>
|
|
||||||
<Text style={styles.buttons} />
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSearchBtn() {
|
handleSearchBtn() {
|
||||||
if (this.state.searchTxt.length > 0) {
|
if (this.state.searchTxt.length > 0) {
|
||||||
let obj = this.props.contacts;
|
let obj = this.props.contacts;
|
||||||
let array = Object.keys(obj).map(function (key) { return obj[key]; });
|
let array = Object.keys(obj).map(function (key) {
|
||||||
this.setState({ contacts: array.sort(Helpers.compareValues('name', 'asc')), sortType: 'asc', searchTxt: '' });
|
return obj[key];
|
||||||
|
});
|
||||||
|
this.setState({
|
||||||
|
contacts: array.sort(Helpers.compareValues('name', 'asc')),
|
||||||
|
sortType: 'asc',
|
||||||
|
searchTxt: '',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handleSearchTxt(text) {
|
handleSearchTxt(text) {
|
||||||
this.setState({ searchTxt: text });
|
this.setState({ searchTxt: text });
|
||||||
|
/** @type {Array<import('./../Models/Contact').Contact>} */
|
||||||
|
const contacts = this.props.contacts;
|
||||||
if (text.length > 0) {
|
if (text.length > 0) {
|
||||||
let tmpContactsName = this.props.contacts.filter(item => item.name.toLowerCase().indexOf(text.toLowerCase()) >= 0);
|
const tmpContactsLastname = contacts.filter(
|
||||||
let tmpContactsCompany = this.props.contacts.filter(item => item.company.toLowerCase().indexOf(text.toLowerCase()) >= 0);
|
item => item.lastname?.toLowerCase()?.indexOf(text.toLowerCase()) >= 0,
|
||||||
let resSearch = Object.assign(tmpContactsName, tmpContactsCompany);
|
);
|
||||||
this.setState({ contacts: resSearch.sort(Helpers.compareValues('name', 'asc')), sortType: 'asc' });
|
const tmpContactsFirstname = contacts.filter(
|
||||||
|
item => item.firstname?.toLowerCase()?.indexOf(text.toLowerCase()) >= 0,
|
||||||
|
);
|
||||||
|
const tmpContactsEmail = contacts.filter(
|
||||||
|
item => item.email.toLowerCase().indexOf(text.toLowerCase()) >= 0,
|
||||||
|
);
|
||||||
|
const tmpContactsPhone = contacts.filter(
|
||||||
|
item => item.phone?.toLowerCase()?.indexOf(text.toLowerCase()) >= 0,
|
||||||
|
);
|
||||||
|
const resSearch = new Map();
|
||||||
|
tmpContactsLastname.forEach(contact =>
|
||||||
|
resSearch.set(contact.id, contact),
|
||||||
|
);
|
||||||
|
tmpContactsFirstname.forEach(contact =>
|
||||||
|
resSearch.set(contact.id, contact),
|
||||||
|
);
|
||||||
|
tmpContactsEmail.forEach(contact => resSearch.set(contact.id, contact));
|
||||||
|
tmpContactsPhone.forEach(contact => resSearch.set(contact.id, contact));
|
||||||
|
this.setState({
|
||||||
|
contacts: [...resSearch.values()].sort(
|
||||||
|
Helpers.compareValues('name', 'asc'),
|
||||||
|
),
|
||||||
|
sortType: 'asc',
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
let obj = this.props.contacts;
|
let obj = this.props.contacts;
|
||||||
let array = Object.keys(obj).map(function (key) { return obj[key]; });
|
let array = Object.keys(obj).map(function (key) {
|
||||||
this.setState({ contacts: array.sort(Helpers.compareValues('name', 'asc')), sortType: 'asc' });
|
return obj[key];
|
||||||
|
});
|
||||||
|
this.setState({
|
||||||
|
contacts: array.sort(Helpers.compareValues('name', 'asc')),
|
||||||
|
sortType: 'asc',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -269,12 +408,25 @@ class ContactScreen extends React.Component {
|
||||||
init() {
|
init() {
|
||||||
let objContacts = this.props.contacts;
|
let objContacts = this.props.contacts;
|
||||||
let objDocs = this.props.documents;
|
let objDocs = this.props.documents;
|
||||||
let arrayContacts = Object.keys(objContacts).map(function (key) { return objContacts[key]; });
|
let arrayContacts = Object.keys(objContacts).map(function (key) {
|
||||||
let arrayEmails = Object.keys(objContacts).map(function (key) { return objContacts[key]; });
|
return objContacts[key];
|
||||||
let arrayDocs = Object.keys(objDocs).map(function (key) { return objDocs[key]; });
|
});
|
||||||
|
let arrayEmails = Object.keys(objContacts).map(function (key) {
|
||||||
|
return objContacts[key];
|
||||||
|
});
|
||||||
|
let arrayDocs = Object.keys(objDocs).map(function (key) {
|
||||||
|
return objDocs[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
const { action } = this.props.route.params;
|
||||||
|
if (action === 'add') {
|
||||||
|
this.props.navigation.navigate('ContactDetailsScreen', {
|
||||||
|
action: 'add',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
contacts: arrayContacts.sort(Helpers.compareValues('name', 'asc')),
|
contacts: arrayContacts.sort(Helpers.compareValues('timestamp', 'desc')),
|
||||||
sortedDocuments: arrayDocs.sort(Helpers.compareValues('title', 'asc')),
|
sortedDocuments: arrayDocs.sort(Helpers.compareValues('title', 'asc')),
|
||||||
sortedEmails: arrayEmails.sort(Helpers.compareValues('email', 'asc')),
|
sortedEmails: arrayEmails.sort(Helpers.compareValues('email', 'asc')),
|
||||||
sortType: 'asc',
|
sortType: 'asc',
|
||||||
|
|
@ -283,12 +435,8 @@ class ContactScreen extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { contactAdded, action } = this.props.route.params;
|
const { contactAdded } = this.props.route.params;
|
||||||
if (action === 'add') {
|
|
||||||
this.props.navigation.navigate('ContactDetailsScreen', {
|
|
||||||
action: 'add',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
if (contactAdded === true) {
|
if (contactAdded === true) {
|
||||||
this.props.navigation.setParams({ contactAdded: false });
|
this.props.navigation.setParams({ contactAdded: false });
|
||||||
showMessage({
|
showMessage({
|
||||||
|
|
@ -299,6 +447,7 @@ class ContactScreen extends React.Component {
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
|
{/* ACTIONS */}
|
||||||
<View
|
<View
|
||||||
style={{
|
style={{
|
||||||
marginTop: 20,
|
marginTop: 20,
|
||||||
|
|
@ -321,8 +470,18 @@ class ContactScreen extends React.Component {
|
||||||
onPress={() => this.setState({ showSendBrochure: true })}
|
onPress={() => this.setState({ showSendBrochure: true })}
|
||||||
/>
|
/>
|
||||||
<View style={{ flexDirection: 'row' }}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
<TextInput placeholder={i18n.t('global.search')} style={styles.inputSearch} value={this.state.searchTxt} onChangeText={(text) => this.handleSearchTxt(text)} />
|
<TextInput
|
||||||
<TouchableOpacity style={{ ...styles.btnSearch, backgroundColor: this.props.mainColor }} onPress={() => this.handleSearchBtn()}>
|
placeholder={i18n.t('global.search')}
|
||||||
|
style={styles.inputSearch}
|
||||||
|
value={this.state.searchTxt}
|
||||||
|
onChangeText={text => this.handleSearchTxt(text)}
|
||||||
|
/>
|
||||||
|
<TouchableOpacity
|
||||||
|
style={{
|
||||||
|
...styles.btnSearch,
|
||||||
|
backgroundColor: this.props.mainColor,
|
||||||
|
}}
|
||||||
|
onPress={() => this.handleSearchBtn()}>
|
||||||
{this.state.searchTxt.length > 0 ? (
|
{this.state.searchTxt.length > 0 ? (
|
||||||
<FontAwesome5 name={'times'} size={20} color={'white'} />
|
<FontAwesome5 name={'times'} size={20} color={'white'} />
|
||||||
) : (
|
) : (
|
||||||
|
|
@ -331,6 +490,7 @@ class ContactScreen extends React.Component {
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
{/* TABLE view */}
|
||||||
<View style={{ flex: 1, marginTop: 20 }}>
|
<View style={{ flex: 1, marginTop: 20 }}>
|
||||||
<FlatList
|
<FlatList
|
||||||
data={this.state.contacts}
|
data={this.state.contacts}
|
||||||
|
|
@ -339,6 +499,7 @@ class ContactScreen extends React.Component {
|
||||||
keyExtractor={item => item.id.toString()}
|
keyExtractor={item => item.id.toString()}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
{/* TRANSFERT CONTACT POPUP */}
|
||||||
<Overlay
|
<Overlay
|
||||||
isVisible={this.state.showTransferContact}
|
isVisible={this.state.showTransferContact}
|
||||||
windowBackgroundColor="rgba(255, 255, 255, .9)"
|
windowBackgroundColor="rgba(255, 255, 255, .9)"
|
||||||
|
|
@ -347,19 +508,30 @@ class ContactScreen extends React.Component {
|
||||||
height={300}>
|
height={300}>
|
||||||
<View
|
<View
|
||||||
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||||
<Text style={{ marginBottom: 10 }}>{i18n.t('contact_s.select_contact')} :</Text>
|
<Text style={{ marginBottom: 10 }}>
|
||||||
|
{i18n.t('contact_s.select_contact')} :
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
style={{
|
style={{
|
||||||
width: 300,
|
width: 300,
|
||||||
marginBottom: 15,
|
marginBottom: 15,
|
||||||
paddingLeft: 10,
|
paddingLeft: 10,
|
||||||
}}
|
}}
|
||||||
selectedValue={this.state.selectedTransferUser}
|
selectedValue={this.state.selectedTransferUserIndex}
|
||||||
onValueChange={(itemValue, itemIndex) => {
|
onValueChange={(itemValue, itemIndex) => {
|
||||||
this.setState({ selectedTransferUser: itemIndex });
|
this.setState({ selectedTransferUserIndex: itemIndex });
|
||||||
}}>
|
}}>
|
||||||
{this.props.users.filter(user => user.id !== this.props.currentUser.id).map((item, index) => {
|
{this.props.users
|
||||||
return <Picker.Item label={item.email} value={index} key={item.id.toString()} />;
|
.filter(user => user.id !== this.props.currentUser.id)
|
||||||
|
.sort(Helpers.compareValues('email', 'asc'))
|
||||||
|
.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item.email}
|
||||||
|
value={index}
|
||||||
|
key={item.id.toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
<View
|
<View
|
||||||
|
|
@ -382,6 +554,7 @@ class ContactScreen extends React.Component {
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
|
{/* DELETE CONTACT POPUP */}
|
||||||
<Overlay
|
<Overlay
|
||||||
isVisible={this.state.showSendBrochure}
|
isVisible={this.state.showSendBrochure}
|
||||||
windowBackgroundColor="rgba(255, 255, 255, .9)"
|
windowBackgroundColor="rgba(255, 255, 255, .9)"
|
||||||
|
|
@ -417,14 +590,23 @@ class ContactScreen extends React.Component {
|
||||||
onValueChange={(itemValue, itemIndex) => {
|
onValueChange={(itemValue, itemIndex) => {
|
||||||
if (itemValue !== '-1') {
|
if (itemValue !== '-1') {
|
||||||
this.setState({
|
this.setState({
|
||||||
tmpSendBrochureEmail: this.state.sortedEmails[itemIndex - 1]
|
tmpSendBrochureEmail:
|
||||||
.email,
|
this.state.sortedEmails[itemIndex - 1].email,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Picker.Item label={i18n.t('contact_s.contact_list') + ' :'} value="-1" />
|
<Picker.Item
|
||||||
|
label={i18n.t('contact_s.contact_list') + ' :'}
|
||||||
|
value="-1"
|
||||||
|
/>
|
||||||
{this.state.sortedEmails.map((item, index) => {
|
{this.state.sortedEmails.map((item, index) => {
|
||||||
return <Picker.Item label={item.email} value={index} key={item.id.toString()} />;
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item.email}
|
||||||
|
value={index}
|
||||||
|
key={item.id.toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
<TextInput
|
<TextInput
|
||||||
|
|
@ -457,7 +639,7 @@ class ContactScreen extends React.Component {
|
||||||
itemValue !== '-1' &&
|
itemValue !== '-1' &&
|
||||||
this.state.sendDocumentList.length < 8
|
this.state.sendDocumentList.length < 8
|
||||||
) {
|
) {
|
||||||
let tmp = this.state.sendDocumentList;
|
const tmp = this.state.sendDocumentList;
|
||||||
const toPush = this.state.sortedDocuments[itemIndex - 1];
|
const toPush = this.state.sortedDocuments[itemIndex - 1];
|
||||||
const test = this.state.sendDocumentList.filter(
|
const test = this.state.sendDocumentList.filter(
|
||||||
item => item.id === toPush.id,
|
item => item.id === toPush.id,
|
||||||
|
|
@ -470,7 +652,10 @@ class ContactScreen extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Picker.Item label={i18n.t('contact_s.documents_list') + ' :'} value="-1" />
|
<Picker.Item
|
||||||
|
label={i18n.t('contact_s.documents_list') + ' :'}
|
||||||
|
value="-1"
|
||||||
|
/>
|
||||||
{this.state.sortedDocuments.map((item, index) => {
|
{this.state.sortedDocuments.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<Picker.Item
|
<Picker.Item
|
||||||
|
|
@ -498,7 +683,7 @@ class ContactScreen extends React.Component {
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
key={index}
|
key={index}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
let tmp = this.state.sendDocumentList;
|
const tmp = this.state.sendDocumentList;
|
||||||
tmp.splice(this.props.documents[index], 1);
|
tmp.splice(this.props.documents[index], 1);
|
||||||
this.setState({
|
this.setState({
|
||||||
sendDocumentList: tmp,
|
sendDocumentList: tmp,
|
||||||
|
|
@ -545,7 +730,11 @@ class ContactScreen extends React.Component {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
<Button title={i18n.t('global.send')} onPress={() => this.sendBrochure()} color={this.props.mainColor} />
|
<Button
|
||||||
|
title={i18n.t('global.send')}
|
||||||
|
onPress={() => this.sendBrochure()}
|
||||||
|
color={this.props.mainColor}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import { Image, ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
||||||
View,
|
|
||||||
ScrollView,
|
|
||||||
TouchableOpacity,
|
|
||||||
Text,
|
|
||||||
Image
|
|
||||||
} from 'react-native';
|
|
||||||
// Redux
|
// Redux
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { initDocuments } from '../Store/Actions/documents';
|
|
||||||
// Treeview
|
// Treeview
|
||||||
import TreeView from 'react-native-animated-tree-view';
|
import TreeView from 'react-native-animated-tree-view';
|
||||||
// Icon
|
// Icon
|
||||||
|
|
@ -23,7 +16,7 @@ function mapStateToProps(state) {
|
||||||
documents: state.documents,
|
documents: state.documents,
|
||||||
directories: state.directories,
|
directories: state.directories,
|
||||||
locale: state.locale.locale,
|
locale: state.locale.locale,
|
||||||
mainColor: state.app.mainColor
|
mainColor: state.app.mainColor,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -63,7 +56,7 @@ class DirectoriesScreen extends React.Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
documents: this.props.documents.filter(
|
documents: this.props.documents.filter(
|
||||||
tmp => tmp.directory === folder.id,
|
tmp => tmp.directory === folder.id,
|
||||||
)
|
),
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
@ -82,7 +75,7 @@ class DirectoriesScreen extends React.Component {
|
||||||
} else if (document.type === 'mp4') {
|
} else if (document.type === 'mp4') {
|
||||||
this.props.navigation.navigate('VideoScreen', { uuid: document.uuid });
|
this.props.navigation.navigate('VideoScreen', { uuid: document.uuid });
|
||||||
} else {
|
} else {
|
||||||
console.log('Inconnu');
|
console.error('Type de document Inconnu');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,26 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { View, ImageBackground, TouchableOpacity, Text, Image } from 'react-native';
|
import {
|
||||||
|
Image,
|
||||||
|
ImageBackground,
|
||||||
|
Text,
|
||||||
|
TouchableOpacity,
|
||||||
|
View,
|
||||||
|
} from 'react-native';
|
||||||
// Common Styles
|
// Common Styles
|
||||||
import commonStyles from '../../Resources/CommonStyles';
|
import commonStyles from '../../Resources/CommonStyles';
|
||||||
// Redux
|
// Redux
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { initDocuments } from '../Store/Actions/documents';
|
|
||||||
import { initContact } from '../Store/Actions/contacts';
|
import { initContact } from '../Store/Actions/contacts';
|
||||||
import { initDirectories } from '../Store/Actions/directories';
|
import { initDirectories } from '../Store/Actions/directories';
|
||||||
|
import { initDocuments } from '../Store/Actions/documents';
|
||||||
// SplashScreen
|
// SplashScreen
|
||||||
import * as SplashScreen from 'expo-splash-screen';
|
import * as SplashScreen from 'expo-splash-screen';
|
||||||
// Style
|
// Style
|
||||||
import styles from '../../Resources/Styles/HomeStyle';
|
import styles from '../../Resources/Styles/HomeStyle';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from "../../I18n";
|
import i18n from '../../I18n';
|
||||||
// FileSytem
|
// FileSytem
|
||||||
import * as FileSystem from 'expo-file-system';
|
import * as FileSystem from 'expo-file-system';
|
||||||
// NetInfo
|
|
||||||
import NetInfo from '@react-native-community/netinfo';
|
|
||||||
// Controller
|
// Controller
|
||||||
import SyncController from '../Controllers/SyncController';
|
import SyncController from '../Controllers/SyncController';
|
||||||
|
|
||||||
|
|
@ -25,22 +29,21 @@ function mapStateToProps(state) {
|
||||||
btns: state.app.HomeBtns,
|
btns: state.app.HomeBtns,
|
||||||
directories: state.directories,
|
directories: state.directories,
|
||||||
locale: state.locale.locale,
|
locale: state.locale.locale,
|
||||||
currentUser: state.app.currentUser
|
currentUser: state.app.currentUser,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
initBtns: () => dispatch({ type: 'INIT_HOME_BTNS' }),
|
initBtns: () => dispatch({ type: 'INIT_HOME_BTNS' }),
|
||||||
initDocuments: (lang, directories) => dispatch(initDocuments(lang, directories)),
|
initDocuments: (lang, directories) =>
|
||||||
|
dispatch(initDocuments(lang, directories)),
|
||||||
initContact: currentUser => dispatch(initContact(currentUser)),
|
initContact: currentUser => dispatch(initContact(currentUser)),
|
||||||
initDirectories: (lang, user) => dispatch(initDirectories(lang, user)),
|
initDirectories: (lang, user) => dispatch(initDirectories(lang, user)),
|
||||||
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class HomeScreen extends React.Component {
|
class HomeScreen extends React.Component {
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
lastSyncCall: '1970-01-01',
|
lastSyncCall: '1970-01-01',
|
||||||
};
|
};
|
||||||
|
|
@ -50,6 +53,7 @@ class HomeScreen extends React.Component {
|
||||||
return this.openSync();
|
return this.openSync();
|
||||||
}
|
}
|
||||||
this.props.initBtns();
|
this.props.initBtns();
|
||||||
|
console.debug(this.props.currentUser);
|
||||||
this.props.initContact(this.props.currentUser);
|
this.props.initContact(this.props.currentUser);
|
||||||
this.props.initDirectories(this.props.locale, this.props.currentUser);
|
this.props.initDirectories(this.props.locale, this.props.currentUser);
|
||||||
this.props.initDocuments(this.props.locale, this.props.directories.global);
|
this.props.initDocuments(this.props.locale, this.props.directories.global);
|
||||||
|
|
@ -57,19 +61,6 @@ class HomeScreen extends React.Component {
|
||||||
SplashScreen.hideAsync();
|
SplashScreen.hideAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsubscribe() {
|
|
||||||
NetInfo.addEventListener(state => {
|
|
||||||
if (state.isConnected === true) {
|
|
||||||
let seconds =
|
|
||||||
Math.abs(new Date(this.state.lastSyncCall) - Date.now()) / 1000;
|
|
||||||
if (seconds > 30) {
|
|
||||||
this.setState({ lastSyncCall: Date.now() });
|
|
||||||
SyncController.needSync(this.openSync.bind(this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
openSync() {
|
openSync() {
|
||||||
this.props.navigation.navigate('SyncScreen', { forceSync: true });
|
this.props.navigation.navigate('SyncScreen', { forceSync: true });
|
||||||
}
|
}
|
||||||
|
|
@ -77,21 +68,46 @@ class HomeScreen extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
i18n.locale = this.props.locale;
|
i18n.locale = this.props.locale;
|
||||||
return (
|
return (
|
||||||
<ImageBackground source={{ uri: FileSystem.documentDirectory + 'BackgroundImage.png' }} style={commonStyles.background} resizeMode='cover'>
|
<ImageBackground
|
||||||
|
source={{ uri: FileSystem.documentDirectory + 'BackgroundImage.png' }}
|
||||||
|
style={commonStyles.background}
|
||||||
|
resizeMode="cover">
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
{this.renderBtns()}
|
{this.renderBtns()}
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
key={'OnlyVideos'}
|
key={'OnlyVideos'}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.props.initDocuments(this.props.locale, this.props.directories.global);
|
this.props.initDocuments(
|
||||||
|
this.props.locale,
|
||||||
|
this.props.directories.global,
|
||||||
|
);
|
||||||
this.props.navigation.navigate('OnlyVideosScreen');
|
this.props.navigation.navigate('OnlyVideosScreen');
|
||||||
}}
|
}}
|
||||||
style={styles.button}>
|
style={styles.button}>
|
||||||
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
<Image
|
||||||
|
source={{
|
||||||
|
uri: FileSystem.documentDirectory + 'HomeButtonImage.png',
|
||||||
|
}}
|
||||||
|
style={styles.btnImg}
|
||||||
|
/>
|
||||||
<Text style={styles.btnTxt}>{i18n.t('global.videos')}</Text>
|
<Text style={styles.btnTxt}>{i18n.t('global.videos')}</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
<TouchableOpacity key={'Contacts'} onPress={() => this.props.navigation.navigate('ContactScreen')} style={styles.button}>
|
<TouchableOpacity
|
||||||
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
key={'Contacts'}
|
||||||
|
onPress={() => {
|
||||||
|
this.props.initDocuments(
|
||||||
|
this.props.locale,
|
||||||
|
this.props.directories.global,
|
||||||
|
);
|
||||||
|
this.props.navigation.navigate('ContactScreen');
|
||||||
|
}}
|
||||||
|
style={styles.button}>
|
||||||
|
<Image
|
||||||
|
source={{
|
||||||
|
uri: FileSystem.documentDirectory + 'HomeButtonImage.png',
|
||||||
|
}}
|
||||||
|
style={styles.btnImg}
|
||||||
|
/>
|
||||||
<Text style={styles.btnTxt}>{i18n.t('global.contacts')}</Text>
|
<Text style={styles.btnTxt}>{i18n.t('global.contacts')}</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -102,16 +118,26 @@ class HomeScreen extends React.Component {
|
||||||
renderBtns() {
|
renderBtns() {
|
||||||
let locale = this.props.locale;
|
let locale = this.props.locale;
|
||||||
let objBtns = this.props.btns;
|
let objBtns = this.props.btns;
|
||||||
let array = Object.keys(objBtns).map(function (key) { return objBtns[key]; });
|
let array = Object.keys(objBtns).map(function (key) {
|
||||||
|
return objBtns[key];
|
||||||
|
});
|
||||||
return array.map((item, index) => {
|
return array.map((item, index) => {
|
||||||
let names = JSON.parse(item.name);
|
let names = JSON.parse(item.name);
|
||||||
let name = (locale in names) ? names[locale] : names.fr;
|
let name = locale in names ? names[locale] : names.fr;
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity key={index} onPress={() => this.openFolder(item.id)} style={styles.button}>
|
<TouchableOpacity
|
||||||
<Image source={{ uri: FileSystem.documentDirectory + 'HomeButtonImage.png' }} style={styles.btnImg} />
|
key={index}
|
||||||
|
onPress={() => this.openFolder(item.id)}
|
||||||
|
style={styles.button}>
|
||||||
|
<Image
|
||||||
|
source={{
|
||||||
|
uri: FileSystem.documentDirectory + 'HomeButtonImage.png',
|
||||||
|
}}
|
||||||
|
style={styles.btnImg}
|
||||||
|
/>
|
||||||
<Text style={styles.btnTxt}>{name}</Text>
|
<Text style={styles.btnTxt}>{name}</Text>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
)
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,17 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { ImageBackground, View, Image, Text, TextInput, Button, Alert } from 'react-native';
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Image,
|
||||||
|
ImageBackground,
|
||||||
|
Text,
|
||||||
|
TextInput,
|
||||||
|
View,
|
||||||
|
} from 'react-native';
|
||||||
// Redux
|
// Redux
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
// Sentry
|
// Sentry
|
||||||
import * as Sentry from "@sentry/react-native";
|
import * as Sentry from '@sentry/react-native';
|
||||||
// SplashScreen
|
// SplashScreen
|
||||||
import * as SplashScreen from 'expo-splash-screen';
|
import * as SplashScreen from 'expo-splash-screen';
|
||||||
// Helpers
|
// Helpers
|
||||||
|
|
@ -15,12 +23,12 @@ import commonStyles from '../../Resources/CommonStyles';
|
||||||
// Style
|
// Style
|
||||||
import styles from '../../Resources/Styles/InstallStyle';
|
import styles from '../../Resources/Styles/InstallStyle';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from "../../I18n";
|
import i18n from '../../I18n';
|
||||||
// Controller
|
// Controller
|
||||||
import InstallController from '../Controllers/InstallController';
|
import InstallController from '../Controllers/InstallController';
|
||||||
import SyncController from '../Controllers/SyncController';
|
import SyncController from '../Controllers/SyncController';
|
||||||
// Database
|
// Database
|
||||||
import { User, Setting } from '../../Database';
|
import { Setting, User } from '../../Database';
|
||||||
// FileSytem
|
// FileSytem
|
||||||
import * as FileSystem from 'expo-file-system';
|
import * as FileSystem from 'expo-file-system';
|
||||||
|
|
||||||
|
|
@ -34,15 +42,15 @@ function mapStateToProps(state) {
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
setIsSetup: () => dispatch({ type: 'SET_ISSETUP' }),
|
setIsSetup: () => dispatch({ type: 'SET_ISSETUP' }),
|
||||||
init: () => dispatch({ type: 'INIT' })
|
init: () => dispatch({ type: 'INIT' }),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
class InstallScreen extends React.Component {
|
class InstallScreen extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
processing: false,
|
processing: false,
|
||||||
txtStep: '',
|
txtStep: '',
|
||||||
url: "",
|
url: '',
|
||||||
}
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
SplashScreen.hideAsync();
|
SplashScreen.hideAsync();
|
||||||
|
|
@ -51,39 +59,49 @@ class InstallScreen extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
i18n.locale = this.props.locale;
|
i18n.locale = this.props.locale;
|
||||||
return (
|
return (
|
||||||
<ImageBackground source={require('../../Resources/assets/img/background_ldc.png')} style={commonStyles.background}>
|
<ImageBackground
|
||||||
|
source={require('../../Resources/assets/img/background_ldc.png')}
|
||||||
|
style={commonStyles.background}>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Image source={require('../../Resources/assets/img/logo-square-ldc.png')} style={styles.logo} />
|
<Image
|
||||||
|
source={require('../../Resources/assets/img/logo-square-ldc.png')}
|
||||||
|
style={styles.logo}
|
||||||
|
/>
|
||||||
<View style={styles.actions}>
|
<View style={styles.actions}>
|
||||||
<TextInput
|
<TextInput
|
||||||
keyboardType='url'
|
keyboardType="url"
|
||||||
autoCapitalize='none'
|
autoCapitalize="none"
|
||||||
style={commonStyles.textInput}
|
style={commonStyles.textInput}
|
||||||
placeholder={i18n.t("install.enter_url")}
|
placeholder={i18n.t('install.enter_url')}
|
||||||
onChangeText={(newText) => this.setState({ url: newText })}
|
onChangeText={newText => this.setState({ url: newText })}
|
||||||
value={this.state.url}
|
value={this.state.url}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
disabled={this.state.processing}
|
disabled={this.state.processing}
|
||||||
color={'#D4021D'}
|
color={'#D4021D'}
|
||||||
title={ i18n.t('install.install')}
|
title={i18n.t('install.install')}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
if (this.state.url.length === 0) {
|
if (this.state.url.length === 0) {
|
||||||
Alert.alert(i18n.t("alert.error"), i18n.t("install.enter_url"));
|
Alert.alert(
|
||||||
|
i18n.t('alert.error'),
|
||||||
|
i18n.t('install.enter_url'),
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
if (Helpers.isUrlValid(this.state.url)) {
|
// * Ignore ths check on dev, just install.
|
||||||
|
if (__DEV__ || Helpers.isUrlValid(this.state.url)) {
|
||||||
this.install();
|
this.install();
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(i18n.t("alert.error"), i18n.t("install.url_invalid"));
|
Alert.alert(
|
||||||
|
i18n.t('alert.error'),
|
||||||
|
i18n.t('install.url_invalid'),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<View style={styles.actions}>
|
<View style={styles.actions}>
|
||||||
<Text>
|
<Text>{this.state.txtStep}</Text>
|
||||||
{this.state.txtStep}
|
|
||||||
</Text>
|
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</ImageBackground>
|
</ImageBackground>
|
||||||
|
|
@ -93,89 +111,99 @@ class InstallScreen extends React.Component {
|
||||||
async install() {
|
async install() {
|
||||||
let url = this.state.url.toLowerCase();
|
let url = this.state.url.toLowerCase();
|
||||||
Setting.upsert({ key: 'bo_url', value: url });
|
Setting.upsert({ key: 'bo_url', value: url });
|
||||||
const isConnected = await SyncController.checkConnection().then(state => {
|
const isConnected = await SyncController.checkConnection()
|
||||||
//console.log(state.isConnected)
|
.then(state => {
|
||||||
return state.isConnected
|
console.debug(state.isConnected);
|
||||||
}).catch(error => {
|
return state.isConnected;
|
||||||
//console.log(error);
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
if (!isConnected) {
|
if (!isConnected) {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
i18n.t('global.warning'),
|
i18n.t('global.warning'),
|
||||||
i18n.t('error.must_be_connected_internet_sync')
|
i18n.t('error.must_be_connected_internet_sync'),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setState({ processing: true, txtStep: i18n.t("install.get_app_setting") });
|
this.setState({
|
||||||
const toDL = await InstallController.getConfig(url).then(response => {
|
processing: true,
|
||||||
|
txtStep: i18n.t('install.get_app_setting'),
|
||||||
|
});
|
||||||
|
const toDL = await InstallController.getConfig(url)
|
||||||
|
.then(response => {
|
||||||
let toDL = [];
|
let toDL = [];
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
if (response.data.status === "OK") {
|
if (response.data.status === 'OK') {
|
||||||
|
const rootUrl = url.substring(0, url.lastIndexOf('/'));
|
||||||
_.forEach(response.data.datas, function (value, key) {
|
_.forEach(response.data.datas, function (value, key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case "MainColor":
|
case 'MainColor':
|
||||||
case "AppStoreUUID":
|
|
||||||
case "FormSelect1":
|
|
||||||
case "FormSelect2":
|
|
||||||
case "FormCheck":
|
|
||||||
Setting.upsert({ key: key, value: value });
|
Setting.upsert({ key: key, value: value });
|
||||||
break;
|
break;
|
||||||
case "SquaredLogo":
|
case 'SquaredLogo':
|
||||||
case "RectangleLogo":
|
case 'RectangleLogo':
|
||||||
case "BackgroundImage":
|
case 'BackgroundImage':
|
||||||
case "HomeButtonImage":
|
case 'HomeButtonImage':
|
||||||
toDL.push({
|
toDL.push({
|
||||||
source: url + "/" + value,
|
source: rootUrl + '/' + value,
|
||||||
dest: FileSystem.documentDirectory + key + '.png'
|
dest: FileSystem.documentDirectory + key + '.png',
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return toDL;
|
return toDL;
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
Alert.alert(
|
||||||
|
i18n.t('alert.error'),
|
||||||
|
i18n.t('error.error_has_occurred'),
|
||||||
|
);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch(function (error) {
|
})
|
||||||
|
.catch(function (error) {
|
||||||
Sentry.captureException(error);
|
Sentry.captureException(error);
|
||||||
Alert.alert(i18n.t("alert.error"), i18n.t("error.error_has_occurred"));
|
console.error(error);
|
||||||
|
Alert.alert(i18n.t('alert.error'), i18n.t('error.error_has_occurred'));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
if (!toDL) {
|
if (!toDL) {
|
||||||
this.setState({ processing: false, txtStep: "" });
|
this.setState({ processing: false, txtStep: '' });
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
for await (const file of toDL) {
|
for await (const file of toDL) {
|
||||||
await FileSystem.downloadAsync(
|
await FileSystem.downloadAsync(file.source, file.dest)
|
||||||
file.source,
|
|
||||||
file.dest
|
|
||||||
)
|
|
||||||
.then(({ uri }) => {
|
.then(({ uri }) => {
|
||||||
console.log('Finished downloading to ', uri);
|
console.debug('Finished downloading to ', uri);
|
||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
Alert.alert(i18n.t("alert.error"), i18n.t("install.resource_dl_error") + file.dest);
|
Alert.alert(
|
||||||
|
i18n.t('alert.error'),
|
||||||
|
i18n.t('install.resource_dl_error') + file.dest,
|
||||||
|
);
|
||||||
console.error(error);
|
console.error(error);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({ txtStep: i18n.t("install.get_content_setting") });
|
this.setState({ txtStep: i18n.t('install.get_content_setting') });
|
||||||
if (InstallController.getAppConfig(url)) {
|
if (InstallController.getAppConfig(url)) {
|
||||||
// getUsers
|
// getUsers
|
||||||
this.setState({ txtStep: i18n.t('sync_s.updating_users') + '...' });
|
this.setState({ txtStep: i18n.t('sync_s.updating_users') + '...' });
|
||||||
const resUsers = await SyncController.getUsers().then(res => {
|
const resUsers = await SyncController.getUsers()
|
||||||
|
.then(res => {
|
||||||
User.clear();
|
User.clear();
|
||||||
return res.data;
|
return res.data;
|
||||||
}).catch(error => {
|
})
|
||||||
console.log(error);
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
i18n.t('error.error'),
|
i18n.t('error.error'),
|
||||||
i18n.t('error.error_has_occurred')
|
i18n.t('error.error_has_occurred'),
|
||||||
);
|
);
|
||||||
return
|
return;
|
||||||
});
|
});
|
||||||
resUsers.forEach(user => {
|
resUsers.forEach(user => {
|
||||||
User.add(user);
|
User.add(user);
|
||||||
|
|
@ -184,7 +212,7 @@ class InstallScreen extends React.Component {
|
||||||
this.props.setIsSetup();
|
this.props.setIsSetup();
|
||||||
this.props.navigation.navigate('LoginScreen');
|
this.props.navigation.navigate('LoginScreen');
|
||||||
}
|
}
|
||||||
this.setState({ processing: false, txtStep: "" });
|
this.setState({ processing: false, txtStep: '' });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,12 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { View, ImageBackground, TextInput, Button, Image, Alert } from 'react-native';
|
import {
|
||||||
|
Alert,
|
||||||
|
Button,
|
||||||
|
Image,
|
||||||
|
ImageBackground,
|
||||||
|
TextInput,
|
||||||
|
View,
|
||||||
|
} from 'react-native';
|
||||||
// Redux
|
// Redux
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
// SplashScreen
|
// SplashScreen
|
||||||
|
|
@ -9,13 +16,15 @@ import commonStyles from '../../Resources/CommonStyles';
|
||||||
// Style
|
// Style
|
||||||
import styles from '../../Resources/Styles/LoginStyle';
|
import styles from '../../Resources/Styles/LoginStyle';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from "../../I18n";
|
import i18n from '../../I18n';
|
||||||
// FileSytem
|
// FileSytem
|
||||||
import * as FileSystem from 'expo-file-system';
|
import * as FileSystem from 'expo-file-system';
|
||||||
// Controller
|
// Controller
|
||||||
import LoginController from '../Controllers/LoginController';
|
import LoginController from '../Controllers/LoginController';
|
||||||
// Database
|
// Database
|
||||||
import { Setting } from '../../Database';
|
import _ from 'lodash';
|
||||||
|
import { Setting, User } from '../../Database';
|
||||||
|
import InstallController from '../Controllers/InstallController';
|
||||||
import SyncController from '../Controllers/SyncController';
|
import SyncController from '../Controllers/SyncController';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
|
|
@ -23,18 +32,21 @@ function mapStateToProps(state) {
|
||||||
app: state.app,
|
app: state.app,
|
||||||
users: state.users.users,
|
users: state.users.users,
|
||||||
locale: state.locale.locale,
|
locale: state.locale.locale,
|
||||||
mainColor: state.app.mainColor
|
mainColor: state.app.mainColor,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDispatchToProps = dispatch => {
|
const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
setCurrentUser: () => dispatch({ type: 'SET_CURRENT_USER' }),
|
setCurrentUser: () => dispatch({ type: 'SET_CURRENT_USER' }),
|
||||||
|
setIsSetup: () => dispatch({ type: 'SET_ISSETUP' }),
|
||||||
|
init: () => dispatch({ type: 'INIT' }),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class LoginScreen extends React.Component {
|
class LoginScreen extends React.Component {
|
||||||
state = {
|
state = {
|
||||||
|
syncWorking: false,
|
||||||
login: '',
|
login: '',
|
||||||
password: '',
|
password: '',
|
||||||
};
|
};
|
||||||
|
|
@ -44,13 +56,20 @@ class LoginScreen extends React.Component {
|
||||||
this.props.setCurrentUser(false);
|
this.props.setCurrentUser(false);
|
||||||
}
|
}
|
||||||
SplashScreen.hideAsync();
|
SplashScreen.hideAsync();
|
||||||
|
this.syncUsersIfPossibleAsync();
|
||||||
|
this.syncAppConfigIfPossibleAsync();
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<ImageBackground source={{ uri: FileSystem.documentDirectory + 'BackgroundImage.png' }} style={commonStyles.background}>
|
<ImageBackground
|
||||||
|
source={{ uri: FileSystem.documentDirectory + 'BackgroundImage.png' }}
|
||||||
|
style={commonStyles.background}>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<Image source={{ uri: FileSystem.documentDirectory + 'SquaredLogo.png' }} style={styles.logo} />
|
<Image
|
||||||
|
source={{ uri: FileSystem.documentDirectory + 'SquaredLogo.png' }}
|
||||||
|
style={styles.logo}
|
||||||
|
/>
|
||||||
<View>
|
<View>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.text}
|
style={styles.text}
|
||||||
|
|
@ -71,78 +90,204 @@ class LoginScreen extends React.Component {
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
|
disabled={this.state.syncWorking}
|
||||||
title={i18n.t('global.login')}
|
title={i18n.t('global.login')}
|
||||||
onPress={() => this.login(this.state.login.toLowerCase(), this.state.password)}
|
onPress={() =>
|
||||||
color={this.props.mainColor}
|
this.login(this.state.login.toLowerCase(), this.state.password)
|
||||||
|
}
|
||||||
|
color={!this.state.syncWorking ? this.props.mainColor : 'gray'}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</ImageBackground >
|
</ImageBackground>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async login(login, password) {
|
async login(login, password) {
|
||||||
if (login === '' || password === '') {
|
if (login === '' || password === '') {
|
||||||
Alert.alert(i18n.t("global.warning"), i18n.t('error.must_fill_login_fields'));
|
Alert.alert(
|
||||||
|
i18n.t('global.warning'),
|
||||||
|
i18n.t('error.must_fill_login_fields'),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var usersSize = Object.keys(this.props.users).length;
|
/** @type {Array<import('../Models/User').User>} */
|
||||||
if (usersSize === 0) {
|
const users = this.props.users;
|
||||||
Alert.alert(i18n.t("global.warning"), i18n.t('login_s.missing_users'));
|
if (users.length === 0) {
|
||||||
|
Alert.alert(i18n.t('global.warning'), i18n.t('login_s.missing_users'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let user = this.props.users.filter(tmp => tmp.email === login);
|
const user = users.find(tmp => tmp.email === login);
|
||||||
if (user.length === 0) {
|
if (user === undefined) {
|
||||||
Alert.alert(i18n.t('error.error'), i18n.t('error.incorrect_credentials'));
|
Alert.alert(i18n.t('error.error'), i18n.t('error.incorrect_credentials'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user = user[0];
|
const verified = await LoginController.verify(user, password);
|
||||||
const verified = LoginController.verify(user, password).then(verified => verified);
|
|
||||||
if (!verified) {
|
if (!verified) {
|
||||||
Alert.alert(i18n.t('error.error'), i18n.t('error.incorrect_credentials'));
|
Alert.alert(i18n.t('error.error'), i18n.t('error.incorrect_credentials'));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const isConnected = await SyncController.checkConnection().then(state => {
|
const isConnected = await SyncController.checkConnection()
|
||||||
//console.log(state.isConnected)
|
.then(state => {
|
||||||
return state.isConnected
|
console.debug(state.isConnected);
|
||||||
}).catch(error => {
|
return state.isConnected;
|
||||||
//console.log(error);
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.debug(error);
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
const lastUser = Setting.get('lastUser');
|
const lastUser = Setting.get('lastUser');
|
||||||
// Si on est sur une installation
|
|
||||||
if (lastUser === false || lastUser == undefined) {
|
// * Si on est sur une installation
|
||||||
// Si la tablette est connectée à internet pour forcer la synchro
|
if (lastUser === null) {
|
||||||
|
console.debug('New Install');
|
||||||
|
// * Si la tablette est connectée à internet pour forcer la synchro
|
||||||
if (!isConnected) {
|
if (!isConnected) {
|
||||||
Alert.alert(i18n.t('error.error'), i18n.t('error.tablet_not_connected_internet'));
|
Alert.alert(
|
||||||
|
i18n.t('error.error'),
|
||||||
|
i18n.t('error.tablet_not_connected_internet'),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
return this.loginAction(user);
|
return this.loginAction(user);
|
||||||
}
|
}
|
||||||
// Si on a deja une install
|
|
||||||
if (lastUser !== false && lastUser !== undefined) {
|
// * On a deja eu une install
|
||||||
// Si on a une précédente connexion
|
|
||||||
|
// * Si on a une précédente connexion
|
||||||
if (lastUser.value === user.id.toString()) {
|
if (lastUser.value === user.id.toString()) {
|
||||||
this.loginAction(user);
|
console.debug('Was previously logged in');
|
||||||
} else { // Si le user precedent est different du user courant
|
return this.loginAction(user);
|
||||||
|
}
|
||||||
|
// Si le user precedent est different du user courant
|
||||||
// Si user !== last user && last user not synced
|
// Si user !== last user && last user not synced
|
||||||
if (!SyncController.isSynced()) {
|
if (!SyncController.isSynced(user.id)) {
|
||||||
Alert.alert(i18n.t('error.error'), i18n.t('error.tablet_not_synced_last_user'));
|
Alert.alert(
|
||||||
|
i18n.t('error.error'),
|
||||||
|
i18n.t('error.tablet_not_synced_last_user'),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Si la tablette est connectée à internet pour forcer la synchro
|
// Si la tablette est connectée à internet pour forcer la synchro
|
||||||
if (!isConnected) {
|
if (!isConnected) {
|
||||||
Alert.alert(i18n.t('error.error'), i18n.t('error.tablet_not_connected_internet'));
|
Alert.alert(
|
||||||
|
i18n.t('error.error'),
|
||||||
|
i18n.t('error.tablet_not_connected_internet'),
|
||||||
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.debug('New user loggin');
|
||||||
SyncController.setInstalled(true);
|
SyncController.setInstalled(true);
|
||||||
this.loginAction(user, true);
|
return this.loginAction(user, true);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async syncUsersIfPossibleAsync() {
|
||||||
|
const isConnected = await SyncController.checkConnection();
|
||||||
|
if (!isConnected.isInternetReachable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.debug('sync users ?');
|
||||||
|
this.setState({ syncWorking: true });
|
||||||
|
if (InstallController.getAppConfig(SyncController.getUrlBo())) {
|
||||||
|
// getUsers
|
||||||
|
const resUsers = await SyncController.getUsers()
|
||||||
|
.then(res => {
|
||||||
|
User.clear();
|
||||||
|
console.debug('got users');
|
||||||
|
return res.data;
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
this.setState({ syncWorking: false });
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
if (!resUsers?.length) {
|
||||||
|
this.setState({ syncWorking: false });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resUsers.forEach(user => {
|
||||||
|
User.add(user);
|
||||||
|
});
|
||||||
|
this.setState({ syncWorking: false });
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
async syncAppConfigIfPossibleAsync() {
|
||||||
|
const isConnected = await SyncController.checkConnection();
|
||||||
|
if (!isConnected.isInternetReachable) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.debug('sync settings ?');
|
||||||
|
this.setState({ syncWorking: true });
|
||||||
|
const url = Setting.get('bo_url')?.value;
|
||||||
|
if (!url) {
|
||||||
|
console.warn('url config is wrong');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const toDL = await InstallController.getConfig(url)
|
||||||
|
.then(response => {
|
||||||
|
const toDLArray = [];
|
||||||
|
if (response.data) {
|
||||||
|
if (response.data.status === 'OK') {
|
||||||
|
console.debug('got settings');
|
||||||
|
_.forEach(response.data.datas, function (value, key) {
|
||||||
|
switch (key) {
|
||||||
|
case 'MainColor':
|
||||||
|
Setting.upsert({ key: key, value: value });
|
||||||
|
break;
|
||||||
|
case 'SquaredLogo':
|
||||||
|
case 'RectangleLogo':
|
||||||
|
case 'BackgroundImage':
|
||||||
|
case 'HomeButtonImage':
|
||||||
|
toDLArray.push({
|
||||||
|
source: url + '/' + value,
|
||||||
|
dest: FileSystem.documentDirectory + key + '.png',
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return toDLArray;
|
||||||
|
} else {
|
||||||
|
console.debug('got Ko settings');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
console.debug(response);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
console.error(error);
|
||||||
|
console.error(error.response);
|
||||||
|
return [];
|
||||||
|
});
|
||||||
|
if (!toDL?.length) {
|
||||||
|
this.setState({ syncWorking: false });
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
for await (const file of toDL) {
|
||||||
|
await FileSystem.downloadAsync(file.source, file.dest)
|
||||||
|
.then(({ uri }) => {
|
||||||
|
console.debug('Finished downloading to ', uri);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error(error);
|
||||||
|
this.setState({ syncWorking: false });
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.props.init();
|
||||||
|
this.props.setIsSetup();
|
||||||
|
this.setState({ syncWorking: false });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {import('../Models/User').User} user
|
||||||
|
*/
|
||||||
loginAction(user) {
|
loginAction(user) {
|
||||||
this.setState({ login: '', password: '' });
|
this.setState({ login: '', password: '' });
|
||||||
|
console.debug('loginAction');
|
||||||
LoginController.login(user);
|
LoginController.login(user);
|
||||||
this.props.setCurrentUser();
|
this.props.setCurrentUser();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import {
|
|
||||||
View,
|
|
||||||
Text,
|
|
||||||
} from 'react-native';
|
|
||||||
// Redux
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
// Style
|
|
||||||
import styles from '../../Resources/Styles/MySpaceStyle';
|
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
|
||||||
return {
|
|
||||||
documents: state.app.documents,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class MySpaceScreen extends React.Component {
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<View style={styles.container}>
|
|
||||||
<Text>Mon Espace</Text>
|
|
||||||
</View>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(MySpaceScreen);
|
|
||||||
|
|
@ -1,10 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import { ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
||||||
View,
|
|
||||||
ScrollView,
|
|
||||||
TouchableOpacity,
|
|
||||||
Text,
|
|
||||||
} from 'react-native';
|
|
||||||
// Redux
|
// Redux
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
// Icons
|
// Icons
|
||||||
|
|
@ -15,7 +10,7 @@ import styles from '../../Resources/Styles/OnlyVideosStyle';
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
documents: state.documents,
|
documents: state.documents,
|
||||||
mainColor: state.app.mainColor
|
mainColor: state.app.mainColor,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25,7 +20,9 @@ class OnlyVideosScreen extends React.Component {
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.setState({ documents: this.props.documents.filter(tmp => tmp.type === 'mp4') });
|
this.setState({
|
||||||
|
documents: this.props.documents.filter(tmp => tmp.type === 'mp4'),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
@ -35,8 +32,13 @@ class OnlyVideosScreen extends React.Component {
|
||||||
key={document.id.toString()}
|
key={document.id.toString()}
|
||||||
style={{ ...styles.file, backgroundColor: this.props.mainColor }}
|
style={{ ...styles.file, backgroundColor: this.props.mainColor }}
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
this.props.dispatch({ type: 'SET_CURRENT_OPENED_DOC', data: document });
|
this.props.dispatch({
|
||||||
this.props.navigation.navigate('VideoScreen', { uuid: document.uuid });
|
type: 'SET_CURRENT_OPENED_DOC',
|
||||||
|
data: document,
|
||||||
|
});
|
||||||
|
this.props.navigation.navigate('VideoScreen', {
|
||||||
|
uuid: document.uuid,
|
||||||
|
});
|
||||||
}}>
|
}}>
|
||||||
{document.type === 'pdf' ? (
|
{document.type === 'pdf' ? (
|
||||||
<FontAwesome5 name="file-pdf" color={'white'} size={60} />
|
<FontAwesome5 name="file-pdf" color={'white'} size={60} />
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,16 @@ class PDFScreen extends React.Component {
|
||||||
<Pdf
|
<Pdf
|
||||||
source={source}
|
source={source}
|
||||||
onLoadComplete={(numberOfPages, filePath) => {
|
onLoadComplete={(numberOfPages, filePath) => {
|
||||||
//console.log(`number of pages: ${numberOfPages}`);
|
console.debug(`number of pages: ${numberOfPages}`);
|
||||||
}}
|
}}
|
||||||
onPageChanged={(page, numberOfPages) => {
|
onPageChanged={(page, numberOfPages) => {
|
||||||
//console.log(`current page: ${page}`);
|
console.debug(`current page: ${page}`);
|
||||||
}}
|
}}
|
||||||
onError={error => {
|
onError={error => {
|
||||||
console.log(error);
|
console.error(error);
|
||||||
}}
|
}}
|
||||||
onPressLink={uri => {
|
onPressLink={uri => {
|
||||||
//console.log(`Link presse: ${uri}`);
|
console.debug(`Link presse: ${uri}`);
|
||||||
}}
|
}}
|
||||||
style={styles.pdf}
|
style={styles.pdf}
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,11 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import { ScrollView, Text, TouchableOpacity, View } from 'react-native';
|
||||||
View,
|
|
||||||
ScrollView,
|
|
||||||
TouchableOpacity,
|
|
||||||
Text,
|
|
||||||
} from 'react-native';
|
|
||||||
// Reduxs
|
// Reduxs
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
// Helpers
|
// Helpers
|
||||||
import Helpers from "../Lib/Helpers";
|
import Helpers from '../Lib/Helpers';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from "../../I18n";
|
import i18n from '../../I18n';
|
||||||
// Icons
|
// Icons
|
||||||
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
import FontAwesome5 from 'react-native-vector-icons/FontAwesome5';
|
||||||
// Style
|
// Style
|
||||||
|
|
@ -19,7 +14,7 @@ import styles from '../../Resources/Styles/SearchStyle';
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
documents: state.documents,
|
documents: state.documents,
|
||||||
mainColor: state.app.mainColor
|
mainColor: state.app.mainColor,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -35,16 +30,20 @@ class SearchScreen extends React.Component {
|
||||||
} else if (document.type === 'mp4') {
|
} else if (document.type === 'mp4') {
|
||||||
this.props.navigation.navigate('VideoScreen', { uuid: document.uuid });
|
this.props.navigation.navigate('VideoScreen', { uuid: document.uuid });
|
||||||
} else {
|
} else {
|
||||||
console.log('Inconnu');
|
console.error('Type de document inconnu');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { needle, onlyVideos } = this.props.route.params;
|
const { needle, onlyVideos } = this.props.route.params;
|
||||||
let objDocs = this.props.documents;
|
let objDocs = this.props.documents;
|
||||||
let arrayDocs = Object.keys(objDocs).map(function (key) { return objDocs[key]; });
|
let arrayDocs = Object.keys(objDocs).map(function (key) {
|
||||||
|
return objDocs[key];
|
||||||
|
});
|
||||||
let sorted = arrayDocs.sort(Helpers.compareValues('title', 'asc'));
|
let sorted = arrayDocs.sort(Helpers.compareValues('title', 'asc'));
|
||||||
let filtered = sorted.filter(item => item.title.toLowerCase().indexOf(needle.toLowerCase()) >= 0);
|
let filtered = sorted.filter(
|
||||||
|
item => item.title.toLowerCase().indexOf(needle.toLowerCase()) >= 0,
|
||||||
|
);
|
||||||
if (onlyVideos === true) {
|
if (onlyVideos === true) {
|
||||||
filtered = filtered.filter(item => item.type === 'mp4');
|
filtered = filtered.filter(item => item.type === 'mp4');
|
||||||
}
|
}
|
||||||
|
|
@ -75,7 +74,9 @@ class SearchScreen extends React.Component {
|
||||||
<ScrollView style={styles.scrollview}>
|
<ScrollView style={styles.scrollview}>
|
||||||
<View style={styles.filesContainer}>{documentList}</View>
|
<View style={styles.filesContainer}>{documentList}</View>
|
||||||
{this.state.documents.length === 0 && (
|
{this.state.documents.length === 0 && (
|
||||||
<Text style={{ textAlign: 'center', marginTop: 50, fontSize: 30 }}>{i18n.t('search_s.no_result')}</Text>
|
<Text style={{ textAlign: 'center', marginTop: 50, fontSize: 30 }}>
|
||||||
|
{i18n.t('search_s.no_result')}
|
||||||
|
</Text>
|
||||||
)}
|
)}
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
||||||
|
|
@ -1,32 +1,39 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { View, Button, Alert, Text } from 'react-native';
|
import { Alert, Button, Linking, Text, View } from 'react-native';
|
||||||
// Redux
|
// Redux
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { initDirectories } from '../Store/Actions/directories';
|
|
||||||
import { initContact } from '../Store/Actions/contacts';
|
import { initContact } from '../Store/Actions/contacts';
|
||||||
|
import { initDirectories } from '../Store/Actions/directories';
|
||||||
import { initDocuments } from '../Store/Actions/documents';
|
import { initDocuments } from '../Store/Actions/documents';
|
||||||
// Sentry
|
// Sentry
|
||||||
import * as Sentry from "@sentry/react-native";
|
import * as Sentry from '@sentry/react-native';
|
||||||
|
|
||||||
// Style
|
// Style
|
||||||
import styles from '../../Resources/Styles/SyncStyle';
|
import styles from '../../Resources/Styles/SyncStyle';
|
||||||
// Translations
|
// Translations
|
||||||
import i18n from "../../I18n";
|
import i18n from '../../I18n';
|
||||||
// Controller
|
// Controller
|
||||||
import SyncController from '../Controllers/SyncController';
|
import SyncController from '../Controllers/SyncController';
|
||||||
// Progress
|
// Progress
|
||||||
import * as Progress from 'react-native-progress';
|
import * as Progress from 'react-native-progress';
|
||||||
// Database
|
// Database
|
||||||
import { User, Contact, Directory, Document, SendBrochure } from '../../Database';
|
import {
|
||||||
|
Contact,
|
||||||
|
Directory,
|
||||||
|
Document,
|
||||||
|
Form,
|
||||||
|
SendBrochure,
|
||||||
|
User,
|
||||||
|
} from '../../Database';
|
||||||
// FileSytem
|
// FileSytem
|
||||||
import * as FileSystem from 'expo-file-system';
|
import * as FileSystem from 'expo-file-system';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
syncVersion: state.app.syncVersion,
|
|
||||||
currentUser: state.app.currentUser,
|
currentUser: state.app.currentUser,
|
||||||
locale: state.locale.locale,
|
locale: state.locale.locale,
|
||||||
mainColor: state.app.mainColor,
|
mainColor: state.app.mainColor,
|
||||||
directories: state.directories
|
directories: state.directories,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,18 +41,12 @@ const mapDispatchToProps = dispatch => {
|
||||||
return {
|
return {
|
||||||
init: () => dispatch({ type: 'INIT' }),
|
init: () => dispatch({ type: 'INIT' }),
|
||||||
initUsers: () => dispatch({ type: 'INIT_USERS' }),
|
initUsers: () => dispatch({ type: 'INIT_USERS' }),
|
||||||
|
initFormularies: () => dispatch({ type: 'INIT_FORMS' }),
|
||||||
initDirectories: (lang, user) => dispatch(initDirectories(lang, user)),
|
initDirectories: (lang, user) => dispatch(initDirectories(lang, user)),
|
||||||
initDocuments: (lang, directories) => dispatch(initDocuments(lang, directories)),
|
initDocuments: (lang, directories) =>
|
||||||
|
dispatch(initDocuments(lang, directories)),
|
||||||
initContact: currentUser => dispatch(initContact(currentUser)),
|
initContact: currentUser => dispatch(initContact(currentUser)),
|
||||||
initBtns: () => dispatch({ type: 'INIT_HOME_BTNS' }),
|
initBtns: () => dispatch({ type: 'INIT_HOME_BTNS' })
|
||||||
updateVersion: version => dispatch({
|
|
||||||
type: 'UPDATE_VERSION',
|
|
||||||
data: version,
|
|
||||||
}),
|
|
||||||
updateShowIsActive: value => dispatch({
|
|
||||||
type: 'UPDATE_SHOW_IS_ACTIVE',
|
|
||||||
data: value,
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -56,8 +57,7 @@ class SyncScreen extends React.Component {
|
||||||
downloadProgress: 0,
|
downloadProgress: 0,
|
||||||
downloadingFile: false,
|
downloadingFile: false,
|
||||||
processing: false,
|
processing: false,
|
||||||
newApp: false,
|
forced: false,
|
||||||
forced: false
|
|
||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|
@ -97,125 +97,186 @@ class SyncScreen extends React.Component {
|
||||||
|
|
||||||
async sync() {
|
async sync() {
|
||||||
let errorStatus = false;
|
let errorStatus = false;
|
||||||
const isConnected = await SyncController.checkConnection().then(state => {
|
|
||||||
//console.log(state.isConnected)
|
console.debug('Sync');
|
||||||
return state.isConnected
|
|
||||||
}).catch(error => {
|
/**
|
||||||
//console.log(error);
|
* @param {Promise<import('@react-native-community/netinfo').NetInfoState>} promise
|
||||||
return false;
|
* @param {(error:any) => void|null} onError
|
||||||
});
|
*/
|
||||||
|
const getCall = (promise, onError = null) => {
|
||||||
|
if (onError === null) {
|
||||||
|
/** @param {import('axios').AxiosError} error */
|
||||||
|
onError = error => {
|
||||||
|
let message = 'Erreur de la communication serveur';
|
||||||
|
if (error?.response?.status === 422) {
|
||||||
|
message =
|
||||||
|
this.parseValidationErrors(error.response?.data?.errors ?? {}) ||
|
||||||
|
message;
|
||||||
|
console.warn(error.response?.data?.errors ?? {});
|
||||||
|
} else if (error?.response?.status === 419) {
|
||||||
|
// * CSRF TOKEN MISMATCH (On ne pourrais plus faire d'appels AJAX sans recharger la page)
|
||||||
|
message = 'Votre session a expiré, la page va être rechargée';
|
||||||
|
} else if (error?.response?.status === 403) {
|
||||||
|
// * Access denied
|
||||||
|
message = "Vous n'êtes pas autorisé a effectuer cette action";
|
||||||
|
} else {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
console.warn(message);
|
||||||
|
|
||||||
|
Sentry.captureException(error);
|
||||||
|
Alert.alert(
|
||||||
|
i18n.t('error.error'),
|
||||||
|
i18n.t('error.error_has_occurred'),
|
||||||
|
);
|
||||||
|
errorStatus = true;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return promise.catch(onError);
|
||||||
|
};
|
||||||
|
|
||||||
|
const isConnected = await SyncController.checkConnection().catch(
|
||||||
|
error => false,
|
||||||
|
);
|
||||||
if (!isConnected) {
|
if (!isConnected) {
|
||||||
Alert.alert(
|
Alert.alert(
|
||||||
i18n.t('global.warning'),
|
i18n.t('global.warning'),
|
||||||
i18n.t('error.must_be_connected_internet_sync')
|
i18n.t('error.must_be_connected_internet_sync'),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.setState({ processing: true });
|
this.setState({ processing: true });
|
||||||
// getVersion
|
// * --- getUsers
|
||||||
const resVersion = await SyncController.getVersion().then(res => {
|
this.setState({
|
||||||
return res.data;
|
progress: 0.1,
|
||||||
}).catch(error => {
|
txtStep: i18n.t('sync_s.updating_users') + '...',
|
||||||
Sentry.captureException(error);
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('error.error'),
|
|
||||||
i18n.t('error.error_has_occurred')
|
|
||||||
);
|
|
||||||
errorStatus = true
|
|
||||||
});
|
});
|
||||||
if (errorStatus) {
|
const resUsers = await getCall(
|
||||||
return false;
|
SyncController.getUsers().then(res => {
|
||||||
}
|
|
||||||
this.props.updateVersion(resVersion.version);
|
|
||||||
this.props.updateShowIsActive(resVersion.ShowIsActive);
|
|
||||||
this.setState({ newApp: resVersion.newApp });
|
|
||||||
// getUsers
|
|
||||||
this.setState({ txtStep: i18n.t('sync_s.updating_users') + '...' });
|
|
||||||
const resUsers = await SyncController.getUsers().then(res => {
|
|
||||||
User.clear();
|
User.clear();
|
||||||
return res.data;
|
return res.data;
|
||||||
}).catch(error => {
|
}),
|
||||||
Sentry.captureException(error);
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('error.error'),
|
|
||||||
i18n.t('error.error_has_occurred')
|
|
||||||
);
|
);
|
||||||
errorStatus = true
|
|
||||||
});
|
|
||||||
if (errorStatus) {
|
if (errorStatus) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
resUsers.forEach(user => {
|
resUsers.forEach(user => {
|
||||||
User.add(user);
|
User.add(user);
|
||||||
});
|
});
|
||||||
// getContacts
|
|
||||||
this.setState({ progress: 0.1, txtStep: i18n.t('sync_s.updating_contacts') + '...' });
|
// * --- Contacts Sync
|
||||||
const resContacts = await SyncController.getContacts(this.props.currentUser.id).then(res => {
|
/*
|
||||||
Contact.clear();
|
* This is done only for actual app user
|
||||||
|
- 1 Upsert all contacts
|
||||||
|
- 2 Delete contacts where to_delete is true
|
||||||
|
- 3 Get all contacts
|
||||||
|
*/
|
||||||
|
this.setState({
|
||||||
|
progress: 0.2,
|
||||||
|
txtStep: i18n.t('sync_s.updating_contacts') + '...',
|
||||||
|
});
|
||||||
|
|
||||||
|
// * --- Contacts Sync -- STEP 1
|
||||||
|
await getCall(SyncController.upsertContacts(this.props.currentUser.id));
|
||||||
|
if (errorStatus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * --- Contacts Sync -- STEP 2
|
||||||
|
this.setState({
|
||||||
|
progress: 0.23,
|
||||||
|
});
|
||||||
|
await getCall(SyncController.deleteContacts(this.props.currentUser.id));
|
||||||
|
if (errorStatus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * --- Contacts Sync -- STEP 3
|
||||||
|
this.setState({
|
||||||
|
progress: 0.26,
|
||||||
|
});
|
||||||
|
const resContacts = await getCall(
|
||||||
|
SyncController.getContacts(this.props.currentUser.id).then(res => {
|
||||||
|
// * Clear Contacts, in order to fetch them all after.
|
||||||
|
Contact.clear(this.props.currentUser.id);
|
||||||
return res.data;
|
return res.data;
|
||||||
}).catch(error => {
|
}),
|
||||||
Sentry.captureException(error);
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('error.error'),
|
|
||||||
i18n.t('error.error_has_occurred')
|
|
||||||
);
|
);
|
||||||
errorStatus = true
|
|
||||||
});
|
|
||||||
if (errorStatus) {
|
if (errorStatus) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
resContacts.forEach(contact => {
|
/** @type {(contact: import('./../Models/Contact').ContactData ) => void} */
|
||||||
Contact.add(contact);
|
const contactMapper = contact => {
|
||||||
|
// * Stringify complex Fields
|
||||||
|
contact.data = JSON.stringify(contact.data);
|
||||||
|
contact.visits = JSON.stringify(contact.visits);
|
||||||
|
contact.timestamp = new Date(contact.timestamp);
|
||||||
|
Contact.set(contact);
|
||||||
|
};
|
||||||
|
resContacts.forEach(contactMapper);
|
||||||
|
|
||||||
|
// * --- sendBrochures
|
||||||
|
this.setState({
|
||||||
|
progress: 0.3,
|
||||||
|
txtStep: i18n.t('sync_s.sending_flyers') + '...',
|
||||||
});
|
});
|
||||||
//sendBrochures
|
const brochures = SendBrochure.getAll();
|
||||||
this.setState({ progress: 0.2, txtStep: i18n.t('sync_s.sending_flyers') + '...' });
|
|
||||||
let brochures = SendBrochure.getAll();
|
|
||||||
for (const brochure of brochures) {
|
for (const brochure of brochures) {
|
||||||
await SyncController.sendBrochure(brochure).then(res => {
|
await getCall(
|
||||||
|
SyncController.sendBrochure(brochure).then(res => {
|
||||||
SendBrochure.delete(brochure.id);
|
SendBrochure.delete(brochure.id);
|
||||||
}).catch(error => {
|
}),
|
||||||
Sentry.captureException(error);
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('error.error'),
|
|
||||||
i18n.t('error.error_has_occurred') + ' : Brochures'
|
|
||||||
);
|
);
|
||||||
errorStatus = true;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
if (errorStatus) {
|
if (errorStatus) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//getDirectories
|
|
||||||
this.setState({ progress: 0.3, txtStep: i18n.t('sync_s.updating_folders') + '...' });
|
// * --- getDirectories
|
||||||
const resDirectories = await SyncController.getDirectories().then(res => {
|
this.setState({
|
||||||
|
progress: 0.4,
|
||||||
|
txtStep: i18n.t('sync_s.updating_folders') + '...',
|
||||||
|
});
|
||||||
|
const resDirectories = await getCall(
|
||||||
|
SyncController.getDirectories().then(res => {
|
||||||
Directory.clear();
|
Directory.clear();
|
||||||
return res.data;
|
return res.data;
|
||||||
}).catch(error => {
|
}),
|
||||||
Sentry.captureException(error);
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('error.error'),
|
|
||||||
i18n.t('error.error_has_occurred')
|
|
||||||
);
|
);
|
||||||
errorStatus = true
|
|
||||||
});
|
|
||||||
if (errorStatus) {
|
if (errorStatus) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
resDirectories.forEach(dir => {
|
resDirectories.forEach(dir => {
|
||||||
Directory.add(dir);
|
Directory.add(dir);
|
||||||
});
|
});
|
||||||
// getDocuments
|
|
||||||
this.setState({ progress: 0.4, txtStep: i18n.t('sync_s.updating_docs') + '...' });
|
// * --- getFormularies
|
||||||
const resDocuments = await SyncController.getDocuments().then(res => {
|
this.setState({
|
||||||
return res.data;
|
progress: 0.5,
|
||||||
}).catch(error => {
|
txtStep: i18n.t('sync_s.updating_forms') + '...',
|
||||||
Sentry.captureException(error);
|
|
||||||
Alert.alert(
|
|
||||||
i18n.t('error.error'),
|
|
||||||
i18n.t('error.error_has_occurred')
|
|
||||||
);
|
|
||||||
errorStatus = true
|
|
||||||
});
|
});
|
||||||
|
const resFormularies = await getCall(
|
||||||
|
SyncController.getFormularies().then(res => {
|
||||||
|
Form.clear();
|
||||||
|
return res.data;
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
if (errorStatus) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
resFormularies.forEach(form => Form.add(form));
|
||||||
|
|
||||||
|
// * --- getDocuments
|
||||||
|
this.setState({
|
||||||
|
progress: 0.6,
|
||||||
|
txtStep: i18n.t('sync_s.updating_docs') + '...',
|
||||||
|
});
|
||||||
|
const resDocuments = await getCall(
|
||||||
|
SyncController.getDocuments().then(res => {
|
||||||
|
return res.data;
|
||||||
|
}),
|
||||||
|
);
|
||||||
if (errorStatus) {
|
if (errorStatus) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -224,8 +285,8 @@ class SyncScreen extends React.Component {
|
||||||
Document.update(document);
|
Document.update(document);
|
||||||
});
|
});
|
||||||
this.downloadDocuments(Document.getAll(), toDelete);
|
this.downloadDocuments(Document.getAll(), toDelete);
|
||||||
// End
|
|
||||||
this.setState({ txtStep: i18n.t('sync_s.update_completed') + '.', processing: false });
|
// * --- End
|
||||||
}
|
}
|
||||||
|
|
||||||
fileProgress() {
|
fileProgress() {
|
||||||
|
|
@ -235,34 +296,38 @@ class SyncScreen extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadDocuments(docs, toDelete) {
|
downloadDocuments(docs, toDelete) {
|
||||||
const version = this.props.syncVersion;
|
|
||||||
this.getToDL(docs, 0).then(toDownload => {
|
this.getToDL(docs, 0).then(toDownload => {
|
||||||
if (toDownload.length > 0) {
|
if (toDownload.length > 0) {
|
||||||
this.setState({ progress: 0.5 });
|
this.setState({ progress: 0.6 });
|
||||||
const docProgress = 0.5 / toDownload.length;
|
const docProgress = 0.4 / toDownload.length;
|
||||||
this.download(toDownload, docProgress, 0).then(status => {
|
this.download(toDownload, docProgress, 0).then(status => {
|
||||||
if (status === true) {
|
if (status === true) {
|
||||||
this.deleteFile(toDelete, 0).then(status => {
|
this.deleteFile(toDelete, 0).then(delStatus => {
|
||||||
this.finishSync(version);
|
this.finishSync();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setState({ txtStep: i18n.t('error.error_has_occurred') + '.' });
|
this.setState({
|
||||||
|
txtStep: i18n.t('error.error_has_occurred') + '.',
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.deleteFile(toDelete, 0).then(status => {
|
this.deleteFile(toDelete, 0).then(status => {
|
||||||
this.setState({ progress: 1 });
|
this.setState({ progress: 1 });
|
||||||
this.finishSync(version);
|
this.finishSync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async getToDL(docs, i, toDL = []) {
|
async getToDL(docs, i, toDL = []) {
|
||||||
if (docs.length < 1)
|
if (docs.length < 1) {
|
||||||
return toDL;
|
return toDL;
|
||||||
|
}
|
||||||
const item = docs[i];
|
const item = docs[i];
|
||||||
const { exists, modificationTime } = await FileSystem.getInfoAsync(FileSystem.documentDirectory + item.uuid + '.' + item.type);
|
const { exists, modificationTime } = await FileSystem.getInfoAsync(
|
||||||
|
FileSystem.documentDirectory + item.uuid + '.' + item.type,
|
||||||
|
);
|
||||||
if (exists === false) {
|
if (exists === false) {
|
||||||
toDL.push(item);
|
toDL.push(item);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -279,7 +344,10 @@ class SyncScreen extends React.Component {
|
||||||
async deleteFile(docs, i) {
|
async deleteFile(docs, i) {
|
||||||
if (docs.length > 0) {
|
if (docs.length > 0) {
|
||||||
const file = docs[i];
|
const file = docs[i];
|
||||||
await FileSystem.deleteAsync(FileSystem.documentDirectory + file.uuid + '.' + file.type, { idempotent: true });
|
await FileSystem.deleteAsync(
|
||||||
|
FileSystem.documentDirectory + file.uuid + '.' + file.type,
|
||||||
|
{ idempotent: true },
|
||||||
|
);
|
||||||
if (i < docs.length - 1) {
|
if (i < docs.length - 1) {
|
||||||
return this.deleteFile(docs, i + 1);
|
return this.deleteFile(docs, i + 1);
|
||||||
}
|
}
|
||||||
|
|
@ -312,25 +380,32 @@ class SyncScreen extends React.Component {
|
||||||
if (this.state.downloadingFile === false) {
|
if (this.state.downloadingFile === false) {
|
||||||
this.setState({ downloadingFile: true });
|
this.setState({ downloadingFile: true });
|
||||||
}
|
}
|
||||||
const endpoint = SyncController.getUrlBo() + '/storage/docs/'
|
const tenantUrl = SyncController.getUrlBo();
|
||||||
|
const rootUrl = tenantUrl.substring(0, tenantUrl.lastIndexOf('/'));
|
||||||
|
const tenantId = tenantUrl.match(/[^\/]+$/)[0];
|
||||||
|
const endpoint = rootUrl + '/storage/docs/' + tenantId + "/";
|
||||||
const doc = documents[i];
|
const doc = documents[i];
|
||||||
this.setState({
|
this.setState({
|
||||||
txtStep:
|
txtStep:
|
||||||
i18n.t('sync_s.download') + ' : ' +
|
i18n.t('sync_s.download') +
|
||||||
|
' : ' +
|
||||||
doc.title +
|
doc.title +
|
||||||
' (' +
|
' (' +
|
||||||
doc.type.toUpperCase() +
|
doc.type.toUpperCase() +
|
||||||
') ...',
|
') ...',
|
||||||
});
|
});
|
||||||
try {
|
try {
|
||||||
|
const uri = `${endpoint}${doc.uuid}.${doc.type}`;
|
||||||
await this.downloadResumable(
|
await this.downloadResumable(
|
||||||
endpoint + doc.uuid + "." + doc.type,
|
endpoint + doc.uuid + '.' + doc.type,
|
||||||
doc.uuid,
|
doc.uuid,
|
||||||
doc.type,
|
doc.type,
|
||||||
).downloadAsync();
|
).downloadAsync();
|
||||||
const { modificationTime } = await FileSystem.getInfoAsync(FileSystem.documentDirectory + doc.uuid + '.' + doc.type);
|
const { modificationTime } = await FileSystem.getInfoAsync(
|
||||||
|
FileSystem.documentDirectory + doc.uuid + '.' + doc.type,
|
||||||
|
);
|
||||||
SyncController.updateLastModificationDoc(doc.id, modificationTime);
|
SyncController.updateLastModificationDoc(doc.id, modificationTime);
|
||||||
//console.log('Finished downloading to ', uri);
|
console.debug('Finished downloading to ', uri);
|
||||||
this.setState({ progress: this.state.progress + progress });
|
this.setState({ progress: this.state.progress + progress });
|
||||||
if (i < documents.length - 1) {
|
if (i < documents.length - 1) {
|
||||||
return this.download(documents, progress, i + 1);
|
return this.download(documents, progress, i + 1);
|
||||||
|
|
@ -343,7 +418,7 @@ class SyncScreen extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finishSync(version) {
|
finishSync() {
|
||||||
this.props.init();
|
this.props.init();
|
||||||
this.props.initUsers();
|
this.props.initUsers();
|
||||||
this.props.initContact(this.props.currentUser);
|
this.props.initContact(this.props.currentUser);
|
||||||
|
|
@ -353,27 +428,32 @@ class SyncScreen extends React.Component {
|
||||||
if (this.state.forced) {
|
if (this.state.forced) {
|
||||||
SyncController.setInstalled();
|
SyncController.setInstalled();
|
||||||
}
|
}
|
||||||
SyncController.updateVersion(version);
|
this.setState({
|
||||||
this.setState({ txtStep: i18n.t('sync_s.update_completed') + '.', processing: false });
|
txtStep: i18n.t('sync_s.update_completed') + '.',
|
||||||
if (this.state.newApp === true) {
|
processing: false,
|
||||||
const appUUID = SyncController.getAppStoreUUID();
|
});
|
||||||
const url = 'https://store.ldc.fr' + '/app/' + appUUID;
|
|
||||||
Alert.alert(
|
|
||||||
'LDC Store',
|
|
||||||
i18n.t('sync_s.new_app_version'),
|
|
||||||
[
|
|
||||||
{
|
|
||||||
text: i18n.t('global.cancel'),
|
|
||||||
onPress: () => console.log('Cancel Pressed'),
|
|
||||||
style: 'cancel',
|
|
||||||
},
|
|
||||||
{ text: i18n.t('sync_s.open_store'), onPress: () => Linking.openURL(url).catch((err) => console.error('An error occurred', err)) },
|
|
||||||
],
|
|
||||||
{ cancelable: false },
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse error messages for a specific input.
|
||||||
|
*
|
||||||
|
* @param {Record<string, Array<string>>} allErrors
|
||||||
|
* @return {string | null}
|
||||||
|
*/
|
||||||
|
parseValidationErrors(allErrors = {}) {
|
||||||
|
const errorList = Object.values(allErrors);
|
||||||
|
if (!errorList.length) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return errorList
|
||||||
|
.reduce((oldInputErrors, inputErrors) =>
|
||||||
|
oldInputErrors ? oldInputErrors.concat(inputErrors) : inputErrors,
|
||||||
|
)
|
||||||
|
.reduce(
|
||||||
|
(oldInputString, inputString) =>
|
||||||
|
(oldInputString ? `${oldInputString}, ` : '') + inputString,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(SyncScreen);
|
export default connect(mapStateToProps, mapDispatchToProps)(SyncScreen);
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { View, Dimensions } from 'react-native';
|
import { Dimensions, View } from 'react-native';
|
||||||
// Reduxs
|
// Reduxs
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
// FileSytem
|
// FileSytem
|
||||||
|
|
@ -7,33 +7,44 @@ import * as FileSystem from 'expo-file-system';
|
||||||
// Video
|
// Video
|
||||||
import { ResizeMode } from 'expo-av';
|
import { ResizeMode } from 'expo-av';
|
||||||
import VideoPlayer from 'expo-video-player';
|
import VideoPlayer from 'expo-video-player';
|
||||||
|
// Sentry
|
||||||
|
import * as Sentry from '@sentry/react-native';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
mainColor: state.app.mainColor
|
mainColor: state.app.mainColor,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
class VideoScreen extends React.Component {
|
class VideoScreen extends React.Component {
|
||||||
render() {
|
render() {
|
||||||
const { uuid } = this.props.route.params;
|
const { uuid } = this.props.route.params;
|
||||||
let width = Dimensions.get("window").width;
|
let width = Dimensions.get('window').width;
|
||||||
let height = Dimensions.get("window").height;
|
let height = Dimensions.get('window').height;
|
||||||
|
|
||||||
// if portrait
|
// * If on portrait
|
||||||
if (height > width) {
|
if (height > width) {
|
||||||
let tmpHeight = height;
|
const tmpHeight = height;
|
||||||
height = width - 150;
|
height = width - 150;
|
||||||
width = tmpHeight + 100;
|
width = tmpHeight + 100;
|
||||||
} else {
|
} else {
|
||||||
height = height - 100;
|
height = height - 100;
|
||||||
}
|
}
|
||||||
|
const videoUri = `${FileSystem.documentDirectory}${uuid}.mp4`;
|
||||||
|
console.debug({
|
||||||
|
shouldPlay: true,
|
||||||
|
resizeMode: ResizeMode.CONTAIN,
|
||||||
|
source: {
|
||||||
|
uri: videoUri,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
try {
|
||||||
return (
|
return (
|
||||||
<View style={{ flex: 1, backgroundColor: 'black' }}>
|
<View style={{ flex: 1, backgroundColor: 'black' }}>
|
||||||
<VideoPlayer
|
<VideoPlayer
|
||||||
defaultControlsVisible={true}
|
defaultControlsVisible={true}
|
||||||
fullscreen={{
|
fullscreen={{
|
||||||
visible: false
|
visible: false,
|
||||||
}}
|
}}
|
||||||
slider={{
|
slider={{
|
||||||
minimumTrackTintColor: this.props.mainColor,
|
minimumTrackTintColor: this.props.mainColor,
|
||||||
|
|
@ -41,18 +52,25 @@ class VideoScreen extends React.Component {
|
||||||
}}
|
}}
|
||||||
style={{
|
style={{
|
||||||
height: height,
|
height: height,
|
||||||
width: width
|
width: width,
|
||||||
}}
|
}}
|
||||||
videoProps={{
|
videoProps={{
|
||||||
shouldPlay: true,
|
shouldPlay: true,
|
||||||
resizeMode: ResizeMode.CONTAIN,
|
resizeMode: ResizeMode.CONTAIN,
|
||||||
source: {
|
source: {
|
||||||
uri: FileSystem.documentDirectory + uuid + '.mp4',
|
uri: videoUri,
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
errorCallback={e => {
|
||||||
|
console.error(e);
|
||||||
|
Sentry.captureException(e);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
} catch (e) {
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
import Realm from "realm";
|
import Realm from 'realm';
|
||||||
|
|
||||||
import ContactModel, { ContactsSchema } from "./App/Models/Contact";
|
import ContactModel, { ContactsSchema } from './App/Models/Contact';
|
||||||
import DirectoryModel, { DirectoriesSchema } from "./App/Models/Directory";
|
import DirectoryModel, { DirectoriesSchema } from './App/Models/Directory';
|
||||||
import DocumentModel, { DocumentsSchema } from "./App/Models/Document";
|
import DocumentModel, { DocumentsSchema } from './App/Models/Document';
|
||||||
import SendBrochureModel, { SendBrochuresSchema } from "./App/Models/SendBrochure";
|
import FormModel, { FormsSchema } from './App/Models/Form';
|
||||||
import SettingModel, { SettingsSchema } from "./App/Models/Setting";
|
import SendBrochureModel, {
|
||||||
import UserModel, { UsersSchema } from "./App/Models/User";
|
SendBrochuresSchema,
|
||||||
|
} from './App/Models/SendBrochure';
|
||||||
|
import SettingModel, { SettingsSchema } from './App/Models/Setting';
|
||||||
|
import UserModel, { UsersSchema } from './App/Models/User';
|
||||||
|
|
||||||
const Database = {
|
const Database = {
|
||||||
schema: [
|
schema: [
|
||||||
|
|
@ -14,16 +17,18 @@ const Database = {
|
||||||
DocumentsSchema,
|
DocumentsSchema,
|
||||||
SendBrochuresSchema,
|
SendBrochuresSchema,
|
||||||
SettingsSchema,
|
SettingsSchema,
|
||||||
UsersSchema
|
UsersSchema,
|
||||||
|
FormsSchema,
|
||||||
],
|
],
|
||||||
//encryptionKey: new Int8Array(64)
|
//encryptionKey: new Int8Array(64)
|
||||||
};
|
};
|
||||||
|
|
||||||
let realm = new Realm(Database);
|
let realm = new Realm(Database);
|
||||||
|
|
||||||
export let Contact = new ContactModel(realm);
|
export const Contact = new ContactModel(realm);
|
||||||
export let Directory = new DirectoryModel(realm);
|
export const Directory = new DirectoryModel(realm);
|
||||||
export let Document = new DocumentModel(realm);
|
export const Document = new DocumentModel(realm);
|
||||||
export let SendBrochure = new SendBrochureModel(realm);
|
export const SendBrochure = new SendBrochureModel(realm);
|
||||||
export let Setting = new SettingModel(realm);
|
export const Setting = new SettingModel(realm);
|
||||||
export let User = new UserModel(realm);
|
export const User = new UserModel(realm);
|
||||||
|
export const Form = new FormModel(realm);
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
import { I18n } from 'i18n-js';
|
import { I18n } from 'i18n-js';
|
||||||
|
|
||||||
import fr from './Resources/Locales/fr';
|
|
||||||
import en from './Resources/Locales/en';
|
|
||||||
import de from './Resources/Locales/de';
|
import de from './Resources/Locales/de';
|
||||||
|
import en from './Resources/Locales/en';
|
||||||
|
import fr from './Resources/Locales/fr';
|
||||||
|
|
||||||
const i18n = new I18n({
|
const i18n = new I18n({
|
||||||
fr: fr,
|
fr: fr,
|
||||||
en: en,
|
en: en,
|
||||||
de: de
|
de: de,
|
||||||
});
|
});
|
||||||
|
|
||||||
i18n.defaultLocale = 'fr';
|
i18n.defaultLocale = 'fr';
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { createNavigationContainerRef } from '@react-navigation/native';
|
import { createNavigationContainerRef } from '@react-navigation/native';
|
||||||
|
|
||||||
export const navigationRef = createNavigationContainerRef()
|
export const navigationRef = createNavigationContainerRef();
|
||||||
|
|
||||||
export function navigate(name, params) {
|
export function navigate(name, params) {
|
||||||
if (navigationRef.isReady()) {
|
if (navigationRef.isReady()) {
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { StyleSheet } from 'react-native';
|
||||||
const commonStyles = StyleSheet.create({
|
const commonStyles = StyleSheet.create({
|
||||||
background: {
|
background: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
justifyContent: "center"
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
textInput: {
|
textInput: {
|
||||||
height: 40,
|
height: 40,
|
||||||
|
|
@ -12,8 +12,8 @@ const commonStyles = StyleSheet.create({
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
marginBottom: 20,
|
marginBottom: 20,
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
paddingLeft: 10
|
paddingLeft: 10,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default commonStyles;
|
export default commonStyles;
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
"videos": "Videos",
|
"videos": "Videos",
|
||||||
"contacts": "Kontakt",
|
"contacts": "Kontakt",
|
||||||
"confirmation": "Bestätigung",
|
"confirmation": "Bestätigung",
|
||||||
"name": "Name",
|
"lastname": "Name",
|
||||||
"firstname": "Vorname",
|
"firstname": "Vorname",
|
||||||
"address": "Adresse",
|
"address": "Adresse",
|
||||||
"phone": "Telefonnummer",
|
"phone": "Telefonnummer",
|
||||||
|
|
@ -48,8 +48,7 @@
|
||||||
"folders": "Ordner",
|
"folders": "Ordner",
|
||||||
"video": "Video",
|
"video": "Video",
|
||||||
"contact_details": "Kontaktdaten",
|
"contact_details": "Kontaktdaten",
|
||||||
"results_search": "Suchergebnisse",
|
"results_search": "Suchergebnisse"
|
||||||
"my_space": "Mein Raum"
|
|
||||||
},
|
},
|
||||||
"login_s": {
|
"login_s": {
|
||||||
"username": "Benutzername",
|
"username": "Benutzername",
|
||||||
|
|
@ -62,6 +61,7 @@
|
||||||
"download": "Download",
|
"download": "Download",
|
||||||
"update_completed": "Update abgeschlossen",
|
"update_completed": "Update abgeschlossen",
|
||||||
"updating_docs": "Dokumentaktualisierung",
|
"updating_docs": "Dokumentaktualisierung",
|
||||||
|
"updating_forms": "Formulare aktualisieren",
|
||||||
"updating_folders": "Dateien aktualisieren",
|
"updating_folders": "Dateien aktualisieren",
|
||||||
"sending_flyers": "Brochure senden",
|
"sending_flyers": "Brochure senden",
|
||||||
"updating_contacts": "Kontakt aktualisieren",
|
"updating_contacts": "Kontakt aktualisieren",
|
||||||
|
|
@ -79,10 +79,13 @@
|
||||||
"contact_deleted": "Kontakt gelöscht",
|
"contact_deleted": "Kontakt gelöscht",
|
||||||
"contact_added": "Kontakt hinzugefügt",
|
"contact_added": "Kontakt hinzugefügt",
|
||||||
"send_flyer": "Senden Sie eine Broschüre",
|
"send_flyer": "Senden Sie eine Broschüre",
|
||||||
"select_contact": "Wählen Sie den Kontakt",
|
"select_contact": "Wählen Sie einen Benutzer aus",
|
||||||
"transfer": "weiterleiten",
|
"transfer": "weiterleiten",
|
||||||
"contact_list": "Kontaktliste",
|
"contact_list": "Kontaktliste",
|
||||||
"documents_list": "Liste der Dokumente"
|
"documents_list": "Liste der Dokumente",
|
||||||
|
"input_required": "Das Feld %{placeholder} ist erforderlich",
|
||||||
|
"input_too_long": "Das Feld %{placeholder} ist zu lang",
|
||||||
|
"input_email": "Das Feld %{placeholder} muss eine gültige E-Mail-Adresse sein"
|
||||||
},
|
},
|
||||||
"contact_details_s": {
|
"contact_details_s": {
|
||||||
"visits": "Besuche",
|
"visits": "Besuche",
|
||||||
|
|
@ -90,12 +93,11 @@
|
||||||
"contact_saved": "Kontakt gespeichert",
|
"contact_saved": "Kontakt gespeichert",
|
||||||
"confirm_visit_delete": "Sind Sie sicher, dass Sie diesen Besuch löschen möchten?",
|
"confirm_visit_delete": "Sind Sie sicher, dass Sie diesen Besuch löschen möchten?",
|
||||||
"qrcode_not_vcard_format": "Dieser QRCode ist nicht im vCard-Format",
|
"qrcode_not_vcard_format": "Dieser QRCode ist nicht im vCard-Format",
|
||||||
"customer": "Kunde",
|
|
||||||
"prospect": "potenzieller Kunde",
|
|
||||||
"other": "Andere",
|
|
||||||
"description": "Beschreibung",
|
"description": "Beschreibung",
|
||||||
"no_visits": "Kein Besuch",
|
"no_visits": "Kein Besuch",
|
||||||
"visit_name": "Besuchsname"
|
"visit_name": "Besuchsname",
|
||||||
|
"input_select_please_choose": "Wähle einen Wert",
|
||||||
|
"input_select_multiple_search": "Suchen"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"error": "Fehler ",
|
"error": "Fehler ",
|
||||||
|
|
@ -104,14 +106,14 @@
|
||||||
"incorrect_credentials": "Falsche Anmeldeinformationen",
|
"incorrect_credentials": "Falsche Anmeldeinformationen",
|
||||||
"must_fill_login_fields": "Sie müssen die Verbindungsfelder ausfüllen",
|
"must_fill_login_fields": "Sie müssen die Verbindungsfelder ausfüllen",
|
||||||
"invalid_email_address": "Ungültige E-Mail-Adresse",
|
"invalid_email_address": "Ungültige E-Mail-Adresse",
|
||||||
|
"invalid_firstname": "Vorname ist ungültig",
|
||||||
|
"invalid_lastname": "Nachname ist ungültig",
|
||||||
|
"invalid_phone": "Die Telefonnummer ist ungültig",
|
||||||
|
"field_required": "Das Feld %{placeholder} ist erforderlich",
|
||||||
"error_has_occurred": "Ein Fehler ist aufgetreten",
|
"error_has_occurred": "Ein Fehler ist aufgetreten",
|
||||||
"must_be_connected_internet_sync": "Sie müssen mit dem Internet verbunden sein, um die Synchronisierung zu starten",
|
"must_be_connected_internet_sync": "Sie müssen mit dem Internet verbunden sein, um die Synchronisierung zu starten",
|
||||||
"incomplete_form": "Unvollständiges Formular",
|
"incomplete_form": "Unvollständiges Formular",
|
||||||
"fill_all_fields_and_1_doc_min": "Bitte füllen Sie alle Felder, mindestens 1 Dokument und eine gültige E-Mail-Adresse aus.",
|
"fill_all_fields_and_1_doc_min": "Bitte füllen Sie alle Felder, mindestens 1 Dokument und eine gültige E-Mail-Adresse aus.",
|
||||||
"fill_other_field": "Füllen Sie das Beschreibungsfeld für: Andere",
|
|
||||||
"specify_type_contact": "Bitte geben Sie die Art des Kontakts an",
|
|
||||||
"invalid_name": "ungültiger Name",
|
|
||||||
"invalid_firstname": "ungültiger Vorname",
|
|
||||||
"camera_permission_denied": "Kameraerlaubnis verweigert",
|
"camera_permission_denied": "Kameraerlaubnis verweigert",
|
||||||
"pending_camera_permission": "Warten auf Kameraerlaubnis"
|
"pending_camera_permission": "Warten auf Kameraerlaubnis"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
"videos": "Videos",
|
"videos": "Videos",
|
||||||
"contacts": "Contacts",
|
"contacts": "Contacts",
|
||||||
"confirmation": "Confirmation",
|
"confirmation": "Confirmation",
|
||||||
"name": "Lastname",
|
"lastname": "Lastname",
|
||||||
"firstname": "Firstname",
|
"firstname": "Firstname",
|
||||||
"address": "Adress",
|
"address": "Adress",
|
||||||
"phone": "Phone number",
|
"phone": "Phone number",
|
||||||
|
|
@ -48,8 +48,7 @@
|
||||||
"folders": "Folders",
|
"folders": "Folders",
|
||||||
"video": "Video",
|
"video": "Video",
|
||||||
"contact_details": "Contact information",
|
"contact_details": "Contact information",
|
||||||
"results_search": "Search results",
|
"results_search": "Search results"
|
||||||
"my_space": "Personal Dashboard"
|
|
||||||
},
|
},
|
||||||
"login_s": {
|
"login_s": {
|
||||||
"username": "Username",
|
"username": "Username",
|
||||||
|
|
@ -62,6 +61,7 @@
|
||||||
"download": "Download",
|
"download": "Download",
|
||||||
"update_completed": "Update Done",
|
"update_completed": "Update Done",
|
||||||
"updating_docs": "Updating documents",
|
"updating_docs": "Updating documents",
|
||||||
|
"updating_forms": "Updating forms",
|
||||||
"updating_folders": "Updating folders",
|
"updating_folders": "Updating folders",
|
||||||
"sending_flyers": "Sending documents",
|
"sending_flyers": "Sending documents",
|
||||||
"updating_contacts": "Updating contacts",
|
"updating_contacts": "Updating contacts",
|
||||||
|
|
@ -79,7 +79,7 @@
|
||||||
"contact_deleted": "Contact deleted",
|
"contact_deleted": "Contact deleted",
|
||||||
"contact_added": "Contact added",
|
"contact_added": "Contact added",
|
||||||
"send_flyer": "Send a document",
|
"send_flyer": "Send a document",
|
||||||
"select_contact": "Select the contact",
|
"select_contact": "Select a user",
|
||||||
"transfer": "Transfer",
|
"transfer": "Transfer",
|
||||||
"contact_list": "Contact List",
|
"contact_list": "Contact List",
|
||||||
"documents_list": "Documents List"
|
"documents_list": "Documents List"
|
||||||
|
|
@ -90,12 +90,14 @@
|
||||||
"contact_saved": "Contact saved",
|
"contact_saved": "Contact saved",
|
||||||
"confirm_visit_delete": "are you sure to delete this visit ?",
|
"confirm_visit_delete": "are you sure to delete this visit ?",
|
||||||
"qrcode_not_vcard_format": "This QRCode is not a VCard",
|
"qrcode_not_vcard_format": "This QRCode is not a VCard",
|
||||||
"customer": "Customer",
|
|
||||||
"prospect": "Prospect",
|
|
||||||
"other": "Other",
|
|
||||||
"description": "Description",
|
"description": "Description",
|
||||||
"no_visits": "No visits available",
|
"no_visits": "No visits available",
|
||||||
"visit_name": "visits name"
|
"visit_name": "visits name",
|
||||||
|
"input_select_please_choose": "Select a value",
|
||||||
|
"input_select_multiple_search": "Search",
|
||||||
|
"input_required": "The %{placeholder} field is required",
|
||||||
|
"input_too_long": "%{placeholder} field is too long",
|
||||||
|
"input_email": "The %{placeholder} field must be a valid email"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"error": "Error",
|
"error": "Error",
|
||||||
|
|
@ -104,14 +106,14 @@
|
||||||
"incorrect_credentials": "Incorrect Credentials",
|
"incorrect_credentials": "Incorrect Credentials",
|
||||||
"must_fill_login_fields": "You must fill the login fields.",
|
"must_fill_login_fields": "You must fill the login fields.",
|
||||||
"invalid_email_address": "Invalid E-mail adress",
|
"invalid_email_address": "Invalid E-mail adress",
|
||||||
|
"invalid_firstname": "Firstname is not valid",
|
||||||
|
"invalid_lastname": "Lastname is not valid",
|
||||||
|
"invalid_phone": "Phone is not valid",
|
||||||
|
"field_required": "The %{placeholder} field is required",
|
||||||
"error_has_occurred": "An error occured",
|
"error_has_occurred": "An error occured",
|
||||||
"must_be_connected_internet_sync": "You must be connected to internet to be able to synchronize",
|
"must_be_connected_internet_sync": "You must be connected to internet to be able to synchronize",
|
||||||
"incomplete_form": "Incomplete Form",
|
"incomplete_form": "Incomplete Form",
|
||||||
"fill_all_fields_and_1_doc_min": "Please fill up all the fields, at least one document and a valid e-mail adress",
|
"fill_all_fields_and_1_doc_min": "Please fill up all the fields, at least one document and a valid e-mail adress",
|
||||||
"fill_other_field": "You must fill the description field for : Other",
|
|
||||||
"specify_type_contact": "You must specify the contact type",
|
|
||||||
"invalid_name": "Invalid lastname",
|
|
||||||
"invalid_firstname": "Invalid firstname",
|
|
||||||
"camera_permission_denied": "Camera Permission Denied",
|
"camera_permission_denied": "Camera Permission Denied",
|
||||||
"pending_camera_permission": "Waiting for the camera permission"
|
"pending_camera_permission": "Waiting for the camera permission"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
"videos": "Vidéos",
|
"videos": "Vidéos",
|
||||||
"contacts": "Contacts",
|
"contacts": "Contacts",
|
||||||
"confirmation": "Confirmation",
|
"confirmation": "Confirmation",
|
||||||
"name": "Nom",
|
"lastname": "Nom",
|
||||||
"firstname": "Prénom",
|
"firstname": "Prénom",
|
||||||
"address": "Adresse",
|
"address": "Adresse",
|
||||||
"phone": "Téléphone",
|
"phone": "Téléphone",
|
||||||
|
|
@ -47,8 +47,7 @@
|
||||||
"folders": "Dossiers",
|
"folders": "Dossiers",
|
||||||
"video": "Vidéo",
|
"video": "Vidéo",
|
||||||
"contact_details": "Détails du contact",
|
"contact_details": "Détails du contact",
|
||||||
"results_search": "Résultat(s) de votre recherche",
|
"results_search": "Résultat(s) de votre recherche"
|
||||||
"my_space": "Mon espace"
|
|
||||||
},
|
},
|
||||||
"login_s": {
|
"login_s": {
|
||||||
"username": "Identifiant",
|
"username": "Identifiant",
|
||||||
|
|
@ -62,6 +61,7 @@
|
||||||
"download": "Téléchargement",
|
"download": "Téléchargement",
|
||||||
"update_completed": "Mise à jour effectuée",
|
"update_completed": "Mise à jour effectuée",
|
||||||
"updating_docs": "Mise à jour des documents",
|
"updating_docs": "Mise à jour des documents",
|
||||||
|
"updating_forms": "Mise à jour des formulaires",
|
||||||
"updating_folders": "Mise à jour des dossiers",
|
"updating_folders": "Mise à jour des dossiers",
|
||||||
"sending_flyers": "Envoi des brochures",
|
"sending_flyers": "Envoi des brochures",
|
||||||
"updating_contacts": "Mise à jour des contacts",
|
"updating_contacts": "Mise à jour des contacts",
|
||||||
|
|
@ -79,7 +79,7 @@
|
||||||
"contact_deleted": "Contact supprimé",
|
"contact_deleted": "Contact supprimé",
|
||||||
"contact_added": "Contact ajouté",
|
"contact_added": "Contact ajouté",
|
||||||
"send_flyer": "Envoyer une brochure",
|
"send_flyer": "Envoyer une brochure",
|
||||||
"select_contact": "Sélectionnez le contact",
|
"select_contact": "Sélectionnez un utilisateur",
|
||||||
"transfer": "Transférer",
|
"transfer": "Transférer",
|
||||||
"contact_list": "Liste des contacts",
|
"contact_list": "Liste des contacts",
|
||||||
"documents_list": "Liste des documents"
|
"documents_list": "Liste des documents"
|
||||||
|
|
@ -90,12 +90,14 @@
|
||||||
"contact_saved": "Contact enregistré",
|
"contact_saved": "Contact enregistré",
|
||||||
"confirm_visit_delete": "Êtes-vous sûr de vouloir supprimer cette visite ?",
|
"confirm_visit_delete": "Êtes-vous sûr de vouloir supprimer cette visite ?",
|
||||||
"qrcode_not_vcard_format": "Ce QRCode n'est pas au format vCard",
|
"qrcode_not_vcard_format": "Ce QRCode n'est pas au format vCard",
|
||||||
"customer": "Client",
|
|
||||||
"prospect": "Prospect",
|
|
||||||
"other": "Autre",
|
|
||||||
"description": "Description",
|
"description": "Description",
|
||||||
"no_visits": "Aucune visites",
|
"no_visits": "Aucune visites",
|
||||||
"visit_name": "Nom de la visite"
|
"visit_name": "Nom de la visite",
|
||||||
|
"input_select_please_choose": "Selectionnez un élément",
|
||||||
|
"input_select_multiple_search": "Recherche",
|
||||||
|
"input_required": "Le champ %{placeholder} est obligatoire",
|
||||||
|
"input_too_long": "Le champ %{placeholder} est trop long",
|
||||||
|
"input_email": "Le champ %{placeholder} doit être un email valide"
|
||||||
},
|
},
|
||||||
"error": {
|
"error": {
|
||||||
"error": "Erreur",
|
"error": "Erreur",
|
||||||
|
|
@ -104,14 +106,14 @@
|
||||||
"incorrect_credentials": "Identifiants incorrect.",
|
"incorrect_credentials": "Identifiants incorrect.",
|
||||||
"must_fill_login_fields": "Vous devez-remplir les champs de connexion.",
|
"must_fill_login_fields": "Vous devez-remplir les champs de connexion.",
|
||||||
"invalid_email_address": "Adresse email invalide",
|
"invalid_email_address": "Adresse email invalide",
|
||||||
|
"invalid_firstname": "Prénom invalide",
|
||||||
|
"invalid_lastname": "Nom invalide",
|
||||||
|
"invalid_phone": "Téléphone invalide",
|
||||||
|
"field_required": "Le champ %{placeholder} est obligatoire",
|
||||||
"error_has_occurred": "Une erreur est survenue",
|
"error_has_occurred": "Une erreur est survenue",
|
||||||
"must_be_connected_internet_sync": "Vous devez être connecté à internet pour lancer la synchronisation",
|
"must_be_connected_internet_sync": "Vous devez être connecté à internet pour lancer la synchronisation",
|
||||||
"incomplete_form": "Formulaire incomplet",
|
"incomplete_form": "Formulaire incomplet",
|
||||||
"fill_all_fields_and_1_doc_min": "Veuillez remplir tous les champs, 1 document minimum et une adresse email valide",
|
"fill_all_fields_and_1_doc_min": "Veuillez remplir tous les champs, 1 document minimum et une adresse email valide",
|
||||||
"fill_other_field": "Vous devez remplir le champs description pour : Autre",
|
|
||||||
"specify_type_contact": "Vous devez préciser le type de contact",
|
|
||||||
"invalid_name": "Nom invalide",
|
|
||||||
"invalid_firstname": "Prénom invalide",
|
|
||||||
"camera_permission_denied": "Permission caméra refusée",
|
"camera_permission_denied": "Permission caméra refusée",
|
||||||
"pending_camera_permission": "En attente de permission caméra"
|
"pending_camera_permission": "En attente de permission caméra"
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { StyleSheet, Dimensions } from 'react-native';
|
import {Dimensions, StyleSheet} from 'react-native';
|
||||||
|
|
||||||
const { width } = Dimensions.get('window');
|
const {width} = Dimensions.get('window');
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|
@ -18,7 +18,7 @@ const styles = StyleSheet.create({
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
width: width / 4,
|
width: width / 4,
|
||||||
fontWeight: 'bold'
|
fontWeight: 'bold',
|
||||||
},
|
},
|
||||||
company: {
|
company: {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
|
|
@ -62,13 +62,13 @@ const styles = StyleSheet.create({
|
||||||
inputSearch: {
|
inputSearch: {
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
width: 200,
|
width: 200,
|
||||||
paddingLeft: 20
|
paddingLeft: 20,
|
||||||
},
|
},
|
||||||
btnSearch: {
|
btnSearch: {
|
||||||
width: 50,
|
width: 50,
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center'
|
justifyContent: 'center',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -29,8 +29,8 @@ const styles = StyleSheet.create({
|
||||||
color: 'white',
|
color: 'white',
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
padding: 5
|
padding: 5,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -22,18 +22,18 @@ const styles = StyleSheet.create({
|
||||||
marginRight: 50,
|
marginRight: 50,
|
||||||
width: 400,
|
width: 400,
|
||||||
height: 80,
|
height: 80,
|
||||||
borderRadius: 10
|
borderRadius: 10,
|
||||||
},
|
},
|
||||||
btnTxt: {
|
btnTxt: {
|
||||||
fontSize: 20
|
fontSize: 20,
|
||||||
},
|
},
|
||||||
btnImg: {
|
btnImg: {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
left: 15,
|
left: 15,
|
||||||
height: 50,
|
height: 50,
|
||||||
width: 50,
|
width: 50,
|
||||||
resizeMode: 'stretch'
|
resizeMode: 'stretch',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -9,10 +9,10 @@ const styles = StyleSheet.create({
|
||||||
logo: {
|
logo: {
|
||||||
width: 150,
|
width: 150,
|
||||||
height: 150,
|
height: 150,
|
||||||
marginBottom: 20
|
marginBottom: 20,
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
marginTop: 20
|
marginTop: 20,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ const styles = StyleSheet.create({
|
||||||
logo: {
|
logo: {
|
||||||
width: 150,
|
width: 150,
|
||||||
height: 150,
|
height: 150,
|
||||||
marginBottom: 20
|
marginBottom: 20,
|
||||||
},
|
},
|
||||||
text: {
|
text: {
|
||||||
height: 40,
|
height: 40,
|
||||||
|
|
@ -18,7 +18,7 @@ const styles = StyleSheet.create({
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
marginBottom: 20,
|
marginBottom: 20,
|
||||||
backgroundColor: 'white',
|
backgroundColor: 'white',
|
||||||
paddingLeft: 10
|
paddingLeft: 10,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,10 @@ const styles = StyleSheet.create({
|
||||||
drawer: {
|
drawer: {
|
||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
alignItems: "center",
|
alignItems: 'center',
|
||||||
justifyContent: "space-between",
|
justifyContent: 'space-between',
|
||||||
backgroundColor: "#ffffff",
|
backgroundColor: '#ffffff',
|
||||||
padding: 20
|
padding: 20,
|
||||||
},
|
},
|
||||||
btn: {
|
btn: {
|
||||||
borderWidth: 1,
|
borderWidth: 1,
|
||||||
|
|
@ -27,12 +27,12 @@ const styles = StyleSheet.create({
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
padding: 10,
|
padding: 10,
|
||||||
marginBottom: 10
|
marginBottom: 10,
|
||||||
},
|
},
|
||||||
btnText: {
|
btnText: {
|
||||||
marginLeft: 10
|
marginLeft: 10,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -26,8 +26,8 @@ const styles = StyleSheet.create({
|
||||||
color: 'white',
|
color: 'white',
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
padding: 5
|
padding: 5,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { StyleSheet, Dimensions } from 'react-native';
|
import { Dimensions, StyleSheet } from 'react-native';
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
container: {
|
container: {
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ const styles = StyleSheet.create({
|
||||||
color: 'white',
|
color: 'white',
|
||||||
fontWeight: 'bold',
|
fontWeight: 'bold',
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
padding: 5
|
padding: 5,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -7,8 +7,8 @@ const styles = StyleSheet.create({
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
btnWrapper: {
|
btnWrapper: {
|
||||||
marginTop: 20
|
marginTop: 20,
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default styles;
|
export default styles;
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
|
import { Picker } from '@react-native-picker/picker';
|
||||||
|
import { ButtonGroup, CheckBox, Overlay } from '@rneui/themed';
|
||||||
|
import { BarCodeScanner } from 'expo-barcode-scanner';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import {
|
||||||
View,
|
Alert,
|
||||||
StyleSheet,
|
|
||||||
Button,
|
Button,
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
Text,
|
View,
|
||||||
Alert,
|
|
||||||
ScrollView
|
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { CheckBox, ButtonGroup, Overlay } from '@rneui/themed';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
||||||
import { showMessage } from 'react-native-flash-message';
|
import { showMessage } from 'react-native-flash-message';
|
||||||
import Helpers from "../Controllers/Helpers";
|
import Icon from 'react-native-vector-icons/FontAwesome';
|
||||||
import i18n from "../I18n";
|
import { connect } from 'react-redux';
|
||||||
import { BarCodeScanner } from 'expo-barcode-scanner';
|
|
||||||
import vCard from 'vcard-parser';
|
import vCard from 'vcard-parser';
|
||||||
import { Picker } from '@react-native-picker/picker';
|
import Helpers from '../Controllers/Helpers';
|
||||||
|
import i18n from '../I18n';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -79,7 +79,7 @@ class ContactDetailsScreen extends React.Component {
|
||||||
parsedEmail: '',
|
parsedEmail: '',
|
||||||
parsedCompany: '',
|
parsedCompany: '',
|
||||||
parsedAddress: '',
|
parsedAddress: '',
|
||||||
parsedPhone: ''
|
parsedPhone: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
updateContact() {
|
updateContact() {
|
||||||
|
|
@ -87,9 +87,8 @@ class ContactDetailsScreen extends React.Component {
|
||||||
const { action } = this.props.route.params;
|
const { action } = this.props.route.params;
|
||||||
// On récupère le texte courant
|
// On récupère le texte courant
|
||||||
if (this.state.visits.length > 0) {
|
if (this.state.visits.length > 0) {
|
||||||
this.state.visits[
|
this.state.visits[this.state.selectedVisit].note =
|
||||||
this.state.selectedVisit
|
this.state.tmpVisitNote;
|
||||||
].note = this.state.tmpVisitNote;
|
|
||||||
}
|
}
|
||||||
let type;
|
let type;
|
||||||
if (this.state.clientChecked === true) {
|
if (this.state.clientChecked === true) {
|
||||||
|
|
@ -104,22 +103,29 @@ class ContactDetailsScreen extends React.Component {
|
||||||
} else {
|
} else {
|
||||||
error = error.concat(i18n.t('error.specify_type_contact') + '.\n');
|
error = error.concat(i18n.t('error.specify_type_contact') + '.\n');
|
||||||
}
|
}
|
||||||
if (this.state.tmpEmail.length < 5 || !Helpers.isEmailValid(this.state.tmpEmail)) {
|
if (
|
||||||
|
this.state.tmpEmail.length < 5 ||
|
||||||
|
!Helpers.isEmailValid(this.state.tmpEmail)
|
||||||
|
) {
|
||||||
error = error.concat(i18n.t('error.invalid_email_address') + '.\n');
|
error = error.concat(i18n.t('error.invalid_email_address') + '.\n');
|
||||||
}
|
}
|
||||||
if (this.state.tmpName.length === 0 || !Helpers.isValidRequiredString(this.state.tmpName)) {
|
if (
|
||||||
|
this.state.tmpName.length === 0 ||
|
||||||
|
!Helpers.isValidRequiredString(this.state.tmpName)
|
||||||
|
) {
|
||||||
error = error.concat(i18n.t('error.invalid_name') + '.\n');
|
error = error.concat(i18n.t('error.invalid_name') + '.\n');
|
||||||
}
|
}
|
||||||
if (this.state.tmpFirstname.length === 0 || !Helpers.isValidRequiredString(this.state.tmpFirstname)) {
|
if (
|
||||||
|
this.state.tmpFirstname.length === 0 ||
|
||||||
|
!Helpers.isValidRequiredString(this.state.tmpFirstname)
|
||||||
|
) {
|
||||||
error = error.concat(i18n.t('error.invalid_firstname') + '.\n');
|
error = error.concat(i18n.t('error.invalid_firstname') + '.\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error.length > 0) {
|
if (error.length > 0) {
|
||||||
Alert.alert(i18n.t('global.warning') + ' !', error, [
|
Alert.alert(i18n.t('global.warning') + ' !', error, [{ text: 'OK' }], {
|
||||||
{ text: 'OK' },
|
cancelable: false,
|
||||||
],
|
});
|
||||||
{ cancelable: false },
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
const products = [
|
const products = [
|
||||||
this.state.p1,
|
this.state.p1,
|
||||||
|
|
@ -130,7 +136,7 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.state.p6,
|
this.state.p6,
|
||||||
this.state.p7,
|
this.state.p7,
|
||||||
this.state.p8,
|
this.state.p8,
|
||||||
this.state.p9
|
this.state.p9,
|
||||||
];
|
];
|
||||||
const contact = {
|
const contact = {
|
||||||
id: Helpers.generateUUID(),
|
id: Helpers.generateUUID(),
|
||||||
|
|
@ -294,7 +300,6 @@ class ContactDetailsScreen extends React.Component {
|
||||||
BarCodeScanner.requestPermissionsAsync().then(res => {
|
BarCodeScanner.requestPermissionsAsync().then(res => {
|
||||||
this.setState({ hasPermission: res.status === 'granted' });
|
this.setState({ hasPermission: res.status === 'granted' });
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
@ -303,12 +308,15 @@ class ContactDetailsScreen extends React.Component {
|
||||||
if (data.includes('VCARD')) {
|
if (data.includes('VCARD')) {
|
||||||
let datas = vCard.parse(data);
|
let datas = vCard.parse(data);
|
||||||
let tmpDatas = [];
|
let tmpDatas = [];
|
||||||
if (datas['n'] !== undefined) {
|
if (datas.n !== undefined) {
|
||||||
const nx = Object.assign({ n1: [{ value: datas['n'][0].value[0] }] }, { n2: [{ value: datas['n'][0].value[1] }] });
|
const nx = Object.assign(
|
||||||
|
{ n1: [{ value: datas.n[0].value[0] }] },
|
||||||
|
{ n2: [{ value: datas.n[0].value[1] }] },
|
||||||
|
);
|
||||||
datas = Object.assign(datas, nx);
|
datas = Object.assign(datas, nx);
|
||||||
}
|
}
|
||||||
if (datas['adr'] !== undefined) {
|
if (datas.adr !== undefined) {
|
||||||
let tmp = datas['adr'][0].value;
|
let tmp = datas.adr[0].value;
|
||||||
let tmpadr = '';
|
let tmpadr = '';
|
||||||
for (let i = 0; i < tmp.length; i++) {
|
for (let i = 0; i < tmp.length; i++) {
|
||||||
if (tmp[i].length > 0) {
|
if (tmp[i].length > 0) {
|
||||||
|
|
@ -319,17 +327,29 @@ class ContactDetailsScreen extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
datas['adr'] = [{ value: tmpadr }];
|
datas.adr = [{ value: tmpadr }];
|
||||||
}
|
}
|
||||||
Object.keys(datas).map((objectKey, index) => {
|
Object.keys(datas).map((objectKey, index) => {
|
||||||
if (objectKey === 'email' || objectKey === 'adr' || objectKey === 'tel' || objectKey === 'org' || objectKey === 'n1' || objectKey === 'n2') {
|
if (
|
||||||
|
objectKey === 'email' ||
|
||||||
|
objectKey === 'adr' ||
|
||||||
|
objectKey === 'tel' ||
|
||||||
|
objectKey === 'org' ||
|
||||||
|
objectKey === 'n1' ||
|
||||||
|
objectKey === 'n2'
|
||||||
|
) {
|
||||||
let value = datas[objectKey][0].value;
|
let value = datas[objectKey][0].value;
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
tmpDatas.push(value);
|
tmpDatas.push(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.setState({ parsedType: 'vcard', parsedDatas: tmpDatas, showQRcodevCard: false, showDynContact: true })
|
this.setState({
|
||||||
|
parsedType: 'vcard',
|
||||||
|
parsedDatas: tmpDatas,
|
||||||
|
showQRcodevCard: false,
|
||||||
|
showDynContact: true,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(i18n.t('contact_details_s.qrcode_not_vcard_format'));
|
Alert.alert(i18n.t('contact_details_s.qrcode_not_vcard_format'));
|
||||||
}
|
}
|
||||||
|
|
@ -389,22 +409,41 @@ class ContactDetailsScreen extends React.Component {
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row' }}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={{ backgroundColor: 'white', margin: 10, padding: 10, flex: 1 }}
|
style={{
|
||||||
|
backgroundColor: 'white',
|
||||||
|
margin: 10,
|
||||||
|
padding: 10,
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
value={this.state.tmpName}
|
value={this.state.tmpName}
|
||||||
placeholder={i18n.t('global.name') + ' (' + i18n.t('global.required') + ')'}
|
placeholder={
|
||||||
|
i18n.t('global.name') + ' (' + i18n.t('global.required') + ')'
|
||||||
|
}
|
||||||
onChangeText={text => this.setState({ tmpName: text })}
|
onChangeText={text => this.setState({ tmpName: text })}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={{ backgroundColor: 'white', margin: 10, padding: 10, flex: 1 }}
|
style={{
|
||||||
|
backgroundColor: 'white',
|
||||||
|
margin: 10,
|
||||||
|
padding: 10,
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
value={this.state.tmpFirstname}
|
value={this.state.tmpFirstname}
|
||||||
placeholder={i18n.t('global.firstname') + ' (' + i18n.t('global.required') + ')'}
|
placeholder={
|
||||||
|
i18n.t('global.firstname') +
|
||||||
|
' (' +
|
||||||
|
i18n.t('global.required') +
|
||||||
|
')'
|
||||||
|
}
|
||||||
onChangeText={text => this.setState({ tmpFirstname: text })}
|
onChangeText={text => this.setState({ tmpFirstname: text })}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={styles.input}
|
||||||
value={this.state.tmpEmail}
|
value={this.state.tmpEmail}
|
||||||
placeholder={i18n.t('global.email') + ' (' + i18n.t('global.required') + ')'}
|
placeholder={
|
||||||
|
i18n.t('global.email') + ' (' + i18n.t('global.required') + ')'
|
||||||
|
}
|
||||||
onChangeText={text => this.setState({ tmpEmail: text })}
|
onChangeText={text => this.setState({ tmpEmail: text })}
|
||||||
autoCapitalize={'none'}
|
autoCapitalize={'none'}
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
|
|
@ -433,7 +472,12 @@ class ContactDetailsScreen extends React.Component {
|
||||||
/>
|
/>
|
||||||
<View style={{ flexDirection: 'row' }}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
<View style={{ flex: 1, flexDirection: 'row' }}>
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||||
<Icon name="sort-down" size={20} color={'black'} style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }} />
|
<Icon
|
||||||
|
name="sort-down"
|
||||||
|
size={20}
|
||||||
|
color={'black'}
|
||||||
|
style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }}
|
||||||
|
/>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.tmpSelect1}
|
selectedValue={this.state.tmpSelect1}
|
||||||
style={styles.select}
|
style={styles.select}
|
||||||
|
|
@ -442,33 +486,107 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ tmpSelect1: itemValue });
|
this.setState({ tmpSelect1: itemValue });
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.title')} value="0" />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c1')} value="commerce-de-detail" />
|
label={i18n.t('custom.select-1.title')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c2')} value={'home-service-freezer-center'} />
|
value="0"
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c3')} value={'restauration-service-a-table'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c4')} value={'fast-food-et-snacking'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c5')} value={'cafetaria-self-service'} />
|
label={i18n.t('custom.select-1.c1')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c6')} value={'societe-de-restauration'} />
|
value="commerce-de-detail"
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c7')} value={'restauration-gre-a-gre-cuisine-centrale'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c8')} value={'distributeur-independant'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c9')} value={'boulangerie-patisserie'} />
|
label={i18n.t('custom.select-1.c2')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c10')} value={'pai'} />
|
value={'home-service-freezer-center'}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c11')} value={'destockeur'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c12')} value={'commerce-halal'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c13')} value={'restauration-d-hebergement'} />
|
label={i18n.t('custom.select-1.c3')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c14')} value={'centrale-restauration-commerciale'} />
|
value={'restauration-service-a-table'}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c15')} value={'restauration-evenementielle-et-parc'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c16')} value={'restauration-de-transport'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c17')} value={'marche-public'} />
|
label={i18n.t('custom.select-1.c4')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c18')} value={'cash'} />
|
value={'fast-food-et-snacking'}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c19')} value={'distributeur-national'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c20')} value={'rungis'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c21')} value={'abbatoir'} />
|
label={i18n.t('custom.select-1.c5')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c22')} value={'autre'} />
|
value={'cafetaria-self-service'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c6')}
|
||||||
|
value={'societe-de-restauration'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c7')}
|
||||||
|
value={'restauration-gre-a-gre-cuisine-centrale'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c8')}
|
||||||
|
value={'distributeur-independant'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c9')}
|
||||||
|
value={'boulangerie-patisserie'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c10')}
|
||||||
|
value={'pai'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c11')}
|
||||||
|
value={'destockeur'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c12')}
|
||||||
|
value={'commerce-halal'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c13')}
|
||||||
|
value={'restauration-d-hebergement'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c14')}
|
||||||
|
value={'centrale-restauration-commerciale'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c15')}
|
||||||
|
value={'restauration-evenementielle-et-parc'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c16')}
|
||||||
|
value={'restauration-de-transport'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c17')}
|
||||||
|
value={'marche-public'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c18')}
|
||||||
|
value={'cash'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c19')}
|
||||||
|
value={'distributeur-national'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c20')}
|
||||||
|
value={'rungis'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c21')}
|
||||||
|
value={'abbatoir'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c22')}
|
||||||
|
value={'autre'}
|
||||||
|
/>
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flex: 1, flexDirection: 'row' }}>
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||||
<Icon name="sort-down" size={20} color={'black'} style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }} />
|
<Icon
|
||||||
|
name="sort-down"
|
||||||
|
size={20}
|
||||||
|
color={'black'}
|
||||||
|
style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }}
|
||||||
|
/>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.tmpSelect2}
|
selectedValue={this.state.tmpSelect2}
|
||||||
style={styles.select}
|
style={styles.select}
|
||||||
|
|
@ -477,19 +595,58 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ tmpSelect2: itemValue });
|
this.setState({ tmpSelect2: itemValue });
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Picker.Item label={i18n.t('custom.select-2.title')} value="0" />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c1')} value={'celvia-dinde'} />
|
label={i18n.t('custom.select-2.title')}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c2')} value={'celvia-elabores'} />
|
value="0"
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c3')} value={'celvia-serent'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c4')} value={'procanar'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c5')} value={'celtys'} />
|
label={i18n.t('custom.select-2.c1')}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c6')} value={'farmor'} />
|
value={'celvia-dinde'}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c7')} value={'robichon'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c8')} value={'les-volailles-de-keranna'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c9')} value={'bosher-volaille'} />
|
label={i18n.t('custom.select-2.c2')}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c10')} value={'ldc-bretagne'} />
|
value={'celvia-elabores'}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c11')} value={'doux-farmor'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c12')} value={'favreau'} />
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c3')}
|
||||||
|
value={'celvia-serent'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c4')}
|
||||||
|
value={'procanar'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c5')}
|
||||||
|
value={'celtys'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c6')}
|
||||||
|
value={'farmor'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c7')}
|
||||||
|
value={'robichon'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c8')}
|
||||||
|
value={'les-volailles-de-keranna'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c9')}
|
||||||
|
value={'bosher-volaille'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c10')}
|
||||||
|
value={'ldc-bretagne'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c11')}
|
||||||
|
value={'doux-farmor'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c12')}
|
||||||
|
value={'favreau'}
|
||||||
|
/>
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -532,7 +689,10 @@ class ContactDetailsScreen extends React.Component {
|
||||||
<View style={{ flex: 1, margin: 5 }}>
|
<View style={{ flex: 1, margin: 5 }}>
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
buttons={[i18n.t('contact_details_s.visits'), i18n.t('contact_details_s.notes')]}
|
buttons={[
|
||||||
|
i18n.t('contact_details_s.visits'),
|
||||||
|
i18n.t('contact_details_s.notes'),
|
||||||
|
]}
|
||||||
selectedButtonStyle={{ backgroundColor: '#ea4f52' }}
|
selectedButtonStyle={{ backgroundColor: '#ea4f52' }}
|
||||||
containerStyle={{ height: 30 }}
|
containerStyle={{ height: 30 }}
|
||||||
selectedIndex={this.state.selectedIndex}
|
selectedIndex={this.state.selectedIndex}
|
||||||
|
|
@ -543,14 +703,23 @@ class ContactDetailsScreen extends React.Component {
|
||||||
<View style={{ flexDirection: 'row' }}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
{this.state.visits.length > 0 && (
|
{this.state.visits.length > 0 && (
|
||||||
<View style={{ flex: 2, flexDirection: 'row' }}>
|
<View style={{ flex: 2, flexDirection: 'row' }}>
|
||||||
<Icon name="sort-down" size={20} color={'black'} style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }} />
|
<Icon
|
||||||
|
name="sort-down"
|
||||||
|
size={20}
|
||||||
|
color={'black'}
|
||||||
|
style={{
|
||||||
|
zIndex: 1,
|
||||||
|
position: 'absolute',
|
||||||
|
right: 25,
|
||||||
|
top: 20,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Picker
|
<Picker
|
||||||
style={styles.select}
|
style={styles.select}
|
||||||
selectedValue={this.state.selectedVisit}
|
selectedValue={this.state.selectedVisit}
|
||||||
onValueChange={(itemValue, itemIndex) => {
|
onValueChange={(itemValue, itemIndex) => {
|
||||||
this.state.visits[
|
this.state.visits[this.state.selectedVisit].note =
|
||||||
this.state.selectedVisit
|
this.state.tmpVisitNote;
|
||||||
].note = this.state.tmpVisitNote;
|
|
||||||
this.setState({
|
this.setState({
|
||||||
visits: this.state.visits,
|
visits: this.state.visits,
|
||||||
selectedVisit: itemIndex,
|
selectedVisit: itemIndex,
|
||||||
|
|
@ -558,7 +727,9 @@ class ContactDetailsScreen extends React.Component {
|
||||||
});
|
});
|
||||||
}}>
|
}}>
|
||||||
{this.state.visits.map((item, index) => {
|
{this.state.visits.map((item, index) => {
|
||||||
return <Picker.Item label={item.title} value={index} />;
|
return (
|
||||||
|
<Picker.Item label={item.title} value={index} />
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -621,13 +792,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', justifyContent: 'space-evenly' }}>
|
<View
|
||||||
|
style={{ flexDirection: 'row', justifyContent: 'space-evenly' }}>
|
||||||
{this.state.action === 'add' && (
|
{this.state.action === 'add' && (
|
||||||
<>
|
<>
|
||||||
<Button title="QRCode vCard" onPress={() => this.setState({ showQRcodevCard: true })} color={'#ea4f52'} />
|
<Button
|
||||||
|
title="QRCode vCard"
|
||||||
|
onPress={() => this.setState({ showQRcodevCard: true })}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Button title={i18n.t('global.save')} onPress={() => this.updateContact()} color={'#ea4f52'} />
|
<Button
|
||||||
|
title={i18n.t('global.save')}
|
||||||
|
onPress={() => this.updateContact()}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<Overlay
|
<Overlay
|
||||||
|
|
@ -638,7 +818,9 @@ class ContactDetailsScreen extends React.Component {
|
||||||
height={300}>
|
height={300}>
|
||||||
<View
|
<View
|
||||||
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||||
<Text style={{ marginBottom: 10 }}>{i18n.t('contact_details_s.visit_name')} :</Text>
|
<Text style={{ marginBottom: 10 }}>
|
||||||
|
{i18n.t('contact_details_s.visit_name')} :
|
||||||
|
</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={i18n.t('contact_details_s.visit_name')}
|
placeholder={i18n.t('contact_details_s.visit_name')}
|
||||||
value={this.state.newVisitTitle}
|
value={this.state.newVisitTitle}
|
||||||
|
|
@ -663,7 +845,11 @@ class ContactDetailsScreen extends React.Component {
|
||||||
onPress={() => this.setState({ showNewVisit: false })}
|
onPress={() => this.setState({ showNewVisit: false })}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
<Button title={i18n.t('global.add')} onPress={() => this.newVisit()} color={'#ea4f52'} />
|
<Button
|
||||||
|
title={i18n.t('global.add')}
|
||||||
|
onPress={() => this.newVisit()}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
|
|
@ -673,10 +859,13 @@ class ContactDetailsScreen extends React.Component {
|
||||||
overlayBackgroundColor="white"
|
overlayBackgroundColor="white"
|
||||||
width={400}
|
width={400}
|
||||||
height={300}>
|
height={300}>
|
||||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
<View
|
||||||
|
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||||
{this.state.hasPermission === true && (
|
{this.state.hasPermission === true && (
|
||||||
<BarCodeScanner
|
<BarCodeScanner
|
||||||
onBarCodeScanned={this.state.scanned ? undefined : handleBarCodeScanned}
|
onBarCodeScanned={
|
||||||
|
this.state.scanned ? undefined : handleBarCodeScanned
|
||||||
|
}
|
||||||
barCodeTypes={[BarCodeScanner.Constants.BarCodeType.qr]}
|
barCodeTypes={[BarCodeScanner.Constants.BarCodeType.qr]}
|
||||||
style={{ flex: 1, width: 380, height: 200 }}
|
style={{ flex: 1, width: 380, height: 200 }}
|
||||||
/>
|
/>
|
||||||
|
|
@ -696,10 +885,18 @@ class ContactDetailsScreen extends React.Component {
|
||||||
}}>
|
}}>
|
||||||
<Button
|
<Button
|
||||||
title={i18n.t('global.cancel')}
|
title={i18n.t('global.cancel')}
|
||||||
onPress={() => this.setState({ showQRcodevCard: false, scanned: false })}
|
onPress={() =>
|
||||||
|
this.setState({ showQRcodevCard: false, scanned: false })
|
||||||
|
}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
{this.state.scanned && <Button title={i18n.t('global.retry')} onPress={() => this.setState({ scanned: false })} color={'#ea4f52'} />}
|
{this.state.scanned && (
|
||||||
|
<Button
|
||||||
|
title={i18n.t('global.retry')}
|
||||||
|
onPress={() => this.setState({ scanned: false })}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
|
|
@ -709,9 +906,16 @@ class ContactDetailsScreen extends React.Component {
|
||||||
overlayBackgroundColor="white"
|
overlayBackgroundColor="white"
|
||||||
width={400}
|
width={400}
|
||||||
height={400}>
|
height={400}>
|
||||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'space-evenly' }}>
|
<View
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-evenly',
|
||||||
|
}}>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.name')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.name')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedName}
|
selectedValue={this.state.parsedName}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -719,13 +923,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedName: itemValue });
|
this.setState({ parsedName: itemValue });
|
||||||
}}>
|
}}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.firstname')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.firstname')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedFirstname}
|
selectedValue={this.state.parsedFirstname}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -733,13 +946,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedFirstname: itemValue })
|
this.setState({ parsedFirstname: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.email')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.email')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedEmail}
|
selectedValue={this.state.parsedEmail}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -747,13 +969,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedEmail: itemValue })
|
this.setState({ parsedEmail: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.company')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.company')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedCompany}
|
selectedValue={this.state.parsedCompany}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -761,13 +992,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedCompany: itemValue })
|
this.setState({ parsedCompany: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.address')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.address')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedAddress}
|
selectedValue={this.state.parsedAddress}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -775,13 +1015,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedAddress: itemValue })
|
this.setState({ parsedAddress: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.phone')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.phone')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedPhone}
|
selectedValue={this.state.parsedPhone}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -789,8 +1038,15 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedPhone: itemValue })
|
this.setState({ parsedPhone: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -803,12 +1059,24 @@ class ContactDetailsScreen extends React.Component {
|
||||||
}}>
|
}}>
|
||||||
<Button
|
<Button
|
||||||
title={i18n.t('global.cancel')}
|
title={i18n.t('global.cancel')}
|
||||||
onPress={() => this.setState({ showDynContact: false, scanned: false, parsedName: '', parsedFirstname: '', parsedEmail: '', parsedCompany: '', parsedAddress: '', parsedPhone: '' })}
|
onPress={() =>
|
||||||
|
this.setState({
|
||||||
|
showDynContact: false,
|
||||||
|
scanned: false,
|
||||||
|
parsedName: '',
|
||||||
|
parsedFirstname: '',
|
||||||
|
parsedEmail: '',
|
||||||
|
parsedCompany: '',
|
||||||
|
parsedAddress: '',
|
||||||
|
parsedPhone: '',
|
||||||
|
})
|
||||||
|
}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
title={i18n.t('global.next')}
|
title={i18n.t('global.next')}
|
||||||
onPress={() => this.setState({
|
onPress={() =>
|
||||||
|
this.setState({
|
||||||
tmpName: this.state.parsedName,
|
tmpName: this.state.parsedName,
|
||||||
tmpFirstname: this.state.parsedFirstname,
|
tmpFirstname: this.state.parsedFirstname,
|
||||||
tmpEmail: this.state.parsedEmail,
|
tmpEmail: this.state.parsedEmail,
|
||||||
|
|
@ -823,7 +1091,8 @@ class ContactDetailsScreen extends React.Component {
|
||||||
parsedPhone: '',
|
parsedPhone: '',
|
||||||
showDynContact: false,
|
showDynContact: false,
|
||||||
scanned: false,
|
scanned: false,
|
||||||
})}
|
})
|
||||||
|
}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
|
import { Picker } from '@react-native-picker/picker';
|
||||||
|
import { ButtonGroup, CheckBox, Overlay } from '@rneui/themed';
|
||||||
|
import { BarCodeScanner } from 'expo-barcode-scanner';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import {
|
||||||
View,
|
Alert,
|
||||||
StyleSheet,
|
|
||||||
Button,
|
Button,
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
Text,
|
||||||
TextInput,
|
TextInput,
|
||||||
TouchableOpacity,
|
TouchableOpacity,
|
||||||
Text,
|
View,
|
||||||
Alert,
|
|
||||||
ScrollView
|
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { CheckBox, ButtonGroup, Overlay } from '@rneui/themed';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
||||||
import { showMessage } from 'react-native-flash-message';
|
import { showMessage } from 'react-native-flash-message';
|
||||||
import Helpers from "../Controllers/Helpers";
|
import Icon from 'react-native-vector-icons/FontAwesome';
|
||||||
import i18n from "../I18n";
|
import { connect } from 'react-redux';
|
||||||
import { BarCodeScanner } from 'expo-barcode-scanner';
|
|
||||||
import vCard from 'vcard-parser';
|
import vCard from 'vcard-parser';
|
||||||
import { Picker } from '@react-native-picker/picker';
|
import Helpers from '../Controllers/Helpers';
|
||||||
|
import i18n from '../I18n';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -79,7 +79,7 @@ class ContactDetailsScreen extends React.Component {
|
||||||
parsedEmail: '',
|
parsedEmail: '',
|
||||||
parsedCompany: '',
|
parsedCompany: '',
|
||||||
parsedAddress: '',
|
parsedAddress: '',
|
||||||
parsedPhone: ''
|
parsedPhone: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
updateContact() {
|
updateContact() {
|
||||||
|
|
@ -87,9 +87,8 @@ class ContactDetailsScreen extends React.Component {
|
||||||
const { action } = this.props.route.params;
|
const { action } = this.props.route.params;
|
||||||
// On récupère le texte courant
|
// On récupère le texte courant
|
||||||
if (this.state.visits.length > 0) {
|
if (this.state.visits.length > 0) {
|
||||||
this.state.visits[
|
this.state.visits[this.state.selectedVisit].note =
|
||||||
this.state.selectedVisit
|
this.state.tmpVisitNote;
|
||||||
].note = this.state.tmpVisitNote;
|
|
||||||
}
|
}
|
||||||
let type;
|
let type;
|
||||||
if (this.state.clientChecked === true) {
|
if (this.state.clientChecked === true) {
|
||||||
|
|
@ -104,7 +103,10 @@ class ContactDetailsScreen extends React.Component {
|
||||||
} else {
|
} else {
|
||||||
error = error.concat(i18n.t('error.specify_type_contact') + '.\n');
|
error = error.concat(i18n.t('error.specify_type_contact') + '.\n');
|
||||||
}
|
}
|
||||||
if (this.state.tmpEmail.length < 5 || !Helpers.isEmailValid(this.state.tmpEmail)) {
|
if (
|
||||||
|
this.state.tmpEmail.length < 5 ||
|
||||||
|
!Helpers.isEmailValid(this.state.tmpEmail)
|
||||||
|
) {
|
||||||
error = error.concat(i18n.t('error.invalid_email_address') + '.\n');
|
error = error.concat(i18n.t('error.invalid_email_address') + '.\n');
|
||||||
}
|
}
|
||||||
if (this.state.tmpName.length === 0) {
|
if (this.state.tmpName.length === 0) {
|
||||||
|
|
@ -115,11 +117,9 @@ class ContactDetailsScreen extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error.length > 0) {
|
if (error.length > 0) {
|
||||||
Alert.alert(i18n.t('global.warning') + ' !', error, [
|
Alert.alert(i18n.t('global.warning') + ' !', error, [{ text: 'OK' }], {
|
||||||
{ text: 'OK' },
|
cancelable: false,
|
||||||
],
|
});
|
||||||
{ cancelable: false },
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
const products = [
|
const products = [
|
||||||
this.state.p1,
|
this.state.p1,
|
||||||
|
|
@ -130,7 +130,7 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.state.p6,
|
this.state.p6,
|
||||||
this.state.p7,
|
this.state.p7,
|
||||||
this.state.p8,
|
this.state.p8,
|
||||||
this.state.p9
|
this.state.p9,
|
||||||
];
|
];
|
||||||
const contact = {
|
const contact = {
|
||||||
id: Helpers.generateUUID(),
|
id: Helpers.generateUUID(),
|
||||||
|
|
@ -294,7 +294,6 @@ class ContactDetailsScreen extends React.Component {
|
||||||
BarCodeScanner.requestPermissionsAsync().then(res => {
|
BarCodeScanner.requestPermissionsAsync().then(res => {
|
||||||
this.setState({ hasPermission: res.status === 'granted' });
|
this.setState({ hasPermission: res.status === 'granted' });
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
@ -303,12 +302,15 @@ class ContactDetailsScreen extends React.Component {
|
||||||
if (data.includes('VCARD')) {
|
if (data.includes('VCARD')) {
|
||||||
let datas = vCard.parse(data);
|
let datas = vCard.parse(data);
|
||||||
let tmpDatas = [];
|
let tmpDatas = [];
|
||||||
if (datas['n'] !== undefined) {
|
if (datas.n !== undefined) {
|
||||||
const nx = Object.assign({ n1: [{ value: datas['n'][0].value[0] }] }, { n2: [{ value: datas['n'][0].value[1] }] });
|
const nx = Object.assign(
|
||||||
|
{ n1: [{ value: datas.n[0].value[0] }] },
|
||||||
|
{ n2: [{ value: datas.n[0].value[1] }] },
|
||||||
|
);
|
||||||
datas = Object.assign(datas, nx);
|
datas = Object.assign(datas, nx);
|
||||||
}
|
}
|
||||||
if (datas['adr'] !== undefined) {
|
if (datas.adr !== undefined) {
|
||||||
let tmp = datas['adr'][0].value;
|
let tmp = datas.adr[0].value;
|
||||||
let tmpadr = '';
|
let tmpadr = '';
|
||||||
for (let i = 0; i < tmp.length; i++) {
|
for (let i = 0; i < tmp.length; i++) {
|
||||||
if (tmp[i].length > 0) {
|
if (tmp[i].length > 0) {
|
||||||
|
|
@ -319,17 +321,29 @@ class ContactDetailsScreen extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
datas['adr'] = [{ value: tmpadr }];
|
datas.adr = [{ value: tmpadr }];
|
||||||
}
|
}
|
||||||
Object.keys(datas).map((objectKey, index) => {
|
Object.keys(datas).map((objectKey, index) => {
|
||||||
if (objectKey === 'email' || objectKey === 'adr' || objectKey === 'tel' || objectKey === 'org' || objectKey === 'n1' || objectKey === 'n2') {
|
if (
|
||||||
|
objectKey === 'email' ||
|
||||||
|
objectKey === 'adr' ||
|
||||||
|
objectKey === 'tel' ||
|
||||||
|
objectKey === 'org' ||
|
||||||
|
objectKey === 'n1' ||
|
||||||
|
objectKey === 'n2'
|
||||||
|
) {
|
||||||
let value = datas[objectKey][0].value;
|
let value = datas[objectKey][0].value;
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
tmpDatas.push(value);
|
tmpDatas.push(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.setState({ parsedType: 'vcard', parsedDatas: tmpDatas, showQRcodevCard: false, showDynContact: true })
|
this.setState({
|
||||||
|
parsedType: 'vcard',
|
||||||
|
parsedDatas: tmpDatas,
|
||||||
|
showQRcodevCard: false,
|
||||||
|
showDynContact: true,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(i18n.t('contact_details_s.qrcode_not_vcard_format'));
|
Alert.alert(i18n.t('contact_details_s.qrcode_not_vcard_format'));
|
||||||
}
|
}
|
||||||
|
|
@ -389,22 +403,41 @@ class ContactDetailsScreen extends React.Component {
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row' }}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={{ backgroundColor: 'white', margin: 10, padding: 10, flex: 1 }}
|
style={{
|
||||||
|
backgroundColor: 'white',
|
||||||
|
margin: 10,
|
||||||
|
padding: 10,
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
value={this.state.tmpName}
|
value={this.state.tmpName}
|
||||||
placeholder={i18n.t('global.name') + ' (' + i18n.t('global.required') + ')'}
|
placeholder={
|
||||||
|
i18n.t('global.name') + ' (' + i18n.t('global.required') + ')'
|
||||||
|
}
|
||||||
onChangeText={text => this.setState({ tmpName: text })}
|
onChangeText={text => this.setState({ tmpName: text })}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={{ backgroundColor: 'white', margin: 10, padding: 10, flex: 1 }}
|
style={{
|
||||||
|
backgroundColor: 'white',
|
||||||
|
margin: 10,
|
||||||
|
padding: 10,
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
value={this.state.tmpFirstname}
|
value={this.state.tmpFirstname}
|
||||||
placeholder={i18n.t('global.firstname') + ' (' + i18n.t('global.required') + ')'}
|
placeholder={
|
||||||
|
i18n.t('global.firstname') +
|
||||||
|
' (' +
|
||||||
|
i18n.t('global.required') +
|
||||||
|
')'
|
||||||
|
}
|
||||||
onChangeText={text => this.setState({ tmpFirstname: text })}
|
onChangeText={text => this.setState({ tmpFirstname: text })}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={styles.input}
|
||||||
value={this.state.tmpEmail}
|
value={this.state.tmpEmail}
|
||||||
placeholder={i18n.t('global.email') + ' (' + i18n.t('global.required') + ')'}
|
placeholder={
|
||||||
|
i18n.t('global.email') + ' (' + i18n.t('global.required') + ')'
|
||||||
|
}
|
||||||
onChangeText={text => this.setState({ tmpEmail: text })}
|
onChangeText={text => this.setState({ tmpEmail: text })}
|
||||||
autoCapitalize={'none'}
|
autoCapitalize={'none'}
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
|
|
@ -433,7 +466,12 @@ class ContactDetailsScreen extends React.Component {
|
||||||
/>
|
/>
|
||||||
<View style={{ flexDirection: 'row' }}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
<View style={{ flex: 1, flexDirection: 'row' }}>
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||||
<Icon name="sort-down" size={20} color={'black'} style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }} />
|
<Icon
|
||||||
|
name="sort-down"
|
||||||
|
size={20}
|
||||||
|
color={'black'}
|
||||||
|
style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }}
|
||||||
|
/>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.tmpSelect1}
|
selectedValue={this.state.tmpSelect1}
|
||||||
style={styles.select}
|
style={styles.select}
|
||||||
|
|
@ -442,33 +480,107 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ tmpSelect1: itemValue });
|
this.setState({ tmpSelect1: itemValue });
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.title')} value="0" />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c1')} value="commerce-de-detail" />
|
label={i18n.t('custom.select-1.title')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c2')} value={'home-service-freezer-center'} />
|
value="0"
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c3')} value={'restauration-service-a-table'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c4')} value={'fast-food-et-snacking'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c5')} value={'cafetaria-self-service'} />
|
label={i18n.t('custom.select-1.c1')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c6')} value={'societe-de-restauration'} />
|
value="commerce-de-detail"
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c7')} value={'restauration-gre-a-gre-cuisine-centrale'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c8')} value={'distributeur-independant'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c9')} value={'boulangerie-patisserie'} />
|
label={i18n.t('custom.select-1.c2')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c10')} value={'pai'} />
|
value={'home-service-freezer-center'}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c11')} value={'destockeur'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c12')} value={'commerce-halal'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c13')} value={'restauration-d-hebergement'} />
|
label={i18n.t('custom.select-1.c3')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c14')} value={'centrale-restauration-commerciale'} />
|
value={'restauration-service-a-table'}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c15')} value={'restauration-evenementielle-et-parc'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c16')} value={'restauration-de-transport'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c17')} value={'marche-public'} />
|
label={i18n.t('custom.select-1.c4')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c18')} value={'cash'} />
|
value={'fast-food-et-snacking'}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c19')} value={'distributeur-national'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c20')} value={'rungis'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c21')} value={'abbatoir'} />
|
label={i18n.t('custom.select-1.c5')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c22')} value={'autre'} />
|
value={'cafetaria-self-service'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c6')}
|
||||||
|
value={'societe-de-restauration'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c7')}
|
||||||
|
value={'restauration-gre-a-gre-cuisine-centrale'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c8')}
|
||||||
|
value={'distributeur-independant'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c9')}
|
||||||
|
value={'boulangerie-patisserie'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c10')}
|
||||||
|
value={'pai'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c11')}
|
||||||
|
value={'destockeur'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c12')}
|
||||||
|
value={'commerce-halal'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c13')}
|
||||||
|
value={'restauration-d-hebergement'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c14')}
|
||||||
|
value={'centrale-restauration-commerciale'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c15')}
|
||||||
|
value={'restauration-evenementielle-et-parc'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c16')}
|
||||||
|
value={'restauration-de-transport'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c17')}
|
||||||
|
value={'marche-public'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c18')}
|
||||||
|
value={'cash'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c19')}
|
||||||
|
value={'distributeur-national'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c20')}
|
||||||
|
value={'rungis'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c21')}
|
||||||
|
value={'abbatoir'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c22')}
|
||||||
|
value={'autre'}
|
||||||
|
/>
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flex: 1, flexDirection: 'row' }}>
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||||
<Icon name="sort-down" size={20} color={'black'} style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }} />
|
<Icon
|
||||||
|
name="sort-down"
|
||||||
|
size={20}
|
||||||
|
color={'black'}
|
||||||
|
style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }}
|
||||||
|
/>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.tmpSelect2}
|
selectedValue={this.state.tmpSelect2}
|
||||||
style={styles.select}
|
style={styles.select}
|
||||||
|
|
@ -477,19 +589,58 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ tmpSelect2: itemValue });
|
this.setState({ tmpSelect2: itemValue });
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Picker.Item label={i18n.t('custom.select-2.title')} value="0" />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c1')} value={'celvia-dinde'} />
|
label={i18n.t('custom.select-2.title')}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c2')} value={'celvia-elabores'} />
|
value="0"
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c3')} value={'celvia-serent'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c4')} value={'procanar'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c5')} value={'celtys'} />
|
label={i18n.t('custom.select-2.c1')}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c6')} value={'farmor'} />
|
value={'celvia-dinde'}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c7')} value={'robichon'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c8')} value={'les-volailles-de-keranna'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c9')} value={'bosher-volaille'} />
|
label={i18n.t('custom.select-2.c2')}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c10')} value={'ldc-bretagne'} />
|
value={'celvia-elabores'}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c11')} value={'doux-farmor'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c12')} value={'favreau'} />
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c3')}
|
||||||
|
value={'celvia-serent'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c4')}
|
||||||
|
value={'procanar'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c5')}
|
||||||
|
value={'celtys'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c6')}
|
||||||
|
value={'farmor'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c7')}
|
||||||
|
value={'robichon'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c8')}
|
||||||
|
value={'les-volailles-de-keranna'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c9')}
|
||||||
|
value={'bosher-volaille'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c10')}
|
||||||
|
value={'ldc-bretagne'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c11')}
|
||||||
|
value={'doux-farmor'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c12')}
|
||||||
|
value={'favreau'}
|
||||||
|
/>
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -532,7 +683,10 @@ class ContactDetailsScreen extends React.Component {
|
||||||
<View style={{ flex: 1, margin: 5 }}>
|
<View style={{ flex: 1, margin: 5 }}>
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
buttons={[i18n.t('contact_details_s.visits'), i18n.t('contact_details_s.notes')]}
|
buttons={[
|
||||||
|
i18n.t('contact_details_s.visits'),
|
||||||
|
i18n.t('contact_details_s.notes'),
|
||||||
|
]}
|
||||||
selectedButtonStyle={{ backgroundColor: '#ea4f52' }}
|
selectedButtonStyle={{ backgroundColor: '#ea4f52' }}
|
||||||
containerStyle={{ height: 30 }}
|
containerStyle={{ height: 30 }}
|
||||||
selectedIndex={this.state.selectedIndex}
|
selectedIndex={this.state.selectedIndex}
|
||||||
|
|
@ -543,14 +697,23 @@ class ContactDetailsScreen extends React.Component {
|
||||||
<View style={{ flexDirection: 'row' }}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
{this.state.visits.length > 0 && (
|
{this.state.visits.length > 0 && (
|
||||||
<View style={{ flex: 2, flexDirection: 'row' }}>
|
<View style={{ flex: 2, flexDirection: 'row' }}>
|
||||||
<Icon name="sort-down" size={20} color={'black'} style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }} />
|
<Icon
|
||||||
|
name="sort-down"
|
||||||
|
size={20}
|
||||||
|
color={'black'}
|
||||||
|
style={{
|
||||||
|
zIndex: 1,
|
||||||
|
position: 'absolute',
|
||||||
|
right: 25,
|
||||||
|
top: 20,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Picker
|
<Picker
|
||||||
style={styles.select}
|
style={styles.select}
|
||||||
selectedValue={this.state.selectedVisit}
|
selectedValue={this.state.selectedVisit}
|
||||||
onValueChange={(itemValue, itemIndex) => {
|
onValueChange={(itemValue, itemIndex) => {
|
||||||
this.state.visits[
|
this.state.visits[this.state.selectedVisit].note =
|
||||||
this.state.selectedVisit
|
this.state.tmpVisitNote;
|
||||||
].note = this.state.tmpVisitNote;
|
|
||||||
this.setState({
|
this.setState({
|
||||||
visits: this.state.visits,
|
visits: this.state.visits,
|
||||||
selectedVisit: itemIndex,
|
selectedVisit: itemIndex,
|
||||||
|
|
@ -558,7 +721,9 @@ class ContactDetailsScreen extends React.Component {
|
||||||
});
|
});
|
||||||
}}>
|
}}>
|
||||||
{this.state.visits.map((item, index) => {
|
{this.state.visits.map((item, index) => {
|
||||||
return <Picker.Item label={item.title} value={index} />;
|
return (
|
||||||
|
<Picker.Item label={item.title} value={index} />
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -621,13 +786,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', justifyContent: 'space-evenly' }}>
|
<View
|
||||||
|
style={{ flexDirection: 'row', justifyContent: 'space-evenly' }}>
|
||||||
{this.state.action === 'add' && (
|
{this.state.action === 'add' && (
|
||||||
<>
|
<>
|
||||||
<Button title="QRCode vCard" onPress={() => this.setState({ showQRcodevCard: true })} color={'#ea4f52'} />
|
<Button
|
||||||
|
title="QRCode vCard"
|
||||||
|
onPress={() => this.setState({ showQRcodevCard: true })}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Button title={i18n.t('global.save')} onPress={() => this.updateContact()} color={'#ea4f52'} />
|
<Button
|
||||||
|
title={i18n.t('global.save')}
|
||||||
|
onPress={() => this.updateContact()}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<Overlay
|
<Overlay
|
||||||
|
|
@ -638,7 +812,9 @@ class ContactDetailsScreen extends React.Component {
|
||||||
height={300}>
|
height={300}>
|
||||||
<View
|
<View
|
||||||
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||||
<Text style={{ marginBottom: 10 }}>{i18n.t('contact_details_s.visit_name')} :</Text>
|
<Text style={{ marginBottom: 10 }}>
|
||||||
|
{i18n.t('contact_details_s.visit_name')} :
|
||||||
|
</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={i18n.t('contact_details_s.visit_name')}
|
placeholder={i18n.t('contact_details_s.visit_name')}
|
||||||
value={this.state.newVisitTitle}
|
value={this.state.newVisitTitle}
|
||||||
|
|
@ -663,7 +839,11 @@ class ContactDetailsScreen extends React.Component {
|
||||||
onPress={() => this.setState({ showNewVisit: false })}
|
onPress={() => this.setState({ showNewVisit: false })}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
<Button title={i18n.t('global.add')} onPress={() => this.newVisit()} color={'#ea4f52'} />
|
<Button
|
||||||
|
title={i18n.t('global.add')}
|
||||||
|
onPress={() => this.newVisit()}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
|
|
@ -673,10 +853,13 @@ class ContactDetailsScreen extends React.Component {
|
||||||
overlayBackgroundColor="white"
|
overlayBackgroundColor="white"
|
||||||
width={400}
|
width={400}
|
||||||
height={300}>
|
height={300}>
|
||||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
<View
|
||||||
|
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||||
{this.state.hasPermission === true && (
|
{this.state.hasPermission === true && (
|
||||||
<BarCodeScanner
|
<BarCodeScanner
|
||||||
onBarCodeScanned={this.state.scanned ? undefined : handleBarCodeScanned}
|
onBarCodeScanned={
|
||||||
|
this.state.scanned ? undefined : handleBarCodeScanned
|
||||||
|
}
|
||||||
barCodeTypes={[BarCodeScanner.Constants.BarCodeType.qr]}
|
barCodeTypes={[BarCodeScanner.Constants.BarCodeType.qr]}
|
||||||
style={{ flex: 1, width: 380, height: 200 }}
|
style={{ flex: 1, width: 380, height: 200 }}
|
||||||
/>
|
/>
|
||||||
|
|
@ -696,10 +879,18 @@ class ContactDetailsScreen extends React.Component {
|
||||||
}}>
|
}}>
|
||||||
<Button
|
<Button
|
||||||
title={i18n.t('global.cancel')}
|
title={i18n.t('global.cancel')}
|
||||||
onPress={() => this.setState({ showQRcodevCard: false, scanned: false })}
|
onPress={() =>
|
||||||
|
this.setState({ showQRcodevCard: false, scanned: false })
|
||||||
|
}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
{this.state.scanned && <Button title={i18n.t('global.retry')} onPress={() => this.setState({ scanned: false })} color={'#ea4f52'} />}
|
{this.state.scanned && (
|
||||||
|
<Button
|
||||||
|
title={i18n.t('global.retry')}
|
||||||
|
onPress={() => this.setState({ scanned: false })}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
|
|
@ -709,9 +900,16 @@ class ContactDetailsScreen extends React.Component {
|
||||||
overlayBackgroundColor="white"
|
overlayBackgroundColor="white"
|
||||||
width={400}
|
width={400}
|
||||||
height={400}>
|
height={400}>
|
||||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'space-evenly' }}>
|
<View
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-evenly',
|
||||||
|
}}>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.name')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.name')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedName}
|
selectedValue={this.state.parsedName}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -719,13 +917,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedName: itemValue });
|
this.setState({ parsedName: itemValue });
|
||||||
}}>
|
}}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.firstname')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.firstname')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedFirstname}
|
selectedValue={this.state.parsedFirstname}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -733,13 +940,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedFirstname: itemValue })
|
this.setState({ parsedFirstname: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.email')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.email')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedEmail}
|
selectedValue={this.state.parsedEmail}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -747,13 +963,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedEmail: itemValue })
|
this.setState({ parsedEmail: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.company')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.company')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedCompany}
|
selectedValue={this.state.parsedCompany}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -761,13 +986,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedCompany: itemValue })
|
this.setState({ parsedCompany: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.address')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.address')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedAddress}
|
selectedValue={this.state.parsedAddress}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -775,13 +1009,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedAddress: itemValue })
|
this.setState({ parsedAddress: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.phone')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.phone')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedPhone}
|
selectedValue={this.state.parsedPhone}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -789,8 +1032,15 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedPhone: itemValue })
|
this.setState({ parsedPhone: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -803,12 +1053,24 @@ class ContactDetailsScreen extends React.Component {
|
||||||
}}>
|
}}>
|
||||||
<Button
|
<Button
|
||||||
title={i18n.t('global.cancel')}
|
title={i18n.t('global.cancel')}
|
||||||
onPress={() => this.setState({ showDynContact: false, scanned: false, parsedName: '', parsedFirstname: '', parsedEmail: '', parsedCompany: '', parsedAddress: '', parsedPhone: '' })}
|
onPress={() =>
|
||||||
|
this.setState({
|
||||||
|
showDynContact: false,
|
||||||
|
scanned: false,
|
||||||
|
parsedName: '',
|
||||||
|
parsedFirstname: '',
|
||||||
|
parsedEmail: '',
|
||||||
|
parsedCompany: '',
|
||||||
|
parsedAddress: '',
|
||||||
|
parsedPhone: '',
|
||||||
|
})
|
||||||
|
}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
title={i18n.t('global.next')}
|
title={i18n.t('global.next')}
|
||||||
onPress={() => this.setState({
|
onPress={() =>
|
||||||
|
this.setState({
|
||||||
tmpName: this.state.parsedName,
|
tmpName: this.state.parsedName,
|
||||||
tmpFirstname: this.state.parsedFirstname,
|
tmpFirstname: this.state.parsedFirstname,
|
||||||
tmpEmail: this.state.parsedEmail,
|
tmpEmail: this.state.parsedEmail,
|
||||||
|
|
@ -823,7 +1085,8 @@ class ContactDetailsScreen extends React.Component {
|
||||||
parsedPhone: '',
|
parsedPhone: '',
|
||||||
showDynContact: false,
|
showDynContact: false,
|
||||||
scanned: false,
|
scanned: false,
|
||||||
})}
|
})
|
||||||
|
}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,23 @@
|
||||||
|
import { ButtonGroup, CheckBox, Overlay } from '@rneui/themed';
|
||||||
|
import { BarCodeScanner } from 'expo-barcode-scanner';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import {
|
import {
|
||||||
View,
|
|
||||||
StyleSheet,
|
|
||||||
Button,
|
|
||||||
TextInput,
|
|
||||||
Picker,
|
|
||||||
TouchableOpacity,
|
|
||||||
Text,
|
|
||||||
Alert,
|
Alert,
|
||||||
ScrollView
|
Button,
|
||||||
|
Picker,
|
||||||
|
ScrollView,
|
||||||
|
StyleSheet,
|
||||||
|
Text,
|
||||||
|
TextInput,
|
||||||
|
TouchableOpacity,
|
||||||
|
View,
|
||||||
} from 'react-native';
|
} from 'react-native';
|
||||||
import { CheckBox, ButtonGroup, Overlay } from '@rneui/themed';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
import Icon from 'react-native-vector-icons/FontAwesome';
|
|
||||||
import { showMessage } from 'react-native-flash-message';
|
import { showMessage } from 'react-native-flash-message';
|
||||||
import Helpers from "../Controllers/Helpers";
|
import Icon from 'react-native-vector-icons/FontAwesome';
|
||||||
import i18n from "../I18n";
|
import { connect } from 'react-redux';
|
||||||
import { BarCodeScanner } from 'expo-barcode-scanner';
|
|
||||||
import vCard from 'vcard-parser';
|
import vCard from 'vcard-parser';
|
||||||
|
import Helpers from '../Controllers/Helpers';
|
||||||
|
import i18n from '../I18n';
|
||||||
|
|
||||||
function mapStateToProps(state) {
|
function mapStateToProps(state) {
|
||||||
return {
|
return {
|
||||||
|
|
@ -79,7 +79,7 @@ class ContactDetailsScreen extends React.Component {
|
||||||
parsedEmail: '',
|
parsedEmail: '',
|
||||||
parsedCompany: '',
|
parsedCompany: '',
|
||||||
parsedAddress: '',
|
parsedAddress: '',
|
||||||
parsedPhone: ''
|
parsedPhone: '',
|
||||||
};
|
};
|
||||||
|
|
||||||
updateContact() {
|
updateContact() {
|
||||||
|
|
@ -87,9 +87,8 @@ class ContactDetailsScreen extends React.Component {
|
||||||
const { action } = this.props.route.params;
|
const { action } = this.props.route.params;
|
||||||
// On récupère le texte courant
|
// On récupère le texte courant
|
||||||
if (this.state.visits.length > 0) {
|
if (this.state.visits.length > 0) {
|
||||||
this.state.visits[
|
this.state.visits[this.state.selectedVisit].note =
|
||||||
this.state.selectedVisit
|
this.state.tmpVisitNote;
|
||||||
].note = this.state.tmpVisitNote;
|
|
||||||
}
|
}
|
||||||
let type;
|
let type;
|
||||||
if (this.state.clientChecked === true) {
|
if (this.state.clientChecked === true) {
|
||||||
|
|
@ -104,7 +103,10 @@ class ContactDetailsScreen extends React.Component {
|
||||||
} else {
|
} else {
|
||||||
error = error.concat(i18n.t('error.specify_type_contact') + '.\n');
|
error = error.concat(i18n.t('error.specify_type_contact') + '.\n');
|
||||||
}
|
}
|
||||||
if (this.state.tmpEmail.length < 5 || !Helpers.isEmailValid(this.state.tmpEmail)) {
|
if (
|
||||||
|
this.state.tmpEmail.length < 5 ||
|
||||||
|
!Helpers.isEmailValid(this.state.tmpEmail)
|
||||||
|
) {
|
||||||
error = error.concat(i18n.t('error.invalid_email_address') + '.\n');
|
error = error.concat(i18n.t('error.invalid_email_address') + '.\n');
|
||||||
}
|
}
|
||||||
if (this.state.tmpName.length === 0) {
|
if (this.state.tmpName.length === 0) {
|
||||||
|
|
@ -115,11 +117,9 @@ class ContactDetailsScreen extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error.length > 0) {
|
if (error.length > 0) {
|
||||||
Alert.alert(i18n.t('global.warning') + ' !', error, [
|
Alert.alert(i18n.t('global.warning') + ' !', error, [{ text: 'OK' }], {
|
||||||
{ text: 'OK' },
|
cancelable: false,
|
||||||
],
|
});
|
||||||
{ cancelable: false },
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
const products = [
|
const products = [
|
||||||
this.state.p1,
|
this.state.p1,
|
||||||
|
|
@ -130,7 +130,7 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.state.p6,
|
this.state.p6,
|
||||||
this.state.p7,
|
this.state.p7,
|
||||||
this.state.p8,
|
this.state.p8,
|
||||||
this.state.p9
|
this.state.p9,
|
||||||
];
|
];
|
||||||
const contact = {
|
const contact = {
|
||||||
id: Helpers.generateUUID(),
|
id: Helpers.generateUUID(),
|
||||||
|
|
@ -278,7 +278,7 @@ class ContactDetailsScreen extends React.Component {
|
||||||
p6: tmp[5],
|
p6: tmp[5],
|
||||||
p7: tmp[6],
|
p7: tmp[6],
|
||||||
p8: tmp[7],
|
p8: tmp[7],
|
||||||
p9: tmp[8]
|
p9: tmp[8],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -293,7 +293,6 @@ class ContactDetailsScreen extends React.Component {
|
||||||
BarCodeScanner.requestPermissionsAsync().then(res => {
|
BarCodeScanner.requestPermissionsAsync().then(res => {
|
||||||
this.setState({ hasPermission: res.status === 'granted' });
|
this.setState({ hasPermission: res.status === 'granted' });
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
@ -302,12 +301,15 @@ class ContactDetailsScreen extends React.Component {
|
||||||
if (data.includes('VCARD')) {
|
if (data.includes('VCARD')) {
|
||||||
let datas = vCard.parse(data);
|
let datas = vCard.parse(data);
|
||||||
let tmpDatas = [];
|
let tmpDatas = [];
|
||||||
if (datas['n'] !== undefined) {
|
if (datas.n !== undefined) {
|
||||||
const nx = Object.assign({ n1: [{ value: datas['n'][0].value[0] }] }, { n2: [{ value: datas['n'][0].value[1] }] });
|
const nx = Object.assign(
|
||||||
|
{ n1: [{ value: datas.n[0].value[0] }] },
|
||||||
|
{ n2: [{ value: datas.n[0].value[1] }] },
|
||||||
|
);
|
||||||
datas = Object.assign(datas, nx);
|
datas = Object.assign(datas, nx);
|
||||||
}
|
}
|
||||||
if (datas['adr'] !== undefined) {
|
if (datas.adr !== undefined) {
|
||||||
let tmp = datas['adr'][0].value;
|
let tmp = datas.adr[0].value;
|
||||||
let tmpadr = '';
|
let tmpadr = '';
|
||||||
for (let i = 0; i < tmp.length; i++) {
|
for (let i = 0; i < tmp.length; i++) {
|
||||||
if (tmp[i].length > 0) {
|
if (tmp[i].length > 0) {
|
||||||
|
|
@ -318,17 +320,29 @@ class ContactDetailsScreen extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
datas['adr'] = [{ value: tmpadr }];
|
datas.adr = [{ value: tmpadr }];
|
||||||
}
|
}
|
||||||
Object.keys(datas).map((objectKey, index) => {
|
Object.keys(datas).map((objectKey, index) => {
|
||||||
if (objectKey === 'email' || objectKey === 'adr' || objectKey === 'tel' || objectKey === 'org' || objectKey === 'n1' || objectKey === 'n2') {
|
if (
|
||||||
|
objectKey === 'email' ||
|
||||||
|
objectKey === 'adr' ||
|
||||||
|
objectKey === 'tel' ||
|
||||||
|
objectKey === 'org' ||
|
||||||
|
objectKey === 'n1' ||
|
||||||
|
objectKey === 'n2'
|
||||||
|
) {
|
||||||
let value = datas[objectKey][0].value;
|
let value = datas[objectKey][0].value;
|
||||||
if (typeof value === 'string') {
|
if (typeof value === 'string') {
|
||||||
tmpDatas.push(value);
|
tmpDatas.push(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
this.setState({ parsedType: 'vcard', parsedDatas: tmpDatas, showQRcodevCard: false, showDynContact: true })
|
this.setState({
|
||||||
|
parsedType: 'vcard',
|
||||||
|
parsedDatas: tmpDatas,
|
||||||
|
showQRcodevCard: false,
|
||||||
|
showDynContact: true,
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
Alert.alert(i18n.t('contact_details_s.qrcode_not_vcard_format'));
|
Alert.alert(i18n.t('contact_details_s.qrcode_not_vcard_format'));
|
||||||
}
|
}
|
||||||
|
|
@ -388,22 +402,41 @@ class ContactDetailsScreen extends React.Component {
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row' }}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={{ backgroundColor: 'white', margin: 10, padding: 10, flex: 1 }}
|
style={{
|
||||||
|
backgroundColor: 'white',
|
||||||
|
margin: 10,
|
||||||
|
padding: 10,
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
value={this.state.tmpName}
|
value={this.state.tmpName}
|
||||||
placeholder={i18n.t('global.name') + ' (' + i18n.t('global.required') + ')'}
|
placeholder={
|
||||||
|
i18n.t('global.name') + ' (' + i18n.t('global.required') + ')'
|
||||||
|
}
|
||||||
onChangeText={text => this.setState({ tmpName: text })}
|
onChangeText={text => this.setState({ tmpName: text })}
|
||||||
/>
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={{ backgroundColor: 'white', margin: 10, padding: 10, flex: 1 }}
|
style={{
|
||||||
|
backgroundColor: 'white',
|
||||||
|
margin: 10,
|
||||||
|
padding: 10,
|
||||||
|
flex: 1,
|
||||||
|
}}
|
||||||
value={this.state.tmpFirstname}
|
value={this.state.tmpFirstname}
|
||||||
placeholder={i18n.t('global.firstname') + ' (' + i18n.t('global.required') + ')'}
|
placeholder={
|
||||||
|
i18n.t('global.firstname') +
|
||||||
|
' (' +
|
||||||
|
i18n.t('global.required') +
|
||||||
|
')'
|
||||||
|
}
|
||||||
onChangeText={text => this.setState({ tmpFirstname: text })}
|
onChangeText={text => this.setState({ tmpFirstname: text })}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
<TextInput
|
<TextInput
|
||||||
style={styles.input}
|
style={styles.input}
|
||||||
value={this.state.tmpEmail}
|
value={this.state.tmpEmail}
|
||||||
placeholder={i18n.t('global.email') + ' (' + i18n.t('global.required') + ')'}
|
placeholder={
|
||||||
|
i18n.t('global.email') + ' (' + i18n.t('global.required') + ')'
|
||||||
|
}
|
||||||
onChangeText={text => this.setState({ tmpEmail: text })}
|
onChangeText={text => this.setState({ tmpEmail: text })}
|
||||||
autoCapitalize={'none'}
|
autoCapitalize={'none'}
|
||||||
autoCorrect={false}
|
autoCorrect={false}
|
||||||
|
|
@ -432,7 +465,12 @@ class ContactDetailsScreen extends React.Component {
|
||||||
/>
|
/>
|
||||||
<View style={{ flexDirection: 'row' }}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
<View style={{ flex: 1, flexDirection: 'row' }}>
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||||
<Icon name="sort-down" size={20} color={'black'} style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }} />
|
<Icon
|
||||||
|
name="sort-down"
|
||||||
|
size={20}
|
||||||
|
color={'black'}
|
||||||
|
style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }}
|
||||||
|
/>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.tmpSelect1}
|
selectedValue={this.state.tmpSelect1}
|
||||||
style={styles.select}
|
style={styles.select}
|
||||||
|
|
@ -441,19 +479,51 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ tmpSelect1: itemValue });
|
this.setState({ tmpSelect1: itemValue });
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.title')} value="0" />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c1')} value={'pole-sable'} />
|
label={i18n.t('custom.select-1.title')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c2')} value={'snv'} />
|
value="0"
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c3')} value={'pole-sud-est'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c4')} value={'aquitaine'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c5')} value={'sbv'} />
|
label={i18n.t('custom.select-1.c1')}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c6')} value={'arrive'} />
|
value={'pole-sable'}
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c7')} value={'plusieurs-filiales'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-1.c8')} value={'autre'} />
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c2')}
|
||||||
|
value={'snv'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c3')}
|
||||||
|
value={'pole-sud-est'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c4')}
|
||||||
|
value={'aquitaine'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c5')}
|
||||||
|
value={'sbv'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c6')}
|
||||||
|
value={'arrive'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c7')}
|
||||||
|
value={'plusieurs-filiales'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-1.c8')}
|
||||||
|
value={'autre'}
|
||||||
|
/>
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flex: 1, flexDirection: 'row' }}>
|
<View style={{ flex: 1, flexDirection: 'row' }}>
|
||||||
<Icon name="sort-down" size={20} color={'black'} style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }} />
|
<Icon
|
||||||
|
name="sort-down"
|
||||||
|
size={20}
|
||||||
|
color={'black'}
|
||||||
|
style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }}
|
||||||
|
/>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.tmpSelect2}
|
selectedValue={this.state.tmpSelect2}
|
||||||
style={styles.select}
|
style={styles.select}
|
||||||
|
|
@ -462,14 +532,38 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ tmpSelect2: itemValue });
|
this.setState({ tmpSelect2: itemValue });
|
||||||
}
|
}
|
||||||
}}>
|
}}>
|
||||||
<Picker.Item label={i18n.t('custom.select-2.title')} value="0" />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c1')} value={'commerce-de-detail'} />
|
label={i18n.t('custom.select-2.title')}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c2')} value={'restauration-commerciale'} />
|
value="0"
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c3')} value={'restauration-collective'} />
|
/>
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c4')} value={'grossiste-distributeur-cash'} />
|
<Picker.Item
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c5')} value={'pai'} />
|
label={i18n.t('custom.select-2.c1')}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c6')} value={'home-freezer-center'} />
|
value={'commerce-de-detail'}
|
||||||
<Picker.Item label={i18n.t('custom.select-2.c7')} value={'autres'} />
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c2')}
|
||||||
|
value={'restauration-commerciale'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c3')}
|
||||||
|
value={'restauration-collective'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c4')}
|
||||||
|
value={'grossiste-distributeur-cash'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c5')}
|
||||||
|
value={'pai'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c6')}
|
||||||
|
value={'home-freezer-center'}
|
||||||
|
/>
|
||||||
|
<Picker.Item
|
||||||
|
label={i18n.t('custom.select-2.c7')}
|
||||||
|
value={'autres'}
|
||||||
|
/>
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -547,7 +641,10 @@ class ContactDetailsScreen extends React.Component {
|
||||||
<View style={{ flex: 1, margin: 5 }}>
|
<View style={{ flex: 1, margin: 5 }}>
|
||||||
<View style={{ flex: 1 }}>
|
<View style={{ flex: 1 }}>
|
||||||
<ButtonGroup
|
<ButtonGroup
|
||||||
buttons={[i18n.t('contact_details_s.visits'), i18n.t('contact_details_s.notes')]}
|
buttons={[
|
||||||
|
i18n.t('contact_details_s.visits'),
|
||||||
|
i18n.t('contact_details_s.notes'),
|
||||||
|
]}
|
||||||
selectedButtonStyle={{ backgroundColor: '#ea4f52' }}
|
selectedButtonStyle={{ backgroundColor: '#ea4f52' }}
|
||||||
containerStyle={{ height: 30 }}
|
containerStyle={{ height: 30 }}
|
||||||
selectedIndex={this.state.selectedIndex}
|
selectedIndex={this.state.selectedIndex}
|
||||||
|
|
@ -558,14 +655,23 @@ class ContactDetailsScreen extends React.Component {
|
||||||
<View style={{ flexDirection: 'row' }}>
|
<View style={{ flexDirection: 'row' }}>
|
||||||
{this.state.visits.length > 0 && (
|
{this.state.visits.length > 0 && (
|
||||||
<View style={{ flex: 2, flexDirection: 'row' }}>
|
<View style={{ flex: 2, flexDirection: 'row' }}>
|
||||||
<Icon name="sort-down" size={20} color={'black'} style={{ zIndex: 1, position: 'absolute', right: 25, top: 20 }} />
|
<Icon
|
||||||
|
name="sort-down"
|
||||||
|
size={20}
|
||||||
|
color={'black'}
|
||||||
|
style={{
|
||||||
|
zIndex: 1,
|
||||||
|
position: 'absolute',
|
||||||
|
right: 25,
|
||||||
|
top: 20,
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<Picker
|
<Picker
|
||||||
style={styles.select}
|
style={styles.select}
|
||||||
selectedValue={this.state.selectedVisit}
|
selectedValue={this.state.selectedVisit}
|
||||||
onValueChange={(itemValue, itemIndex) => {
|
onValueChange={(itemValue, itemIndex) => {
|
||||||
this.state.visits[
|
this.state.visits[this.state.selectedVisit].note =
|
||||||
this.state.selectedVisit
|
this.state.tmpVisitNote;
|
||||||
].note = this.state.tmpVisitNote;
|
|
||||||
this.setState({
|
this.setState({
|
||||||
visits: this.state.visits,
|
visits: this.state.visits,
|
||||||
selectedVisit: itemIndex,
|
selectedVisit: itemIndex,
|
||||||
|
|
@ -573,7 +679,9 @@ class ContactDetailsScreen extends React.Component {
|
||||||
});
|
});
|
||||||
}}>
|
}}>
|
||||||
{this.state.visits.map((item, index) => {
|
{this.state.visits.map((item, index) => {
|
||||||
return <Picker.Item label={item.title} value={index} />;
|
return (
|
||||||
|
<Picker.Item label={item.title} value={index} />
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -636,13 +744,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', justifyContent: 'space-evenly' }}>
|
<View
|
||||||
|
style={{ flexDirection: 'row', justifyContent: 'space-evenly' }}>
|
||||||
{this.state.action === 'add' && (
|
{this.state.action === 'add' && (
|
||||||
<>
|
<>
|
||||||
<Button title="QRCode vCard" onPress={() => this.setState({ showQRcodevCard: true })} color={'#ea4f52'} />
|
<Button
|
||||||
|
title="QRCode vCard"
|
||||||
|
onPress={() => this.setState({ showQRcodevCard: true })}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Button title={i18n.t('global.save')} onPress={() => this.updateContact()} color={'#ea4f52'} />
|
<Button
|
||||||
|
title={i18n.t('global.save')}
|
||||||
|
onPress={() => this.updateContact()}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
<Overlay
|
<Overlay
|
||||||
|
|
@ -653,7 +770,9 @@ class ContactDetailsScreen extends React.Component {
|
||||||
height={300}>
|
height={300}>
|
||||||
<View
|
<View
|
||||||
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||||
<Text style={{ marginBottom: 10 }}>{i18n.t('contact_details_s.visit_name')} :</Text>
|
<Text style={{ marginBottom: 10 }}>
|
||||||
|
{i18n.t('contact_details_s.visit_name')} :
|
||||||
|
</Text>
|
||||||
<TextInput
|
<TextInput
|
||||||
placeholder={i18n.t('contact_details_s.visit_name')}
|
placeholder={i18n.t('contact_details_s.visit_name')}
|
||||||
value={this.state.newVisitTitle}
|
value={this.state.newVisitTitle}
|
||||||
|
|
@ -678,7 +797,11 @@ class ContactDetailsScreen extends React.Component {
|
||||||
onPress={() => this.setState({ showNewVisit: false })}
|
onPress={() => this.setState({ showNewVisit: false })}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
<Button title={i18n.t('global.add')} onPress={() => this.newVisit()} color={'#ea4f52'} />
|
<Button
|
||||||
|
title={i18n.t('global.add')}
|
||||||
|
onPress={() => this.newVisit()}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
|
|
@ -688,10 +811,13 @@ class ContactDetailsScreen extends React.Component {
|
||||||
overlayBackgroundColor="white"
|
overlayBackgroundColor="white"
|
||||||
width={400}
|
width={400}
|
||||||
height={300}>
|
height={300}>
|
||||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
<View
|
||||||
|
style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
|
||||||
{this.state.hasPermission === true && (
|
{this.state.hasPermission === true && (
|
||||||
<BarCodeScanner
|
<BarCodeScanner
|
||||||
onBarCodeScanned={this.state.scanned ? undefined : handleBarCodeScanned}
|
onBarCodeScanned={
|
||||||
|
this.state.scanned ? undefined : handleBarCodeScanned
|
||||||
|
}
|
||||||
barCodeTypes={[BarCodeScanner.Constants.BarCodeType.qr]}
|
barCodeTypes={[BarCodeScanner.Constants.BarCodeType.qr]}
|
||||||
style={{ flex: 1, width: 380, height: 200 }}
|
style={{ flex: 1, width: 380, height: 200 }}
|
||||||
/>
|
/>
|
||||||
|
|
@ -711,10 +837,18 @@ class ContactDetailsScreen extends React.Component {
|
||||||
}}>
|
}}>
|
||||||
<Button
|
<Button
|
||||||
title={i18n.t('global.cancel')}
|
title={i18n.t('global.cancel')}
|
||||||
onPress={() => this.setState({ showQRcodevCard: false, scanned: false })}
|
onPress={() =>
|
||||||
|
this.setState({ showQRcodevCard: false, scanned: false })
|
||||||
|
}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
{this.state.scanned && <Button title={i18n.t('global.retry')} onPress={() => this.setState({ scanned: false })} color={'#ea4f52'} />}
|
{this.state.scanned && (
|
||||||
|
<Button
|
||||||
|
title={i18n.t('global.retry')}
|
||||||
|
onPress={() => this.setState({ scanned: false })}
|
||||||
|
color={'#ea4f52'}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</Overlay>
|
</Overlay>
|
||||||
|
|
@ -724,9 +858,16 @@ class ContactDetailsScreen extends React.Component {
|
||||||
overlayBackgroundColor="white"
|
overlayBackgroundColor="white"
|
||||||
width={400}
|
width={400}
|
||||||
height={400}>
|
height={400}>
|
||||||
<View style={{ flex: 1, alignItems: 'center', justifyContent: 'space-evenly' }}>
|
<View
|
||||||
|
style={{
|
||||||
|
flex: 1,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'space-evenly',
|
||||||
|
}}>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.name')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.name')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedName}
|
selectedValue={this.state.parsedName}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -734,13 +875,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedName: itemValue });
|
this.setState({ parsedName: itemValue });
|
||||||
}}>
|
}}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.firstname')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.firstname')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedFirstname}
|
selectedValue={this.state.parsedFirstname}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -748,13 +898,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedFirstname: itemValue })
|
this.setState({ parsedFirstname: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.email')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.email')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedEmail}
|
selectedValue={this.state.parsedEmail}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -762,13 +921,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedEmail: itemValue })
|
this.setState({ parsedEmail: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.company')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.company')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedCompany}
|
selectedValue={this.state.parsedCompany}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -776,13 +944,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedCompany: itemValue })
|
this.setState({ parsedCompany: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.address')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.address')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedAddress}
|
selectedValue={this.state.parsedAddress}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -790,13 +967,22 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedAddress: itemValue })
|
this.setState({ parsedAddress: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
<View style={{ flexDirection: 'row', alignItems: 'center' }}>
|
||||||
<Text style={{ flex: 1, paddingLeft: 10 }}>{i18n.t('global.phone')}</Text>
|
<Text style={{ flex: 1, paddingLeft: 10 }}>
|
||||||
|
{i18n.t('global.phone')}
|
||||||
|
</Text>
|
||||||
<Picker
|
<Picker
|
||||||
selectedValue={this.state.parsedPhone}
|
selectedValue={this.state.parsedPhone}
|
||||||
style={{ height: 50, width: 250 }}
|
style={{ height: 50, width: 250 }}
|
||||||
|
|
@ -804,8 +990,15 @@ class ContactDetailsScreen extends React.Component {
|
||||||
this.setState({ parsedPhone: itemValue })
|
this.setState({ parsedPhone: itemValue })
|
||||||
}>
|
}>
|
||||||
<Picker.Item label="" value="0" key={0} />
|
<Picker.Item label="" value="0" key={0} />
|
||||||
{this.state.parsedType === 'vcard' && this.state.parsedDatas.map((item, index) => {
|
{this.state.parsedType === 'vcard' &&
|
||||||
return <Picker.Item label={item} value={item} key={(index + 1).toString()} />;
|
this.state.parsedDatas.map((item, index) => {
|
||||||
|
return (
|
||||||
|
<Picker.Item
|
||||||
|
label={item}
|
||||||
|
value={item}
|
||||||
|
key={(index + 1).toString()}
|
||||||
|
/>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</Picker>
|
</Picker>
|
||||||
</View>
|
</View>
|
||||||
|
|
@ -818,12 +1011,24 @@ class ContactDetailsScreen extends React.Component {
|
||||||
}}>
|
}}>
|
||||||
<Button
|
<Button
|
||||||
title={i18n.t('global.cancel')}
|
title={i18n.t('global.cancel')}
|
||||||
onPress={() => this.setState({ showDynContact: false, scanned: false, parsedName: '', parsedFirstname: '', parsedEmail: '', parsedCompany: '', parsedAddress: '', parsedPhone: '' })}
|
onPress={() =>
|
||||||
|
this.setState({
|
||||||
|
showDynContact: false,
|
||||||
|
scanned: false,
|
||||||
|
parsedName: '',
|
||||||
|
parsedFirstname: '',
|
||||||
|
parsedEmail: '',
|
||||||
|
parsedCompany: '',
|
||||||
|
parsedAddress: '',
|
||||||
|
parsedPhone: '',
|
||||||
|
})
|
||||||
|
}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
<Button
|
<Button
|
||||||
title={i18n.t('global.next')}
|
title={i18n.t('global.next')}
|
||||||
onPress={() => this.setState({
|
onPress={() =>
|
||||||
|
this.setState({
|
||||||
tmpName: this.state.parsedName,
|
tmpName: this.state.parsedName,
|
||||||
tmpFirstname: this.state.parsedFirstname,
|
tmpFirstname: this.state.parsedFirstname,
|
||||||
tmpEmail: this.state.parsedEmail,
|
tmpEmail: this.state.parsedEmail,
|
||||||
|
|
@ -838,7 +1043,8 @@ class ContactDetailsScreen extends React.Component {
|
||||||
parsedPhone: '',
|
parsedPhone: '',
|
||||||
showDynContact: false,
|
showDynContact: false,
|
||||||
scanned: false,
|
scanned: false,
|
||||||
})}
|
})
|
||||||
|
}
|
||||||
color={'#ea4f52'}
|
color={'#ea4f52'}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
||||||
17117
ComApp/yarn.lock
17117
ComApp/yarn.lock
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue