ResetPasswordPage.tsx 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import { Form, Head } from '@inertiajs/react';
  2. import { LoaderCircle } from 'lucide-react';
  3. import NewPasswordController from '@/actions/App/Http/Controllers/Auth/NewPasswordController';
  4. import { InputError } from '@/common/InputError';
  5. import AuthLayout from '@/pages/layouts/AuthLayout';
  6. import { Button } from '@/shadcn/button';
  7. import { Input } from '@/shadcn/input';
  8. import { Label } from '@/shadcn/label';
  9. interface ResetPasswordProps {
  10. token: string;
  11. email: string;
  12. }
  13. export default function ResetPasswordPage({ token, email }: ResetPasswordProps) {
  14. return (
  15. <AuthLayout title="Reset password" description="Please enter your new password below">
  16. <Head title="Reset password" />
  17. <Form
  18. {...NewPasswordController.store.form()}
  19. transform={(data) => ({ ...data, token, email })}
  20. resetOnSuccess={['password', 'password_confirmation']}
  21. >
  22. {({ processing, errors }) => (
  23. <div className="grid gap-6">
  24. <div className="grid gap-2">
  25. <Label htmlFor="email">Email</Label>
  26. <Input id="email" type="email" name="email" autoComplete="email" value={email} className="mt-1 block w-full" readOnly />
  27. <InputError message={errors.email} className="mt-2" />
  28. </div>
  29. <div className="grid gap-2">
  30. <Label htmlFor="password">Password</Label>
  31. <Input
  32. id="password"
  33. type="password"
  34. name="password"
  35. autoComplete="new-password"
  36. className="mt-1 block w-full"
  37. autoFocus
  38. placeholder="Password"
  39. />
  40. <InputError message={errors.password} />
  41. </div>
  42. <div className="grid gap-2">
  43. <Label htmlFor="password_confirmation">Confirm password</Label>
  44. <Input
  45. id="password_confirmation"
  46. type="password"
  47. name="password_confirmation"
  48. autoComplete="new-password"
  49. className="mt-1 block w-full"
  50. placeholder="Confirm password"
  51. />
  52. <InputError message={errors.password_confirmation} className="mt-2" />
  53. </div>
  54. <Button type="submit" className="mt-4 w-full" disabled={processing}>
  55. {processing && <LoaderCircle className="h-4 w-4 animate-spin" />}
  56. Reset password
  57. </Button>
  58. </div>
  59. )}
  60. </Form>
  61. </AuthLayout>
  62. );
  63. }