@visns-studio/visns-components 3.3.2 → 3.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.
@@ -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.3",
53
53
  "description": "Various packages to assist in the development of our Custom Applications.",
54
54
  "main": "index.js",
55
55
  "scripts": {