import * as React from 'react' import { Box, Card, Typography, Button, Container, Dialog, DialogContent, Zoom, Fade, LinearProgress, CircularProgress, IconButton, } from '@mui/material' import CheckCircleIcon from '@mui/icons-material/CheckCircle' import LockIcon from '@mui/icons-material/Lock' import ArrowBackIcon from '@mui/icons-material/ArrowBack' import CheckIcon from '@mui/icons-material/Check' import CloseIcon from '@mui/icons-material/Close' import { keyframes } from '@mui/system' import MuiDynamicInput from '../../utills/MuiDynamicInput' // Keyframe animations const scaleIn = keyframes` 0% { transform: scale(0); opacity: 0; } 50% { transform: scale(1.2); } 100% { transform: scale(1); opacity: 1; } ` const pulse = keyframes` 0% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.4); } 70% { box-shadow: 0 0 0 20px rgba(76, 175, 80, 0); } 100% { box-shadow: 0 0 0 0 rgba(76, 175, 80, 0); } ` const fadeInUp = keyframes` 0% { opacity: 0; transform: translateY(20px); } 100% { opacity: 1; transform: translateY(0); } ` const float = keyframes` 0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-20px); } ` // Success Modal Component function SuccessModal({ open, onClose, title, message }) { return ( {title} {message} ) } // Password Strength Indicator function PasswordStrength({ password }) { const getStrength = () => { let strength = 0 if (password.length >= 8) strength += 25 if (/[a-z]/.test(password)) strength += 25 if (/[A-Z]/.test(password)) strength += 25 if (/\d/.test(password)) strength += 15 if (/[!@#$%^&*(),.?":{}|<>]/.test(password)) strength += 10 return Math.min(strength, 100) } const strength = getStrength() const getColor = () => { if (strength < 30) return 'error' if (strength < 60) return 'warning' if (strength < 80) return 'info' return 'success' } const getLabel = () => { if (strength < 30) return 'Weak' if (strength < 60) return 'Fair' if (strength < 80) return 'Good' return 'Strong' } if (!password) return null return ( Password Strength {getLabel()} ) } // Password Requirements Component function PasswordRequirements({ password }) { const requirements = [ { label: 'At least 8 characters', met: password.length >= 8 }, { label: 'One lowercase letter', met: /[a-z]/.test(password) }, { label: 'One uppercase letter', met: /[A-Z]/.test(password) }, { label: 'One number', met: /\d/.test(password) }, { label: 'One special character', met: /[!@#$%^&*(),.?":{}|<>]/.test(password) }, ] return ( {requirements.map((req, index) => ( {req.met ? ( ) : ( )} {req.label} ))} ) } const ChangePasswordPage = () => { const [loading, setLoading] = React.useState(false) const [successModal, setSuccessModal] = React.useState(false) const [formData, setFormData] = React.useState({ currentPassword: '', newPassword: '', confirmPassword: '', }) const [errors, setErrors] = React.useState({}) const handleChange = (e) => { const { name, value } = e.target setFormData((prev) => ({ ...prev, [name]: value })) if (errors[name]) { setErrors((prev) => ({ ...prev, [name]: '' })) } } const validateForm = () => { const newErrors = {} if (!formData.currentPassword) { newErrors.currentPassword = 'Current password is required' } if (!formData.newPassword) { newErrors.newPassword = 'New password is required' } else if (formData.newPassword.length < 8) { newErrors.newPassword = 'Password must be at least 8 characters' } else if (!/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)/.test(formData.newPassword)) { newErrors.newPassword = 'Must include uppercase, lowercase, and number' } if (!formData.confirmPassword) { newErrors.confirmPassword = 'Please confirm your password' } else if (formData.newPassword !== formData.confirmPassword) { newErrors.confirmPassword = 'Passwords do not match' } if (formData.currentPassword === formData.newPassword) { newErrors.newPassword = 'New password must be different from current' } setErrors(newErrors) return Object.keys(newErrors).length === 0 } const handleSubmit = async () => { if (!validateForm()) return setLoading(true) setTimeout(() => { setLoading(false) setSuccessModal(true) console.log('Change Password Data:', { currentPassword: formData.currentPassword, newPassword: formData.newPassword, }) }, 1500) } const handleSuccessClose = () => { setSuccessModal(false) setFormData({ currentPassword: '', newPassword: '', confirmPassword: '' }) console.log('Navigate to profile or dashboard...') } const handleBack = () => { console.log('Navigate back...') } return ( {/* Left Side - Image */} {/* Background Decorations */} {/* Lock Icon with Animation */} Secure Your Account Keep your account safe by regularly updating your password. Choose a strong password that you don't use elsewhere. {/* Security Tips */} Security Tips: • Use a mix of letters, numbers & symbols • Avoid personal information • Don't reuse passwords from other sites {/* Right Side - Form */} {/* Header */} Change Password Your password must be different from previously used passwords. {/* Form Fields */} {/* Password Strength Indicator */} {/* Password Requirements */} {/* Match Indicator */} {formData.confirmPassword && ( {formData.newPassword === formData.confirmPassword ? ( <> Passwords match ) : ( <> Passwords do not match )} )} {/* Submit Button */} {/* Cancel Link */} {/* Success Modal */} ) } export default ChangePasswordPage