mg-library 1.0.339 → 1.0.341

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/blocks.js +62 -0
  2. package/login.js +32 -0
  3. package/package.json +1 -1
package/blocks.js CHANGED
@@ -14,6 +14,68 @@ import './prototypes.js';
14
14
  import * as mgFunctionsLib from './functions.js';
15
15
  import * as mgLoginLib from './login.js';
16
16
 
17
+ export function MGWelcome(props) {
18
+
19
+ let companyInfoComponent = (
20
+ <View style={{ flex: 1, flexDirection: 'row' }}>
21
+ <View style={{ flex: 1, flexGrow: 0.4, alignItems: 'center' }}>
22
+ <Image source={{ uri: props.company.logoUrl }} style={{ width: 100, height: 100 }} />
23
+ </View>
24
+ <View style={{ flex: 1, flexDirection: 'column', alignSelf: 'center' }}>
25
+ <Text style={{ textAlign: 'center' }} category='h6'>{company.legalName}</Text>
26
+ <Text style={{ textAlign: 'center' }} category='c1'>{company.address}</Text>
27
+ <Text style={{ textAlign: 'center' }} category='c1'>{company.city}, {company.province}</Text>
28
+ <Text style={{ textAlign: 'center' }} category='c1'>{company.phone}</Text>
29
+ <Text style={{ textAlign: 'center' }} category='c1'>{company.email}</Text>
30
+ </View>
31
+ </View>
32
+ )
33
+
34
+ let listHeaderComponent = (
35
+ <View>
36
+ <MGSessionHeader module={mgFunctionsLib.i18nString('notices', props.language)} person={props.person} theme={props.theme} />
37
+ {companyInfoComponent}
38
+ <MGDivider />
39
+ </View>
40
+ );
41
+
42
+ function cardHeader(item) {
43
+ return (
44
+ <>
45
+ <View style={{ flexDirection: 'row', marginTop: 10, marginBottom: 10, marginLeft: 10 }}>
46
+ <View style={{ flexGrow: 0.05 }}>
47
+ {item.isImportant &&
48
+ <MaterialCommunityIcons name='alert-circle-outline' color={props.theme['color-primary-500']} size={30} style={{ flex: 1 }} />
49
+ }
50
+ </View>
51
+ <View>
52
+ <Text category='h6'>{item.description}</Text>
53
+ <Text style={{ marginBottom: 10 }} category='c1'>{mgFunctionsLib.getDateForExposition(item.noticeDate, props.language)}, {item.noticeTime._asTime()}</Text>
54
+ </View>
55
+ </View>
56
+ </>
57
+ );
58
+ };
59
+
60
+ return (
61
+ <View style={mgFunctionsLib.getBasicStyleSheet().availableArea}>
62
+ <FlatList
63
+ data={notices}
64
+ keyExtractor={item => item.idNotice.toString()}
65
+ renderItem={({ item }) => (
66
+ <Card header={cardHeader(item)} style={{ marginBottom: 10, marginHorizontal: 10 }}>
67
+ <Text>
68
+ <Text style={{ marginBottom: 10 }}>{item.content}</Text>
69
+ </Text>
70
+ </Card>
71
+ )}
72
+ ListHeaderComponent={listHeaderComponent}
73
+ />
74
+ </View>
75
+ );
76
+
77
+ }
78
+
17
79
  export function MGLogin(props) {
18
80
 
19
81
  const { control, handleSubmit, formState: { errors } } = useForm({
package/login.js CHANGED
@@ -61,3 +61,35 @@ export function onPressLogout(dispatch, actions, app, apiUrl) {
61
61
  mgFunctionsLib.showToastError(error);
62
62
  }
63
63
  }
64
+
65
+ export function onAutoLogin(dispatch, actions, app, apiUrl, language, setAppState, setNavigator) {
66
+ setAppState({ isLoading: true });
67
+ mgFunctionsLib.readFromLocalStorage(mgConstantsLib.ACCESS_TOKEN)
68
+ .then(value => {
69
+ accessToken = value;
70
+ try {
71
+ let requestData = {
72
+ app: app,
73
+ language: language,
74
+ accessToken: accessToken
75
+ }
76
+ dispatch(actions.apiRequest());
77
+ axios.post(apiUrl + '/Login', requestData, mgFunctionsLib.getRequestHeader())
78
+ .then(response => {
79
+ appSession = response.data;
80
+ if (!mgFunctionsLib.isEmpty(appSession))
81
+ dispatch(actions.login(appSession));
82
+ setNavigator(undefined);
83
+ dispatch(actions.apiSuccess());
84
+ setAppState({ isLoading: false });
85
+ })
86
+ .catch(error => {
87
+ dispatch(actions.apiError());
88
+ setAppState({ isLoading: false });
89
+ });
90
+ } catch (error) {
91
+ dispatch(actions.apiError());
92
+ setAppState({ isLoading: false });
93
+ }
94
+ });
95
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mg-library",
3
- "version": "1.0.339",
3
+ "version": "1.0.341",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {