@visns-studio/visns-components 4.3.1 → 4.3.3

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.
@@ -6,42 +6,45 @@ function Breadcrumb({ data, page }) {
6
6
  const getNestedData = (data, keys) =>
7
7
  keys.reduce((acc, key) => (acc && acc[key] ? acc[key] : null), data);
8
8
 
9
+ const nestedData =
10
+ data && page.parentTitleKey
11
+ ? getNestedData(data, page.parentTitleKey)
12
+ : null;
13
+
9
14
  return (
10
15
  <h1>
11
16
  {page?.parentTitle && page?.parentUrl && (
12
17
  <>
13
- <Link to={page.parentUrl}>
14
- {page.parentTitle}{' '}
15
- <CircleChevronRight strokeWidth={2} size={18} />
16
- </Link>
17
-
18
- {data &&
19
- page.parentTitleKey &&
20
- getNestedData(data, page.parentTitleKey) ? (
21
- <Link
22
- to={`${page.parentUrl}/${getNestedData(
23
- data,
24
- page.parentUrlKey
25
- )}`}
26
- >
27
- {getNestedData(data, page.parentTitleKey)}
28
- <CircleChevronRight
29
- strokeWidth={2}
30
- size={18}
31
- />{' '}
32
- </Link>
33
- ) : null}
18
+ <Link to={page.parentUrl}>{page.parentTitle}</Link>
19
+ <CircleChevronRight strokeWidth={2} size={18} />
34
20
  </>
35
21
  )}
36
- <Link to={page && page.previousUrl ? page.previousUrl : null}>
37
- {page && page.title ? page.title : null}
38
- </Link>{' '}
39
- {page?.titleKey && data && data[page.titleKey] ? (
22
+
23
+ {nestedData ? (
40
24
  <>
41
- <CircleChevronRight strokeWidth={2} size={18} />{' '}
42
- {data[page.titleKey]}
25
+ <Link
26
+ to={`${page.parentUrl}/${getNestedData(
27
+ data,
28
+ page.parentUrlKey
29
+ )}`}
30
+ >
31
+ {nestedData}
32
+ </Link>
33
+ <CircleChevronRight strokeWidth={2} size={18} />
43
34
  </>
44
- ) : null}
35
+ ) : (
36
+ page &&
37
+ page.title && (
38
+ <>
39
+ <Link to={page.previousUrl}>{page.title}</Link>
40
+ <CircleChevronRight strokeWidth={2} size={18} />
41
+ </>
42
+ )
43
+ )}
44
+
45
+ {page.titleKey && data && data[page.titleKey] && (
46
+ <>{data[page.titleKey]}</>
47
+ )}
45
48
  </h1>
46
49
  );
47
50
  }
@@ -8,8 +8,10 @@ import parse from 'html-react-parser';
8
8
  import _ from 'lodash';
9
9
  import ReactDataGrid from '@inovua/reactdatagrid-community';
10
10
  import { CircleX } from 'akar-icons';
11
+ import { confirmAlert } from 'react-confirm-alert';
11
12
 
12
13
  import '@inovua/reactdatagrid-community/index.css';
14
+ import 'react-confirm-alert/src/react-confirm-alert.css';
13
15
 
14
16
  import CustomFetch from './Fetch';
15
17
  import Download from './Download';
@@ -491,6 +493,56 @@ function Form({
491
493
  }
492
494
  };
493
495
 
496
+ const handleCustom = async (s) => {
497
+ const executeRequest = async () => {
498
+ try {
499
+ const url = formSettings.customButton.url;
500
+ const method = 'POST';
501
+
502
+ const res = await CustomFetch(url, method, {
503
+ id: formData[formSettings.primaryKey],
504
+ });
505
+
506
+ if (res.data.error === '') {
507
+ if (res.data.message) {
508
+ toast.success(res.data.message);
509
+ }
510
+
511
+ fetchData();
512
+ } else {
513
+ toast.error(res.data.error);
514
+ }
515
+ } catch (error) {
516
+ console.error('Request failed:', error);
517
+ }
518
+ };
519
+
520
+ try {
521
+ if (s.customButton.confirmation) {
522
+ confirmAlert({
523
+ title: '',
524
+ message:
525
+ s.customButton.confirmation.message ||
526
+ 'Are you sure you want to proceed?',
527
+ buttons: [
528
+ {
529
+ label: 'Yes',
530
+ onClick: executeRequest,
531
+ },
532
+ {
533
+ label: 'No',
534
+ onClick: () => close(),
535
+ },
536
+ ],
537
+ });
538
+ } else {
539
+ await executeRequest();
540
+ }
541
+ } catch (err) {
542
+ console.error('An error occurred:', err);
543
+ }
544
+ };
545
+
494
546
  const handleSubmit = async (e) => {
495
547
  try {
496
548
  if (e) {
@@ -1274,7 +1326,14 @@ function Form({
1274
1326
  <div className="polActions">
1275
1327
  {formSettings.hasOwnProperty('customButton') &&
1276
1328
  formSettings.customButton.url ? (
1277
- <button className="btn" onClick={handleSort}>
1329
+ <button
1330
+ className="btn"
1331
+ onClick={(e) => {
1332
+ e.preventDefault();
1333
+
1334
+ handleCustom(formSettings);
1335
+ }}
1336
+ >
1278
1337
  {formSettings.customButton.label
1279
1338
  ? formSettings.customButton.label
1280
1339
  : 'Sort'}
@@ -325,19 +325,15 @@ function Navigation({
325
325
  return () => {
326
326
  window.removeEventListener('scroll', handleScroll);
327
327
  };
328
+
329
+ console.info(layout);
328
330
  }, []);
329
331
 
330
332
  return layout === 'simple' || layout === 'cms' ? (
331
333
  <div className="cwrap">
332
334
  <aside
333
335
  className={
334
- layout === 'cms'
335
- ? isOpen
336
- ? 'aside--cms'
337
- : 'aside--cms aside--cms--open'
338
- : isOpen
339
- ? 'aside'
340
- : 'aside aside--open'
336
+ isOpen ? 'aside--cms' : 'aside--cms aside--cms--open'
341
337
  }
342
338
  >
343
339
  <div className="logo">
@@ -27,6 +27,7 @@ const ProtectedRoute = ({ user, loading, redirectPath = '/login' }) => {
27
27
  };
28
28
 
29
29
  const GenericAuth = ({
30
+ layout = 'full',
30
31
  logo,
31
32
  headerLogo,
32
33
  providers,
@@ -106,6 +107,7 @@ const GenericAuth = ({
106
107
  path="/*"
107
108
  element={
108
109
  <GenericMain
110
+ layout={layout}
109
111
  logo={headerLogo}
110
112
  navigation={navigation}
111
113
  routeConfig={routeConfig}
@@ -4,8 +4,10 @@ import { Routes, Route, Navigate } from 'react-router-dom';
4
4
  import Call from '../Call';
5
5
  import Loader from '../Loader';
6
6
  import Navigation from '../Navigation';
7
+ import { FullScreen } from 'akar-icons';
7
8
 
8
9
  const GenericMain = ({
10
+ layout = 'full',
9
11
  logo,
10
12
  navigation,
11
13
  routeConfig,
@@ -65,6 +67,7 @@ const GenericMain = ({
65
67
  <div>
66
68
  <header className="header">
67
69
  <Navigation
70
+ layout={layout}
68
71
  logo={logo}
69
72
  navConfig={navigation}
70
73
  setSystemAuth={setSystemAuth}
@@ -17,7 +17,7 @@
17
17
  transition: all 200ms;
18
18
  opacity: 0.8;
19
19
  left: 0;
20
- padding: 19px 20px;
20
+ padding: 19px 25px;
21
21
  transform-origin: top left;
22
22
  cursor: text;
23
23
  }
package/package.json CHANGED
@@ -57,7 +57,7 @@
57
57
  "react-dom": "^17.0.1"
58
58
  },
59
59
  "name": "@visns-studio/visns-components",
60
- "version": "4.3.1",
60
+ "version": "4.3.3",
61
61
  "description": "Various packages to assist in the development of our Custom Applications.",
62
62
  "main": "index.js",
63
63
  "scripts": {