@visns-studio/visns-components 3.3.1 → 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.
- package/components/crm/auth/Profile.jsx +34 -19
- package/package.json +1 -1
|
@@ -41,28 +41,43 @@ const Profile = ({ userProfile, setUserProfile }) => {
|
|
|
41
41
|
}));
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
const handleSubmitProfile = (e) => {
|
|
45
|
-
|
|
44
|
+
const handleSubmitProfile = async (e) => {
|
|
45
|
+
try {
|
|
46
|
+
if (e) {
|
|
47
|
+
e.preventDefault();
|
|
48
|
+
}
|
|
46
49
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
|
package/package.json
CHANGED