@visns-studio/visns-components 1.0.10 → 1.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.
@@ -7,9 +7,10 @@ import { File, TrashCan } from "akar-icons";
7
7
  import "react-confirm-alert/src/react-confirm-alert.css";
8
8
 
9
9
  import CustomFetch from "../crm/visns-fetch";
10
+ import { toast } from "react-toastify";
10
11
 
11
12
  function VisnsDropZone(props) {
12
- const { alertStateChange, fetchData, files, settings } = props;
13
+ const { fetchData, files, settings } = props;
13
14
  const [loadingProgress, setLoadingProgress] = useState(0);
14
15
 
15
16
  const onDrop = useCallback((acceptedFiles) => {
@@ -36,27 +37,12 @@ function VisnsDropZone(props) {
36
37
  if (result.error === "") {
37
38
  fetchData();
38
39
 
39
- alertStateChange({
40
- show: true,
41
- alertClass: "dialog success",
42
- alertText: String(
43
- "File has been successfully uploaded."
44
- ),
45
- });
40
+ toast.success(
41
+ "File has been successfully uploaded."
42
+ );
46
43
  } else {
47
- alertStateChange({
48
- show: true,
49
- alertClass: "dialog error",
50
- alertText: String(result.error),
51
- });
44
+ toast.error(String(result.error));
52
45
  }
53
- },
54
- function (error) {
55
- alertStateChange({
56
- show: true,
57
- alertClass: "dialog error",
58
- alertText: String(error),
59
- });
60
46
  }
61
47
  );
62
48
  });
@@ -71,11 +57,7 @@ function VisnsDropZone(props) {
71
57
  if (id && id > 0) {
72
58
  window.open(`/ajax/file/download/${id}/${settings.model}`);
73
59
  } else {
74
- alertStateChange({
75
- show: true,
76
- alertClass: "dialog error",
77
- alertText: String("Issue with downloading the selected file."),
78
- });
60
+ toast.warning("Issue with downloading the selected file.");
79
61
  }
80
62
  };
81
63
 
@@ -102,13 +84,6 @@ function VisnsDropZone(props) {
102
84
  if (result.error === "") {
103
85
  fetchData();
104
86
  }
105
- },
106
- function (error) {
107
- alertStateChange({
108
- show: true,
109
- alertClass: "dialog error",
110
- alertText: String(error),
111
- });
112
87
  }
113
88
  );
114
89
  },
@@ -120,11 +95,7 @@ function VisnsDropZone(props) {
120
95
  ],
121
96
  });
122
97
  } else {
123
- alertStateChange({
124
- show: true,
125
- alertClass: "dialog error",
126
- alertText: String("Issue with deleting the selected file."),
127
- });
98
+ toast.error("Issue with deleting the selected file.");
128
99
  }
129
100
  }
130
101
  };
@@ -23,7 +23,6 @@ function Field(props) {
23
23
  settings,
24
24
  inputValue,
25
25
  inputClass,
26
- alertStateChange,
27
26
  onChange,
28
27
  onChangeFile,
29
28
  onChangeRicheditor,
@@ -51,44 +50,32 @@ function Field(props) {
51
50
  };
52
51
  }
53
52
 
54
- CustomFetch(
55
- settings.url,
56
- "POST",
57
- filter,
58
- function (result) {
59
- setOptions(result.data);
53
+ CustomFetch(settings.url, "POST", filter, function (result) {
54
+ setOptions(result.data);
60
55
 
61
- let dataArray = [];
56
+ let dataArray = [];
62
57
 
63
- result.data.forEach((a) => {
64
- let _tempObject = a;
65
-
66
- if (!_.isEmpty(_tempObject)) {
67
- let modifiedObject = {};
58
+ result.data.forEach((a) => {
59
+ let _tempObject = a;
68
60
 
69
- Object.keys(_tempObject).forEach(function (c) {
70
- if (c !== "id" && c !== "label") {
71
- modifiedObject["data-" + c] =
72
- _tempObject[c];
73
- }
74
- });
61
+ if (!_.isEmpty(_tempObject)) {
62
+ let modifiedObject = {};
75
63
 
76
- dataArray.push(modifiedObject);
77
- }
78
- });
64
+ Object.keys(_tempObject).forEach(function (c) {
65
+ if (c !== "id" && c !== "label") {
66
+ modifiedObject["data-" + c] =
67
+ _tempObject[c];
68
+ }
69
+ });
79
70
 
80
- if (dataArray.length > 0) {
81
- setDataOptions(dataArray);
71
+ dataArray.push(modifiedObject);
82
72
  }
83
- },
84
- function (error) {
85
- alertStateChange({
86
- show: true,
87
- alertClass: "dialog error",
88
- alertText: String(error),
89
- });
73
+ });
74
+
75
+ if (dataArray.length > 0) {
76
+ setDataOptions(dataArray);
90
77
  }
91
- );
78
+ });
92
79
  break;
93
80
  case "multi-dropdown-ajax":
94
81
  let multiFilter = {};
@@ -131,13 +118,6 @@ function Field(props) {
131
118
  if (dataArray.length > 0) {
132
119
  setDataOptions(dataArray);
133
120
  }
134
- },
135
- function (error) {
136
- alertStateChange({
137
- show: true,
138
- alertClass: "dialog error",
139
- alertText: String(error),
140
- });
141
121
  }
142
122
  );
143
123
  break;
@@ -173,13 +153,6 @@ function Field(props) {
173
153
  id: settings.child.id,
174
154
  data: result.data,
175
155
  });
176
- },
177
- function (error) {
178
- alertStateChange({
179
- show: true,
180
- alertClass: "dialog error",
181
- alertText: String(error),
182
- });
183
156
  }
184
157
  );
185
158
  }
@@ -4,13 +4,15 @@ import Field from "./visns-field";
4
4
  import slugify from "react-slugify";
5
5
  import moment from "moment";
6
6
  import Reveal from "react-reveal/Reveal";
7
+ import parse from "html-react-parser";
7
8
  import { confirmAlert } from "react-confirm-alert";
8
- import { Copy, Send, TrashBin } from "akar-icons";
9
+ import { toast } from "react-toastify";
10
+ import { Copy, TrashBin } from "akar-icons";
9
11
 
10
12
  import "react-confirm-alert/src/react-confirm-alert.css";
11
13
 
12
14
  function Form(props) {
13
- const { dataId, navigate, form, setActiveNav, alertStateChange } = props;
15
+ const { dataId, navigate, form, setActiveNav } = props;
14
16
  const [data, setData] = useState({});
15
17
  const [dataClass, setDataClass] = useState({});
16
18
  const [audit, setAudit] = useState({
@@ -166,61 +168,37 @@ function Form(props) {
166
168
  message = "You have successfully updated this entry.";
167
169
  }
168
170
 
169
- CustomFetch(
170
- url,
171
- method,
172
- data,
173
- function (result) {
174
- if (result.error === "") {
175
- let _uploadProgress = uploadProgress;
171
+ CustomFetch(url, method, data, function (result) {
172
+ if (result.error === "") {
173
+ let _uploadProgress = uploadProgress;
176
174
 
177
- Object.keys(_uploadProgress).forEach((a, b) => {
178
- setUploadProgress((prevState) => ({
179
- ...prevState,
180
- [b]: 0,
181
- }));
182
- });
175
+ Object.keys(_uploadProgress).forEach((a, b) => {
176
+ setUploadProgress((prevState) => ({
177
+ ...prevState,
178
+ [b]: 0,
179
+ }));
180
+ });
183
181
 
184
- alertStateChange({
185
- show: true,
186
- alertClass: "dialog success",
187
- alertText: message,
188
- });
182
+ toast.success(message);
189
183
 
190
- if (dataId === "create") {
191
- navigate(
192
- form.url.replace("/ajax", "") +
193
- "/" +
194
- result.data.id,
195
- {
196
- state: {
197
- form: form,
198
- },
199
- }
200
- );
201
- }
202
- } else {
203
- alertStateChange({
204
- show: true,
205
- alertClass: "dialog error",
206
- alertText: result.error,
207
- });
184
+ if (dataId === "create") {
185
+ navigate(
186
+ form.url.replace("/ajax", "") +
187
+ "/" +
188
+ result.data.id,
189
+ {
190
+ state: {
191
+ form: form,
192
+ },
193
+ }
194
+ );
208
195
  }
209
- },
210
- function (error) {
211
- alertStateChange({
212
- show: true,
213
- alertClass: "dialog error",
214
- alertText: String(error),
215
- });
196
+ } else {
197
+ toast.error(result.error);
216
198
  }
217
- );
218
- } else {
219
- alertStateChange({
220
- show: true,
221
- alertClass: "dialog error",
222
- alertText: error,
223
199
  });
200
+ } else {
201
+ toast.error(<div>{parse(error)}</div>);
224
202
  }
225
203
  }
226
204
  };
@@ -241,26 +219,12 @@ function Form(props) {
241
219
  function (result) {
242
220
  if (result.error === "") {
243
221
  navigate(form.url.replace("/ajax", ""));
244
- alertStateChange({
245
- show: true,
246
- alertClass: "dialog success",
247
- alertText:
248
- "You have successfully deleted this entry.",
249
- });
222
+ toast.success(
223
+ "You have successfully deleted this entry."
224
+ );
250
225
  } else {
251
- alertStateChange({
252
- show: true,
253
- alertClass: "dialog error",
254
- alertText: result.error,
255
- });
226
+ toast.error(result.error);
256
227
  }
257
- },
258
- function (error) {
259
- alertStateChange({
260
- show: true,
261
- alertClass: "dialog error",
262
- alertText: String(error),
263
- });
264
228
  }
265
229
  ),
266
230
  },
@@ -328,11 +292,8 @@ function Form(props) {
328
292
  },
329
293
  function (error) {
330
294
  navigate("/insights");
331
- alertStateChange({
332
- show: true,
333
- alertClass: "dialog error",
334
- alertText: String(error),
335
- });
295
+
296
+ toast.error(String(error));
336
297
  }
337
298
  );
338
299
  }
@@ -386,7 +347,6 @@ function Form(props) {
386
347
  <div className="dynamicform">
387
348
  {form.fields.map((a, b) => (
388
349
  <Field
389
- alertStateChange={alertStateChange}
390
350
  settings={a}
391
351
  key={
392
352
  b +
package/package.json CHANGED
@@ -15,6 +15,8 @@
15
15
  "react-promise-tracker": "^2.1.1",
16
16
  "react-quill": "^2.0.0",
17
17
  "react-select": "^5.7.3",
18
+ "react-slugify": "^3.0.2",
19
+ "react-sortable-hoc": "^2.0.0",
18
20
  "react-toastify": "^9.1.3",
19
21
  "react-toggle": "^4.1.3",
20
22
  "react-tooltip": "^5.14.0",
@@ -30,7 +32,7 @@
30
32
  "react-dom": ">=18.2.0"
31
33
  },
32
34
  "name": "@visns-studio/visns-components",
33
- "version": "1.0.10",
35
+ "version": "1.0.11",
34
36
  "description": "Various packages to assist in the development of our Custom Applications.",
35
37
  "main": "index.js",
36
38
  "devDependencies": {},