@socialgest/rn-widget 0.0.9 → 0.0.11

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 (73) hide show
  1. package/lib/commonjs/components/chat/Chat.js +4 -4
  2. package/lib/commonjs/components/chat/Chat.js.map +1 -1
  3. package/lib/commonjs/helpers/CheckBox.js +27 -6
  4. package/lib/commonjs/helpers/CheckBox.js.map +1 -1
  5. package/lib/commonjs/helpers/Date.js +38 -29
  6. package/lib/commonjs/helpers/Date.js.map +1 -1
  7. package/lib/commonjs/helpers/DateTime.js +51 -29
  8. package/lib/commonjs/helpers/DateTime.js.map +1 -1
  9. package/lib/commonjs/helpers/utils.helper.js +2 -29
  10. package/lib/commonjs/helpers/utils.helper.js.map +1 -1
  11. package/lib/commonjs/index.js +4 -2
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/redux/actions/app.actions.js +52 -44
  14. package/lib/commonjs/redux/actions/app.actions.js.map +1 -1
  15. package/lib/commonjs/store/index.js +1 -2
  16. package/lib/commonjs/store/index.js.map +1 -1
  17. package/lib/module/components/chat/Chat.js +4 -4
  18. package/lib/module/components/chat/Chat.js.map +1 -1
  19. package/lib/module/helpers/CheckBox.js +27 -6
  20. package/lib/module/helpers/CheckBox.js.map +1 -1
  21. package/lib/module/helpers/Date.js +38 -29
  22. package/lib/module/helpers/Date.js.map +1 -1
  23. package/lib/module/helpers/DateTime.js +51 -29
  24. package/lib/module/helpers/DateTime.js.map +1 -1
  25. package/lib/module/helpers/utils.helper.js +2 -31
  26. package/lib/module/helpers/utils.helper.js.map +1 -1
  27. package/lib/module/index.js +4 -2
  28. package/lib/module/index.js.map +1 -1
  29. package/lib/module/redux/actions/app.actions.js +52 -44
  30. package/lib/module/redux/actions/app.actions.js.map +1 -1
  31. package/lib/module/store/index.js +1 -2
  32. package/lib/module/store/index.js.map +1 -1
  33. package/lib/typescript/src/components/articles/Articles.d.ts +1 -1
  34. package/lib/typescript/src/components/chat/textBox/Picker.d.ts +2 -1
  35. package/lib/typescript/src/components/chat/textBox/Picker.d.ts.map +1 -1
  36. package/lib/typescript/src/components/conversations/Conversations.d.ts +1 -1
  37. package/lib/typescript/src/helpers/CheckBox.d.ts.map +1 -1
  38. package/lib/typescript/src/helpers/Date.d.ts.map +1 -1
  39. package/lib/typescript/src/helpers/DateTime.d.ts.map +1 -1
  40. package/lib/typescript/src/helpers/render.helper.d.ts +2 -1
  41. package/lib/typescript/src/helpers/render.helper.d.ts.map +1 -1
  42. package/lib/typescript/src/helpers/utils.helper.d.ts.map +1 -1
  43. package/lib/typescript/src/hooks/redux-hooks.d.ts +1 -1
  44. package/lib/typescript/src/hooks/redux-hooks.d.ts.map +1 -1
  45. package/lib/typescript/src/index.d.ts +1 -1
  46. package/lib/typescript/src/index.d.ts.map +1 -1
  47. package/lib/typescript/src/redux/actions/app.actions.d.ts.map +1 -1
  48. package/lib/typescript/src/redux/reducers/app.reducers.d.ts +3 -1
  49. package/lib/typescript/src/redux/reducers/app.reducers.d.ts.map +1 -1
  50. package/lib/typescript/src/redux/reducers/articles.reducers.d.ts +3 -1
  51. package/lib/typescript/src/redux/reducers/articles.reducers.d.ts.map +1 -1
  52. package/lib/typescript/src/redux/reducers/chat.reducers.d.ts +3 -1
  53. package/lib/typescript/src/redux/reducers/chat.reducers.d.ts.map +1 -1
  54. package/lib/typescript/src/redux/reducers/chatBoard.reducers.d.ts +3 -1
  55. package/lib/typescript/src/redux/reducers/chatBoard.reducers.d.ts.map +1 -1
  56. package/lib/typescript/src/redux/reducers/chatHistory.reducers.d.ts +3 -1
  57. package/lib/typescript/src/redux/reducers/chatHistory.reducers.d.ts.map +1 -1
  58. package/lib/typescript/src/redux/reducers/operators.reducers.d.ts +3 -1
  59. package/lib/typescript/src/redux/reducers/operators.reducers.d.ts.map +1 -1
  60. package/lib/typescript/src/redux/reducers/storage.reducer.d.ts +3 -1
  61. package/lib/typescript/src/redux/reducers/storage.reducer.d.ts.map +1 -1
  62. package/lib/typescript/src/store/index.d.ts +12 -12
  63. package/lib/typescript/src/store/index.d.ts.map +1 -1
  64. package/package.json +13 -28
  65. package/src/components/channelsCard/ChannelsCard.tsx +1 -1
  66. package/src/components/chat/Chat.tsx +4 -4
  67. package/src/helpers/CheckBox.tsx +27 -5
  68. package/src/helpers/Date.tsx +49 -28
  69. package/src/helpers/DateTime.tsx +62 -28
  70. package/src/helpers/utils.helper.ts +2 -29
  71. package/src/index.ts +8 -3
  72. package/src/redux/actions/app.actions.ts +61 -47
  73. package/src/store/index.tsx +1 -2
@@ -1,4 +1,6 @@
1
1
  import type { StorageState } from '../../models/storage.models';
2
- declare const Storage: import("@reduxjs/toolkit/dist/createReducer").ReducerWithInitialState<StorageState>;
2
+ declare const Storage: import("redux").Reducer<StorageState> & {
3
+ getInitialState: () => StorageState;
4
+ };
3
5
  export default Storage;
4
6
  //# sourceMappingURL=storage.reducer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"storage.reducer.d.ts","sourceRoot":"","sources":["../../../../../src/redux/reducers/storage.reducer.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAgBhE,QAAA,MAAM,OAAO,qFA4CX,CAAC;AAEH,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"storage.reducer.d.ts","sourceRoot":"","sources":["../../../../../src/redux/reducers/storage.reducer.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAgBhE,QAAA,MAAM,OAAO;;CA4CX,CAAC;AAEH,eAAe,OAAO,CAAC"}
@@ -1,4 +1,4 @@
1
- declare const store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore<{
1
+ declare const store: import("@reduxjs/toolkit").EnhancedStore<{
2
2
  app: import("../models/app.models").AppState;
3
3
  articles: import("../models/articles.models").ArticlesState;
4
4
  chat: import("../models/chat.models").ChatState;
@@ -6,17 +6,17 @@ declare const store: import("@reduxjs/toolkit/dist/configureStore").ToolkitStore
6
6
  chatBoard: import("../models/chatBoard.models").ChatBoardState;
7
7
  chatHistory: import("../models/chatHistory.models").State;
8
8
  Operators: import("../models/operators.models").OperatorsState;
9
- }, import("redux").AnyAction, import("@reduxjs/toolkit").MiddlewareArray<[import("redux-thunk").ThunkMiddleware<{
10
- app: import("../models/app.models").AppState;
11
- articles: import("../models/articles.models").ArticlesState;
12
- chat: import("../models/chat.models").ChatState;
13
- Storage: import("../models/storage.models").StorageState;
14
- chatBoard: import("../models/chatBoard.models").ChatBoardState;
15
- chatHistory: import("../models/chatHistory.models").State;
16
- Operators: import("../models/operators.models").OperatorsState;
17
- }, import("redux").AnyAction>, import("redux-thunk").ThunkMiddleware<any, import("redux").AnyAction, undefined> & {
18
- withExtraArgument<ExtraThunkArg, State = any, BasicAction extends import("redux").Action<any> = import("redux").AnyAction>(extraArgument: ExtraThunkArg): import("redux-thunk").ThunkMiddleware<State, BasicAction, ExtraThunkArg>;
19
- }]>>;
9
+ }, import("redux").UnknownAction, import("@reduxjs/toolkit").Tuple<[import("redux").StoreEnhancer<{
10
+ dispatch: import("redux-thunk").ThunkDispatch<{
11
+ app: import("../models/app.models").AppState;
12
+ articles: import("../models/articles.models").ArticlesState;
13
+ chat: import("../models/chat.models").ChatState;
14
+ Storage: import("../models/storage.models").StorageState;
15
+ chatBoard: import("../models/chatBoard.models").ChatBoardState;
16
+ chatHistory: import("../models/chatHistory.models").State;
17
+ Operators: import("../models/operators.models").OperatorsState;
18
+ }, undefined, import("redux").UnknownAction>;
19
+ }>, import("redux").StoreEnhancer]>>;
20
20
  export type RootState = ReturnType<typeof store.getState>;
21
21
  export type AppDispatch = typeof store.dispatch;
22
22
  export default store;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/store/index.tsx"],"names":[],"mappings":"AAWA,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;IAcT,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,OAAO,KAAK,CAAC,QAAQ,CAAC;AAEhD,eAAe,KAAK,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/store/index.tsx"],"names":[],"mappings":"AAUA,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;;;;oCAcT,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,QAAQ,CAAC,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,OAAO,KAAK,CAAC,QAAQ,CAAC;AAEhD,eAAe,KAAK,CAAC"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@socialgest/rn-widget",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Widget Tikket Sdk",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
7
- "types": "lib/typescript/typings.d.ts",
7
+ "types": "lib/typescript/src/index.d.ts",
8
8
  "react-native": "src/index",
9
9
  "source": "src/index",
10
10
  "files": [
@@ -51,21 +51,14 @@
51
51
  "registry": "https://registry.npmjs.org/"
52
52
  },
53
53
  "dependencies": {
54
- "@react-native-async-storage/async-storage": "^1.19.3",
55
- "@reduxjs/toolkit": "^1.9.5",
56
- "@types/react-native-htmlview": "^0.16.3",
57
- "immutable": "^5.0.0-beta.4",
54
+ "@react-native-async-storage/async-storage": "^2.2.0",
55
+ "@reduxjs/toolkit": "^2.9.0",
58
56
  "moment": "^2.29.4",
59
- "react-native-base64": "^0.2.1",
60
- "react-native-datepicker": "^1.7.2",
61
57
  "react-native-document-picker": "^9.0.1",
62
- "react-native-elements": "^3.4.3",
63
58
  "react-native-htmlview": "^0.17.0",
64
59
  "react-native-hyperlink": "^0.0.22",
65
- "react-native-loader": "^1.3.1",
66
60
  "react-native-modal": "^13.0.1",
67
- "react-redux": "^8.1.3",
68
- "redux-thunk": "^2.4.2",
61
+ "react-redux": "^9.2.0",
69
62
  "rn-emoji-keyboard": "^1.5.1",
70
63
  "rxjs": "^7.8.1",
71
64
  "socket.io-client": "^4.7.5"
@@ -76,10 +69,8 @@
76
69
  "@react-native/eslint-config": "^0.72.2",
77
70
  "@release-it/conventional-changelog": "^5.0.0",
78
71
  "@types/jest": "^28.1.2",
79
- "@types/react": "~17.0.21",
80
- "@types/react-native": "0.70.0",
81
- "@types/react-native-base64": "^0.2.2",
82
- "@types/react-native-datepicker": "^1.7.5",
72
+ "@react-native-community/datetimepicker": "^8.6.0",
73
+ "@types/react": "^19.0.0",
83
74
  "commitlint": "^17.0.2",
84
75
  "del-cli": "^5.0.0",
85
76
  "eslint": "^8.4.1",
@@ -87,25 +78,19 @@
87
78
  "eslint-plugin-prettier": "^4.0.0",
88
79
  "jest": "^28.1.1",
89
80
  "prettier": "^2.0.5",
90
- "react": "18.2.0",
91
- "react-native": "0.72.6",
81
+ "react": "19.2.0",
82
+ "react-native": "0.83.0",
92
83
  "react-native-builder-bob": "^0.20.0",
93
84
  "react-native-svg": "^15.0.0",
94
85
  "release-it": "^15.0.0",
95
86
  "typescript": "^5.0.2"
96
87
  },
97
- "resolutions": {
98
- "@types/react": "17.0.21"
99
- },
100
88
  "peerDependencies": {
101
- "react": "*",
102
- "react-native": "*",
103
- "react-native-datepicker": "*",
104
- "react-native-svg": "^15.0.0"
89
+ "react": ">=18.0.0",
90
+ "react-native": ">=0.72.0",
91
+ "@react-native-community/datetimepicker": ">=7.0.0",
92
+ "react-native-svg": ">=15.0.0"
105
93
  },
106
- "workspaces": [
107
- "example"
108
- ],
109
94
  "packageManager": "yarn@3.6.1",
110
95
  "engines": {
111
96
  "node": ">= 18.0.0"
@@ -26,7 +26,7 @@ interface Channel {
26
26
  id: number;
27
27
  name: string;
28
28
  color: string;
29
- icon: FC<{ color: string }>;
29
+ icon: (props: { color: string }) => React.ReactNode;
30
30
  }
31
31
 
32
32
  interface ChannelsCardProps {}
@@ -80,7 +80,7 @@ const Chat: React.FC<ChatProps> = ({ selectFile }) => {
80
80
  const { previews, history } = useAppSelector((state) => state.chatHistory);
81
81
  const { operators } = useAppSelector((state) => state.Operators);
82
82
 
83
- var props = {
83
+ const props = {
84
84
  app,
85
85
  operators,
86
86
  chatHistory: history,
@@ -162,7 +162,7 @@ const Chat: React.FC<ChatProps> = ({ selectFile }) => {
162
162
  };
163
163
 
164
164
  const colorBackground = (index: number | null, i: number) => {
165
- var color = '#ffffff';
165
+ let color = '#ffffff';
166
166
  if (index !== i) {
167
167
  color = initProps.primaryColor;
168
168
  }
@@ -170,7 +170,7 @@ const Chat: React.FC<ChatProps> = ({ selectFile }) => {
170
170
  };
171
171
 
172
172
  const colorBackgroundAndBorde = (index: number | null, i: number) => {
173
- var color =
173
+ const color =
174
174
  initProps.textColor.toLowerCase() === '#ffffff' &&
175
175
  colorBackground(index, i) === '#ffffff'
176
176
  ? initProps.primaryColor
@@ -182,7 +182,7 @@ const Chat: React.FC<ChatProps> = ({ selectFile }) => {
182
182
  };
183
183
 
184
184
  const colorBackgroundAndBorde2 = (index: number | null, i: number) => {
185
- var color =
185
+ const color =
186
186
  colorBackground(index, i) !== '#ffffff'
187
187
  ? initProps.primaryColor
188
188
  : !wc_hex_is_light(initProps.primaryColor) &&
@@ -1,5 +1,5 @@
1
1
  import React, { type FC, useState, useEffect } from 'react';
2
- import { CheckBox } from 'react-native-elements';
2
+ import { TouchableOpacity, View, StyleSheet } from 'react-native';
3
3
 
4
4
  interface CheckBoxComponentProps {
5
5
  value: boolean;
@@ -21,15 +21,37 @@ const CheckBoxComponent: FC<CheckBoxComponentProps> = ({
21
21
  }, [value]);
22
22
 
23
23
  return (
24
- <CheckBox
25
- checked={value}
26
- checkedColor={color}
24
+ <TouchableOpacity
27
25
  onPress={() => {
28
26
  onChange(!check);
29
27
  setCheck(!check);
30
28
  }}
31
- />
29
+ style={[
30
+ styles.box,
31
+ { borderColor: color || '#007AFF' },
32
+ check && { backgroundColor: color || '#007AFF' },
33
+ ]}
34
+ >
35
+ {check && <View style={styles.checkmark} />}
36
+ </TouchableOpacity>
32
37
  );
33
38
  };
34
39
 
40
+ const styles = StyleSheet.create({
41
+ box: {
42
+ width: 24,
43
+ height: 24,
44
+ borderWidth: 2,
45
+ borderRadius: 4,
46
+ justifyContent: 'center',
47
+ alignItems: 'center',
48
+ },
49
+ checkmark: {
50
+ width: 12,
51
+ height: 12,
52
+ backgroundColor: '#fff',
53
+ borderRadius: 2,
54
+ },
55
+ });
56
+
35
57
  export default CheckBoxComponent;
@@ -1,42 +1,63 @@
1
1
  import React, { type FC, useState } from 'react';
2
- import DatePicker from 'react-native-datepicker';
2
+ import {
3
+ View,
4
+ Text,
5
+ TouchableOpacity,
6
+ Platform,
7
+ StyleSheet,
8
+ } from 'react-native';
9
+ import DateTimePicker from '@react-native-community/datetimepicker';
10
+
3
11
  interface DatePickerComponentProps {
4
12
  value: Date;
5
13
  }
6
14
 
7
15
  const DatePickerComponent: FC<DatePickerComponentProps> = ({ value }) => {
8
- const [date, setDate] = useState(new Date());
16
+ const [date, setDate] = useState(value || new Date());
17
+ const [show, setShow] = useState(false);
18
+
19
+ const onChange = (_event: any, selectedDate?: Date) => {
20
+ if (Platform.OS === 'android') {
21
+ setShow(false);
22
+ }
23
+ if (selectedDate) {
24
+ setDate(selectedDate);
25
+ }
26
+ };
9
27
 
10
- const onChangeTime = (event: any) => {
11
- console.log(event, value);
12
- setDate(event);
28
+ const formatDate = (d: Date) => {
29
+ const year = d.getFullYear();
30
+ const month = String(d.getMonth() + 1).padStart(2, '0');
31
+ const day = String(d.getDate()).padStart(2, '0');
32
+ return `${year}-${month}-${day}`;
13
33
  };
14
34
 
15
35
  return (
16
- <DatePicker
17
- style={{ width: 200 }}
18
- date={date}
19
- mode="date"
20
- placeholder="select date"
21
- format="YYYY-MM-DD"
22
- confirmBtnText="Confirm"
23
- cancelBtnText="Cancel"
24
- customStyles={{
25
- dateIcon: {
26
- position: 'absolute',
27
- left: 0,
28
- top: 4,
29
- marginLeft: 0,
30
- },
31
- dateInput: {
32
- marginLeft: 36,
33
- },
34
- }}
35
- onDateChange={(a: any) => {
36
- onChangeTime(a);
37
- }}
38
- />
36
+ <View style={styles.container}>
37
+ <TouchableOpacity onPress={() => setShow(true)}>
38
+ <Text style={styles.text}>{formatDate(date)}</Text>
39
+ </TouchableOpacity>
40
+ {show && (
41
+ <DateTimePicker
42
+ value={date}
43
+ mode="date"
44
+ display="default"
45
+ onChange={onChange}
46
+ />
47
+ )}
48
+ </View>
39
49
  );
40
50
  };
41
51
 
52
+ const styles = StyleSheet.create({
53
+ container: {
54
+ width: 200,
55
+ },
56
+ text: {
57
+ fontSize: 14,
58
+ color: '#000',
59
+ padding: 8,
60
+ },
61
+ });
62
+
42
63
  export default DatePickerComponent;
@@ -1,5 +1,12 @@
1
1
  import React, { type FC, useState } from 'react';
2
- import DatePicker from 'react-native-datepicker';
2
+ import {
3
+ View,
4
+ Text,
5
+ TouchableOpacity,
6
+ Platform,
7
+ StyleSheet,
8
+ } from 'react-native';
9
+ import DateTimePicker from '@react-native-community/datetimepicker';
3
10
 
4
11
  interface DateTimePickerComponentProps {
5
12
  value: Date;
@@ -8,38 +15,65 @@ interface DateTimePickerComponentProps {
8
15
  const DateTimePickerComponent: FC<DateTimePickerComponentProps> = ({
9
16
  value,
10
17
  }) => {
11
- const [date, setDate] = useState(new Date());
18
+ const [date, setDate] = useState(value || new Date());
19
+ const [show, setShow] = useState(false);
20
+ const [mode, setMode] = useState<'date' | 'time'>('date');
12
21
 
13
- const onChangeTime = (event: any) => {
14
- console.log(event, value);
15
- setDate(event);
22
+ const onChange = (_event: any, selectedDate?: Date) => {
23
+ if (Platform.OS === 'android') {
24
+ setShow(false);
25
+ }
26
+ if (selectedDate) {
27
+ setDate(selectedDate);
28
+ if (Platform.OS === 'android' && mode === 'date') {
29
+ setMode('time');
30
+ setShow(true);
31
+ }
32
+ }
33
+ };
34
+
35
+ const formatDateTime = (d: Date) => {
36
+ const year = d.getFullYear();
37
+ const month = String(d.getMonth() + 1).padStart(2, '0');
38
+ const day = String(d.getDate()).padStart(2, '0');
39
+ let hours = d.getHours();
40
+ const minutes = String(d.getMinutes()).padStart(2, '0');
41
+ const ampm = hours >= 12 ? 'PM' : 'AM';
42
+ hours = hours % 12 || 12;
43
+ return `${year}-${month}-${day} ${hours}:${minutes} ${ampm}`;
44
+ };
45
+
46
+ const showPicker = () => {
47
+ setMode('date');
48
+ setShow(true);
16
49
  };
17
50
 
18
51
  return (
19
- <DatePicker
20
- style={{ width: 200 }}
21
- date={date}
22
- mode="datetime"
23
- placeholder="select date"
24
- format="YYYY-MM-DD hh:mm a"
25
- confirmBtnText="Confirm"
26
- cancelBtnText="Cancel"
27
- customStyles={{
28
- dateIcon: {
29
- position: 'absolute',
30
- left: 0,
31
- top: 4,
32
- marginLeft: 0,
33
- },
34
- dateInput: {
35
- marginLeft: 36,
36
- },
37
- }}
38
- onDateChange={(a: any) => {
39
- onChangeTime(a);
40
- }}
41
- />
52
+ <View style={styles.container}>
53
+ <TouchableOpacity onPress={showPicker}>
54
+ <Text style={styles.text}>{formatDateTime(date)}</Text>
55
+ </TouchableOpacity>
56
+ {show && (
57
+ <DateTimePicker
58
+ value={date}
59
+ mode={Platform.OS === 'ios' ? 'datetime' : mode}
60
+ display="default"
61
+ onChange={onChange}
62
+ />
63
+ )}
64
+ </View>
42
65
  );
43
66
  };
44
67
 
68
+ const styles = StyleSheet.create({
69
+ container: {
70
+ width: 200,
71
+ },
72
+ text: {
73
+ fontSize: 14,
74
+ color: '#000',
75
+ padding: 8,
76
+ },
77
+ });
78
+
45
79
  export default DateTimePickerComponent;
@@ -84,11 +84,6 @@ export const cutLongText = (text: string, lettersCuantity: number): string => {
84
84
  return `${text.split('').slice(0, lettersCuantity).join('')}...`;
85
85
  };
86
86
 
87
- // export const setSessionData = (channelId: string, token: string): void => {
88
- // // sessionStorage.setItem("token", token);
89
- // // sessionStorage.setItem("channelId", channelId);
90
- // };
91
-
92
87
  export const setSince = (chat: number | string | null = null): number => {
93
88
  if (typeof chat === 'string') {
94
89
  chat = new Date(chat).getTime();
@@ -104,8 +99,7 @@ export const getArrayOfRandomItems = (
104
99
  ): number[] => {
105
100
  let array: number[] = [];
106
101
  if (arrayItems.length <= count) {
107
- // @ts-ignore
108
- arrayItems.forEach((data, index) => {
102
+ arrayItems.forEach((_data, index) => {
109
103
  array.push(index);
110
104
  });
111
105
  return array;
@@ -122,27 +116,6 @@ export const getArrayOfRandomItems = (
122
116
  return array;
123
117
  };
124
118
 
125
- // export const getIcon = (file: string, arrayIcons: any[]): any[] => {
126
- // return arrayIcons.filter((icon) => {
127
- // return icon.path === file;
128
- // });
129
- // };
130
-
131
- // export const getIcons = (): any[] => {
132
- // const reqSvgs = require("../assets/svg");
133
- // return reqSvgs.keys().map((path: any) => ({ path, file: reqSvgs(path) }));
134
- // };
135
-
136
- // export const getIconByName = (iconName: string): any => {
137
- // const icons = getIcons();
138
- // return icons.filter((icon) => icon.path === `./${iconName}.js`)[0].file;
139
- // };
140
-
141
- // export const getImages = (): any[] => {
142
- // const reqSvgs = require.context("../assets/images", true, /\.png$/);
143
- // return reqSvgs.keys().map((path) => ({ path, file: reqSvgs(path) }));
144
- // };
145
-
146
119
  export const makeObjFields = (fieldsArr: any[]): Record<string, string> => {
147
120
  const objFields: Record<string, string> = {};
148
121
  fieldsArr.forEach((field) => {
@@ -152,7 +125,7 @@ export const makeObjFields = (fieldsArr: any[]): Record<string, string> => {
152
125
  };
153
126
 
154
127
  export const isObjEmpty = (obj: object): boolean => {
155
- for (var prop in obj) {
128
+ for (const prop in obj) {
156
129
  if (obj.hasOwnProperty(prop)) {
157
130
  return false;
158
131
  }
package/src/index.ts CHANGED
@@ -23,8 +23,8 @@ export function getToken(): Promise<string> {
23
23
  return Promise.resolve(token);
24
24
  }
25
25
 
26
- export function init(props: any) {
27
- store.dispatch(initChat(props)).catch((error: any) => {
26
+ export function init(props: any): Promise<any> {
27
+ return store.dispatch(initChat(props)).catch((error: any) => {
28
28
  console.error(
29
29
  '[rn-widget] init dispatch error:',
30
30
  error instanceof Error ? error.message : error
@@ -37,7 +37,12 @@ export function openOrClosedChat(props: any) {
37
37
  }
38
38
 
39
39
  export function updateUser(props: any) {
40
- store.dispatch(updateFormUser(props));
40
+ store.dispatch(updateFormUser(props)).catch((error: any) => {
41
+ console.error(
42
+ '[rn-widget] updateUser dispatch error:',
43
+ error instanceof Error ? error.message : error
44
+ );
45
+ });
41
46
  }
42
47
 
43
48
  export function setTextBox(props: any) {