@visns-studio/visns-components 3.3.0 → 3.3.2

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.
@@ -41,28 +41,43 @@ const Profile = ({ userProfile, setUserProfile }) => {
41
41
  }));
42
42
  };
43
43
 
44
- const handleSubmitProfile = (e) => {
45
- e.preventDefault();
44
+ const handleSubmitProfile = async (e) => {
45
+ try {
46
+ if (e) {
47
+ e.preventDefault();
48
+ }
46
49
 
47
- if (profile.name.trim() === '' || profile.email.trim() === '') {
48
- setInputClasses({
49
- name: profile.name.trim() === '' ? 'inputError' : '',
50
- email: profile.email.trim() === '' ? 'inputError' : '',
51
- });
50
+ // Validate required fields
51
+ if (profile.name.trim() === '' || profile.email.trim() === '') {
52
+ setInputClasses({
53
+ name: profile.name.trim() === '' ? 'inputError' : '',
54
+ email: profile.email.trim() === '' ? 'inputError' : '',
55
+ });
52
56
 
53
- toast.error('Please fill in all the required fields.');
54
- } else {
55
- CustomFetch(
56
- `/ajax/users/${userProfile.id}`,
57
- 'PUT',
58
- profile,
59
- function (result) {
60
- setUserProfile(result.user);
61
- toast.success(
62
- 'Your profile has been successfully updated.'
63
- );
57
+ toast.error('Please fill in all the required fields.');
58
+ } else {
59
+ // Create a new payload object
60
+ let payload = {
61
+ name: profile.name,
62
+ email: profile.email,
63
+ };
64
+
65
+ // Conditionally add password to payload if it has a value
66
+ if (profile.password.trim() !== '') {
67
+ payload.password = profile.password;
64
68
  }
65
- );
69
+
70
+ const res = await CustomFetch(
71
+ `/ajax/users/${userProfile.id}`,
72
+ 'PUT',
73
+ payload
74
+ );
75
+
76
+ setUserProfile(res.data.user);
77
+ toast.success('Your profile has been successfully updated.');
78
+ }
79
+ } catch (err) {
80
+ console.log(err);
66
81
  }
67
82
  };
68
83
 
@@ -18,8 +18,6 @@ import Login from '../auth/Login';
18
18
  import Reset from '../auth/Reset';
19
19
  import Verify from '../auth/Verify';
20
20
 
21
- // import Main from '../../../../../../resources/js/main';
22
-
23
21
  const ProtectedRoute = ({ user, loading, redirectPath = '/login' }) => {
24
22
  return loading ? null : !user.id ? (
25
23
  <Navigate to={redirectPath} replace />
@@ -1,6 +1,9 @@
1
1
  import React, { useState } from 'react';
2
- import { Routes, Route } from 'react-router-dom';
3
- import { Call, Loader, Navigation } from '@visns-studio/visns-components';
2
+ import { Routes, Route, Navigate } from 'react-router-dom';
3
+
4
+ import Call from '../Call';
5
+ import Loader from '../Loader';
6
+ import Navigation from '../Navigation';
4
7
 
5
8
  const GenericMain = ({
6
9
  logo,
@@ -52,7 +55,14 @@ const GenericMain = ({
52
55
  <main className="content">
53
56
  <div className="content-main" id="app">
54
57
  <div className="padding">
55
- <Routes>{renderRoutes(routeConfig)}</Routes>
58
+ <Routes>
59
+ {renderRoutes(routeConfig)}
60
+ {/* Add a wildcard route for handling unknown paths */}
61
+ <Route
62
+ path="*"
63
+ element={<Navigate to="/" replace />}
64
+ />
65
+ </Routes>
56
66
  </div>
57
67
  <Call incomingCallData={incomingCallData} />
58
68
  <Loader />
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.0",
52
+ "version": "3.3.2",
53
53
  "description": "Various packages to assist in the development of our Custom Applications.",
54
54
  "main": "index.js",
55
55
  "scripts": {