RegisterPage.tsx 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. import { Form, Head } from '@inertiajs/react';
  2. import { LoaderCircle } from 'lucide-react';
  3. import RegisteredUserController from '@/actions/App/Http/Controllers/Auth/RegisteredUserController';
  4. import { InputError } from '@/common/InputError';
  5. import { TextLink } from '@/common/TextLink';
  6. import AuthLayout from '@/pages/layouts/AuthLayout';
  7. import { login } from '@/routes';
  8. import { Button } from '@/shadcn/button';
  9. import { Input } from '@/shadcn/input';
  10. import { Label } from '@/shadcn/label';
  11. export default function RegisterPage() {
  12. return (
  13. <AuthLayout title="Create an account" description="Enter your details below to create your account">
  14. <Head title="Register" />
  15. <Form
  16. {...RegisteredUserController.store.form()}
  17. resetOnSuccess={['password', 'password_confirmation']}
  18. disableWhileProcessing
  19. className="flex flex-col gap-6"
  20. >
  21. {({ processing, errors }) => (
  22. <>
  23. <div className="grid gap-6">
  24. <div className="grid gap-2">
  25. <Label htmlFor="name">Name</Label>
  26. <Input
  27. id="name"
  28. type="text"
  29. required
  30. autoFocus
  31. tabIndex={1}
  32. autoComplete="name"
  33. name="name"
  34. placeholder="Full name"
  35. />
  36. <InputError message={errors.name} className="mt-2" />
  37. </div>
  38. <div className="grid gap-2">
  39. <Label htmlFor="email">Email address</Label>
  40. <Input
  41. id="email"
  42. type="email"
  43. required
  44. tabIndex={2}
  45. autoComplete="email"
  46. name="email"
  47. placeholder="email@example.com"
  48. />
  49. <InputError message={errors.email} />
  50. </div>
  51. <div className="grid gap-2">
  52. <Label htmlFor="password">Password</Label>
  53. <Input
  54. id="password"
  55. type="password"
  56. required
  57. tabIndex={3}
  58. autoComplete="new-password"
  59. name="password"
  60. placeholder="Password"
  61. />
  62. <InputError message={errors.password} />
  63. </div>
  64. <div className="grid gap-2">
  65. <Label htmlFor="password_confirmation">Confirm password</Label>
  66. <Input
  67. id="password_confirmation"
  68. type="password"
  69. required
  70. tabIndex={4}
  71. autoComplete="new-password"
  72. name="password_confirmation"
  73. placeholder="Confirm password"
  74. />
  75. <InputError message={errors.password_confirmation} />
  76. </div>
  77. <Button type="submit" className="mt-2 w-full" tabIndex={5}>
  78. {processing && <LoaderCircle className="h-4 w-4 animate-spin" />}
  79. Create account
  80. </Button>
  81. </div>
  82. <div className="text-center text-sm text-muted-foreground">
  83. Already have an account?{' '}
  84. <TextLink href={login()} tabIndex={6}>
  85. Log in
  86. </TextLink>
  87. </div>
  88. </>
  89. )}
  90. </Form>
  91. </AuthLayout>
  92. );
  93. }