Skip to content

Commit

Permalink
fix user editing
Browse files Browse the repository at this point in the history
  • Loading branch information
EwanLyon committed Aug 10, 2023
1 parent bba851a commit 1c8f93f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 2 additions & 2 deletions apps/nextjs/pages/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ export default function SignUpPage() {
const [username, setUsername] = useState('');
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [dob, setDob] = useState(maxDate);
const [dob, setDob] = useState<Date | undefined>();


const cantSignUp = !Boolean(username) || !Boolean(email)|| !Boolean(dob) || password.length < 8 || maxDate < new Date(dob) || !UsernameRegex.test(username);
const cantSignUp = !Boolean(username) || !Boolean(email)|| !Boolean(dob) || password.length < 8 || maxDate < new Date(dob || Date.now()) || !UsernameRegex.test(username);

return (
<ThemeProvider theme={theme}>
Expand Down
4 changes: 3 additions & 1 deletion apps/nextjs/pages/user/edit-user.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ export default function EditUser() {
}
}

console.log(dateOfBirth);

const maxDate = sub(new Date(), { years: 13 });

return (
Expand Down Expand Up @@ -229,7 +231,7 @@ export default function EditUser() {
<div>Date of birth</div>
<LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={enLocale}>
<DatePicker
value={dateOfBirth}
value={new Date(dateOfBirth || Date.now())}
onChange={(newValue) => {
if (newValue) setDateOfBirth(newValue);
}}
Expand Down

0 comments on commit 1c8f93f

Please sign in to comment.