@visns-studio/visns-components 3.3.2 → 3.3.4

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.
@@ -669,7 +669,7 @@ const DataGrid = forwardRef(
669
669
  {(form.create &&
670
670
  form.create.title &&
671
671
  form.create.title !== '') ||
672
- (form.url && form.create.title) ? (
672
+ (form.url && form.create?.title) ? (
673
673
  <button
674
674
  className="btn"
675
675
  onClick={(e) => {
@@ -694,6 +694,21 @@ const DataGrid = forwardRef(
694
694
  >
695
695
  <div className="icon-plus"></div> Create
696
696
  </button>
697
+ ) : form.url ? (
698
+ <button
699
+ className="btn"
700
+ onClick={(e) => {
701
+ e.preventDefault();
702
+
703
+ window.open(
704
+ form.url,
705
+ '',
706
+ 'width=1440,height=1024,menubar=1,resizable=1,status=1,titlebar=1,toolbar=1'
707
+ );
708
+ }}
709
+ >
710
+ <div className="icon-plus"></div> Create
711
+ </button>
697
712
  ) : null}
698
713
  </div>
699
714
  );
@@ -26,6 +26,7 @@ const Profile = ({ userProfile, setUserProfile }) => {
26
26
  ]);
27
27
 
28
28
  useEffect(() => {
29
+ console.info(userProfile);
29
30
  setProfile({
30
31
  name: userProfile.name,
31
32
  email: userProfile.email,
@@ -73,7 +74,7 @@ const Profile = ({ userProfile, setUserProfile }) => {
73
74
  payload
74
75
  );
75
76
 
76
- setUserProfile(res.data.user);
77
+ setUserProfile(res.data.data);
77
78
  toast.success('Your profile has been successfully updated.');
78
79
  }
79
80
  } catch (err) {
@@ -19,7 +19,7 @@ import Reset from '../auth/Reset';
19
19
  import Verify from '../auth/Verify';
20
20
 
21
21
  const ProtectedRoute = ({ user, loading, redirectPath = '/login' }) => {
22
- return loading ? null : !user.id ? (
22
+ return loading ? null : !user || !user.id ? (
23
23
  <Navigate to={redirectPath} replace />
24
24
  ) : (
25
25
  <Outlet />
@@ -20,7 +20,7 @@ import Table from '../DataGrid';
20
20
  import TableFilter from '../TableFilter';
21
21
  import { toast } from 'react-toastify';
22
22
 
23
- function GenericDetail({ setting, urlParam, userProfile }) {
23
+ function GenericDetail({ extraUrlParam, setting, urlParam, userProfile }) {
24
24
  const routeParams = useParams();
25
25
 
26
26
  const { filters, page, stages, tabs } = setting;
@@ -15,18 +15,37 @@ const GenericMain = ({
15
15
  }) => {
16
16
  const [incomingCallData, setIncomingCallData] = useState({});
17
17
 
18
+ // Function to extract route parameters
19
+ const extractRouteParams = (path) => {
20
+ const params = path.match(/:\w+/g) || [];
21
+ return params.map((param) => param.substring(1));
22
+ };
23
+
18
24
  // Recursive function to render routes
19
25
  const renderRoutes = (routes) => {
20
26
  return routes.map((route, index) => {
21
- let element;
27
+ let elementProps = {
28
+ userProfile: userProfile,
29
+ setUserProfile: setUserProfile,
30
+ };
31
+
32
+ const routeParams = extractRouteParams(route.path);
33
+ const extraParams = routeParams.filter(
34
+ (param) => param !== 'dataId'
35
+ );
22
36
 
23
- if (route.element) {
24
- element = React.cloneElement(route.element, {
25
- userProfile: userProfile,
26
- setUserProfile: setUserProfile,
27
- });
37
+ if (routeParams.includes('dataId')) {
38
+ elementProps.urlParam = 'dataId';
28
39
  }
29
40
 
41
+ if (extraParams.length > 0) {
42
+ elementProps.extraUrlParam = extraParams;
43
+ }
44
+
45
+ let element = route.element
46
+ ? React.cloneElement(route.element, elementProps)
47
+ : null;
48
+
30
49
  if (route.children && route.children.length > 0) {
31
50
  // If the route has children, render them recursively
32
51
  return (
package/package.json CHANGED
@@ -49,7 +49,7 @@
49
49
  "react-dom": "^17.0.1"
50
50
  },
51
51
  "name": "@visns-studio/visns-components",
52
- "version": "3.3.2",
52
+ "version": "3.3.4",
53
53
  "description": "Various packages to assist in the development of our Custom Applications.",
54
54
  "main": "index.js",
55
55
  "scripts": {