- {localAvatar ? (
-
- ) : (
-
+
+
+ {/* Profile Information Section */}
+
+
+
+
+ {touched.email && errors.email && (
+
{errors.email}
)}
- {isLoading ? (
-
-
-
Uploading
+ {values.email !== session.data.user.email && (
+
+
+
You will be logged out after changing your email
- ) : (
- <>
-
-
- >
+ )}
+
+
+
+
+
+ {touched.username && errors.username && (
+
{errors.username}
+ )}
+
+
+
+
+
+ {touched.first_name && errors.first_name && (
+
{errors.first_name}
+ )}
+
+
+
+
+
+ {touched.last_name && errors.last_name && (
+
{errors.last_name}
+ )}
+
+
+
+
+
+ {touched.bio && errors.bio && (
+
{errors.bio}
)}
-
-
-
Recommended size 100x100
+
+ {/* Profile Picture Section */}
+
+
+
+
+ {error && (
+
+
+ {error}
+
+ )}
+ {success && (
+
+
+ {success}
+
+ )}
+ {localAvatar ? (
+
+ ) : (
+
+ )}
+ {isLoading ? (
+
+ ) : (
+ <>
+
+
+ >
+ )}
+
+
+
Recommended size 100x100
+
+
+
+
+
+
+
-
+
)}
)}
diff --git a/apps/web/components/Dashboard/Pages/UserAccount/UserEditPassword/UserEditPassword.tsx b/apps/web/components/Dashboard/Pages/UserAccount/UserEditPassword/UserEditPassword.tsx
index 6c7751a3..3f4643e3 100644
--- a/apps/web/components/Dashboard/Pages/UserAccount/UserEditPassword/UserEditPassword.tsx
+++ b/apps/web/components/Dashboard/Pages/UserAccount/UserEditPassword/UserEditPassword.tsx
@@ -1,61 +1,134 @@
import { useLHSession } from '@components/Contexts/LHSessionContext'
import { updatePassword } from '@services/settings/password'
-import { Formik, Form, Field } from 'formik'
+import { Formik, Form } from 'formik'
import React, { useEffect } from 'react'
+import { AlertTriangle } from 'lucide-react'
+import { Input } from "@components/ui/input"
+import { Button } from "@components/ui/button"
+import { Label } from "@components/ui/label"
+import { toast } from 'react-hot-toast'
+import { signOut } from 'next-auth/react'
+import { getUriWithoutOrg } from '@services/config/config'
+import * as Yup from 'yup'
+
+const validationSchema = Yup.object().shape({
+ old_password: Yup.string().required('Current password is required'),
+ new_password: Yup.string()
+ .required('New password is required')
+ .min(8, 'Password must be at least 8 characters'),
+})
function UserEditPassword() {
const session = useLHSession() as any
const access_token = session?.data?.tokens?.access_token;
const updatePasswordUI = async (values: any) => {
- let user_id = session.data.user.id
- await updatePassword(user_id, values, access_token)
+ const loadingToast = toast.loading('Updating password...')
+ try {
+ let user_id = session.data.user.id
+ const response = await updatePassword(user_id, values, access_token)
+
+ if (response.success) {
+ toast.dismiss(loadingToast)
+
+ // Show success message and notify about logout
+ toast.success('Password updated successfully', { duration: 4000 })
+ toast((t) => (
+
+ Please login again with your new password
+
+ ), {
+ duration: 4000,
+ icon: '🔑'
+ })
+
+ // Wait for 4 seconds before signing out
+ await new Promise(resolve => setTimeout(resolve, 4000))
+ signOut({ redirect: true, callbackUrl: getUriWithoutOrg('/') })
+ } else {
+ toast.error(response.data.detail || 'Failed to update password', { id: loadingToast })
+ }
+ } catch (error: any) {
+ const errorMessage = error.data?.detail || 'Failed to update password. Please try again.'
+ toast.error(errorMessage, { id: loadingToast })
+ console.error('Password update error:', error)
+ }
}
useEffect(() => { }, [session])
return (
-
-
{
- setTimeout(() => {
- setSubmitting(false)
- updatePasswordUI(values)
- }, 400)
- }}
- >
- {({ isSubmitting }) => (
-