|
1 | 1 | 'use client' |
2 | 2 |
|
3 | | -import { useEffect, useMemo, useRef, useState } from 'react' |
| 3 | +import { useMemo, useRef, useState } from 'react' |
4 | 4 | import { Turnstile, type TurnstileInstance } from '@marsidev/react-turnstile' |
5 | 5 | import { createLogger } from '@sim/logger' |
6 | 6 | import { Eye, EyeOff } from 'lucide-react' |
@@ -121,19 +121,6 @@ export default function LoginPage({ |
121 | 121 | : null |
122 | 122 | ) |
123 | 123 |
|
124 | | - useEffect(() => { |
125 | | - const handleKeyDown = (event: KeyboardEvent) => { |
126 | | - if (event.key === 'Enter' && forgotPasswordOpen) { |
127 | | - handleForgotPassword() |
128 | | - } |
129 | | - } |
130 | | - |
131 | | - window.addEventListener('keydown', handleKeyDown) |
132 | | - return () => { |
133 | | - window.removeEventListener('keydown', handleKeyDown) |
134 | | - } |
135 | | - }, [forgotPasswordEmail, forgotPasswordOpen]) |
136 | | - |
137 | 124 | const handleEmailChange = (e: React.ChangeEvent<HTMLInputElement>) => { |
138 | 125 | const newEmail = e.target.value |
139 | 126 | setEmail(newEmail) |
@@ -602,45 +589,51 @@ export default function LoginPage({ |
602 | 589 | <ModalContent className='dark' size='sm'> |
603 | 590 | <ModalHeader>Reset Password</ModalHeader> |
604 | 591 | <ModalBody> |
605 | | - <ModalDescription className='mb-4 text-[var(--text-muted)] text-sm'> |
606 | | - Enter your email address and we'll send you a link to reset your password if your |
607 | | - account exists. |
608 | | - </ModalDescription> |
609 | | - <div className='space-y-4'> |
610 | | - <div className='space-y-2'> |
611 | | - <Label htmlFor='reset-email'>Email</Label> |
612 | | - <Input |
613 | | - id='reset-email' |
614 | | - value={forgotPasswordEmail} |
615 | | - onChange={(e) => setForgotPasswordEmail(e.target.value)} |
616 | | - placeholder='Enter your email' |
617 | | - required |
618 | | - type='email' |
619 | | - className={cn( |
620 | | - resetStatus.type === 'error' && 'border-red-500 focus:border-red-500' |
| 592 | + <form |
| 593 | + onSubmit={(e) => { |
| 594 | + e.preventDefault() |
| 595 | + handleForgotPassword() |
| 596 | + }} |
| 597 | + > |
| 598 | + <ModalDescription className='mb-4 text-[var(--text-muted)] text-sm'> |
| 599 | + Enter your email address and we'll send you a link to reset your password if your |
| 600 | + account exists. |
| 601 | + </ModalDescription> |
| 602 | + <div className='space-y-4'> |
| 603 | + <div className='space-y-2'> |
| 604 | + <Label htmlFor='reset-email'>Email</Label> |
| 605 | + <Input |
| 606 | + id='reset-email' |
| 607 | + value={forgotPasswordEmail} |
| 608 | + onChange={(e) => setForgotPasswordEmail(e.target.value)} |
| 609 | + placeholder='Enter your email' |
| 610 | + required |
| 611 | + type='email' |
| 612 | + className={cn( |
| 613 | + resetStatus.type === 'error' && 'border-red-500 focus:border-red-500' |
| 614 | + )} |
| 615 | + /> |
| 616 | + {resetStatus.type === 'error' && ( |
| 617 | + <div className='mt-1 text-red-400 text-xs'> |
| 618 | + <p>{resetStatus.message}</p> |
| 619 | + </div> |
621 | 620 | )} |
622 | | - /> |
623 | | - {resetStatus.type === 'error' && ( |
624 | | - <div className='mt-1 text-red-400 text-xs'> |
| 621 | + </div> |
| 622 | + {resetStatus.type === 'success' && ( |
| 623 | + <div className='mt-1 text-[#4CAF50] text-xs'> |
625 | 624 | <p>{resetStatus.message}</p> |
626 | 625 | </div> |
627 | 626 | )} |
| 627 | + <BrandedButton |
| 628 | + type='submit' |
| 629 | + disabled={isSubmittingReset} |
| 630 | + loading={isSubmittingReset} |
| 631 | + loadingText='Sending' |
| 632 | + > |
| 633 | + Send Reset Link |
| 634 | + </BrandedButton> |
628 | 635 | </div> |
629 | | - {resetStatus.type === 'success' && ( |
630 | | - <div className='mt-1 text-[#4CAF50] text-xs'> |
631 | | - <p>{resetStatus.message}</p> |
632 | | - </div> |
633 | | - )} |
634 | | - <BrandedButton |
635 | | - type='button' |
636 | | - onClick={handleForgotPassword} |
637 | | - disabled={isSubmittingReset} |
638 | | - loading={isSubmittingReset} |
639 | | - loadingText='Sending' |
640 | | - > |
641 | | - Send Reset Link |
642 | | - </BrandedButton> |
643 | | - </div> |
| 636 | + </form> |
644 | 637 | </ModalBody> |
645 | 638 | </ModalContent> |
646 | 639 | </Modal> |
|
0 commit comments