Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions client/src/pages/Profile.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const Profile = () => {
const [isImageSafe, setImageSafe] = useState(false);
const { authState, dispatchAuth } = useAuth();
const [loading, setLoading] = useState(false);
const [age, setAge] = useState('')
const { logout } = useKindeAuth();

const aboutRef = useRef(null);
Expand Down Expand Up @@ -97,6 +98,12 @@ const Profile = () => {
formData.append('username', username);
formData.append('aboutMe', aboutRef.current.value);
formData.append('gender', genderRef.current.value);
const numericAge = Number(age);
if (isNaN(numericAge) || numericAge < 12 || numericAge > 120) {
setProfileResponse('Error: Please enter a valid age between 12 and 120.');
setLoading(false);
return;
}
formData.append('age', Number(ageRef.current.value));

if (imageFile && isImageSafe) {
Expand Down Expand Up @@ -212,10 +219,9 @@ const Profile = () => {
className="outline-none bg-transparent text-right"
ref={ageRef}
min="12"
max="120"
onChange={(e) => {
if (e.target.value < 12) {
e.target.value = '12';
}
setAge(e.target.value)
}}
/>
</div>
Expand Down
Loading