|
| 1 | +import { Link, useForm } from '@inertiajs/react' |
| 2 | +import { FormEvent } from 'react' |
| 3 | + |
| 4 | +export default function Register() { |
| 5 | + const { data, setData, post, processing, errors } = useForm({ |
| 6 | + username: '', |
| 7 | + name: '', |
| 8 | + email: '', |
| 9 | + password: '', |
| 10 | + }) |
| 11 | + |
| 12 | + function handleSubmit(e: FormEvent) { |
| 13 | + e.preventDefault() |
| 14 | + post('/register') |
| 15 | + } |
| 16 | + |
| 17 | + return ( |
| 18 | + <div className="min-h-screen bg-gray-50"> |
| 19 | + <div className="grid lg:grid-cols-2 h-screen"> |
| 20 | + <div className="flex flex-col justify-center px-4 sm:px-6 lg:flex-none lg:px-20 xl:px-24"> |
| 21 | + <div className="mx-auto w-full max-w-sm lg:w-96"> |
| 22 | + <div className="text-center"> |
| 23 | + <h2 className="mt-6 text-2xl font-bold text-gray-900"> |
| 24 | + Ouvrez votre esprit pour découvrir de nouveaux horizons. |
| 25 | + </h2> |
| 26 | + </div> |
| 27 | + |
| 28 | + <div className="mt-8"> |
| 29 | + <div className="mt-6"> |
| 30 | + <form onSubmit={handleSubmit} className="space-y-6"> |
| 31 | + <div> |
| 32 | + <label htmlFor="username" className="block text-sm font-medium text-gray-700"> |
| 33 | + Username |
| 34 | + </label> |
| 35 | + <input |
| 36 | + type="text" |
| 37 | + id="username" |
| 38 | + value={data.username} |
| 39 | + onChange={(e) => setData('username', e.target.value)} |
| 40 | + className="mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" |
| 41 | + /> |
| 42 | + {errors.username && ( |
| 43 | + <p className="mt-1 text-sm text-red-600">{errors.username}</p> |
| 44 | + )} |
| 45 | + </div> |
| 46 | + |
| 47 | + <div> |
| 48 | + <label htmlFor="name" className="block text-sm font-medium text-gray-700"> |
| 49 | + Full Name |
| 50 | + </label> |
| 51 | + <input |
| 52 | + type="text" |
| 53 | + id="name" |
| 54 | + value={data.name} |
| 55 | + onChange={(e) => setData('name', e.target.value)} |
| 56 | + className="mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" |
| 57 | + /> |
| 58 | + {errors.name && <p className="mt-1 text-sm text-red-600">{errors.name}</p>} |
| 59 | + </div> |
| 60 | + |
| 61 | + <div> |
| 62 | + <label htmlFor="email" className="block text-sm font-medium text-gray-700"> |
| 63 | + Email |
| 64 | + </label> |
| 65 | + <input |
| 66 | + type="email" |
| 67 | + id="email" |
| 68 | + value={data.email} |
| 69 | + onChange={(e) => setData('email', e.target.value)} |
| 70 | + className="mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" |
| 71 | + /> |
| 72 | + {errors.email && <p className="mt-1 text-sm text-red-600">{errors.email}</p>} |
| 73 | + </div> |
| 74 | + |
| 75 | + <div> |
| 76 | + <label htmlFor="password" className="block text-sm font-medium text-gray-700"> |
| 77 | + Password |
| 78 | + </label> |
| 79 | + <input |
| 80 | + type="password" |
| 81 | + id="password" |
| 82 | + value={data.password} |
| 83 | + onChange={(e) => setData('password', e.target.value)} |
| 84 | + className="mt-1 block w-full rounded-md border border-gray-300 px-3 py-2 shadow-sm focus:border-indigo-500 focus:outline-none focus:ring-indigo-500 sm:text-sm" |
| 85 | + /> |
| 86 | + {errors.password && ( |
| 87 | + <p className="mt-1 text-sm text-red-600">{errors.password}</p> |
| 88 | + )} |
| 89 | + </div> |
| 90 | + |
| 91 | + <div> |
| 92 | + <button |
| 93 | + type="submit" |
| 94 | + disabled={processing} |
| 95 | + className="flex w-full justify-center rounded-md border border-transparent bg-indigo-600 py-2 px-4 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2" |
| 96 | + > |
| 97 | + Create Account |
| 98 | + </button> |
| 99 | + </div> |
| 100 | + </form> |
| 101 | + |
| 102 | + <div className="mt-6"> |
| 103 | + <div className="relative"> |
| 104 | + <div className="absolute inset-0 flex items-center"> |
| 105 | + <div className="w-full border-t border-gray-300" /> |
| 106 | + </div> |
| 107 | + <div className="relative flex justify-center text-sm"> |
| 108 | + <span className="bg-gray-50 px-2 text-gray-500">Or continue with</span> |
| 109 | + </div> |
| 110 | + </div> |
| 111 | + |
| 112 | + <div className="mt-6"> |
| 113 | + <Link |
| 114 | + href="/auth/github" |
| 115 | + className="flex w-full items-center justify-center gap-3 rounded-md bg-[#24292F] px-3 py-1.5 text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-[#24292F]" |
| 116 | + > |
| 117 | + <svg className="h-5 w-5" fill="currentColor" viewBox="0 0 20 20"> |
| 118 | + <path |
| 119 | + fillRule="evenodd" |
| 120 | + d="M10 0C4.477 0 0 4.484 0 10.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.531 1.032 1.531 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0110 4.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.203 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.942.359.31.678.921.678 1.856 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0020 10.017C20 4.484 15.522 0 10 0z" |
| 121 | + clipRule="evenodd" |
| 122 | + /> |
| 123 | + </svg> |
| 124 | + <span className="text-sm font-semibold leading-6">GitHub</span> |
| 125 | + </Link> |
| 126 | + </div> |
| 127 | + </div> |
| 128 | + </div> |
| 129 | + </div> |
| 130 | + </div> |
| 131 | + </div> |
| 132 | + <div className="relative hidden lg:block"> |
| 133 | + <img |
| 134 | + className="absolute inset-0 h-full w-full object-cover" |
| 135 | + src="https://images.unsplash.com/photo-1505904267569-f02eaeb45a4c?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1908&q=80" |
| 136 | + alt="" |
| 137 | + /> |
| 138 | + </div> |
| 139 | + </div> |
| 140 | + </div> |
| 141 | + ) |
| 142 | +} |
0 commit comments