Signup.tsx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. 'use client';
  2. // import Link from '@/components/Link';
  3. // import { useRouter } from 'next/navigation';
  4. // import { ChangeEvent, useState } from 'react';
  5. // import { signIn } from 'next-auth/react';
  6. export default function Signup() {
  7. // const router = useRouter();
  8. // const [loading, setLoading] = useState(false);
  9. // const [formValues, setFormValues] = useState({
  10. // name: '',
  11. // email: '',
  12. // password: '',
  13. // });
  14. // const [error, setError] = useState('');
  15. // const onSubmit = async (e: React.FormEvent) => {
  16. // e.preventDefault();
  17. // setLoading(true);
  18. // setFormValues({ name: '', email: '', password: '' });
  19. // try {
  20. // const res = await fetch('/api/register', {
  21. // method: 'POST',
  22. // body: JSON.stringify(formValues),
  23. // headers: {
  24. // 'Content-Type': 'application/json',
  25. // },
  26. // });
  27. // setLoading(false);
  28. // if (!res.ok) {
  29. // setError((await res.json()).message);
  30. // return;
  31. // }
  32. // signIn(undefined, { callbackUrl: '/' });
  33. // } catch (error: any) {
  34. // setLoading(false);
  35. // setError(error);
  36. // }
  37. // };
  38. // const handleChange = (event: ChangeEvent<HTMLInputElement>) => {
  39. // const { name, value } = event.target;
  40. // setFormValues({ ...formValues, [name]: value });
  41. // };
  42. return (
  43. <>
  44. {/* <div className="text-center mb-4">
  45. <Link href="/" className="mx-auto d-inline-block logo" aria-label="Tabler" />
  46. </div>
  47. <form onSubmit={onSubmit} className="flex-column card card-md">
  48. <div className="card-body">
  49. <h2 className="card-title text-center mb-4">Create new account</h2>
  50. {
  51. error &&
  52. <p className="text-center" style={{color: 'red'}}>{error}</p>
  53. }
  54. <div className="mb-3">
  55. <label className="form-label">Name</label>
  56. <input
  57. required
  58. type="name"
  59. name="name"
  60. value={formValues.name}
  61. onChange={handleChange}
  62. className="form-control"
  63. placeholder="Name"
  64. />
  65. </div>
  66. <div className="mb-3">
  67. <label className="form-label">Email address</label>
  68. <input
  69. required
  70. type="email"
  71. name="email"
  72. value={formValues.email}
  73. onChange={handleChange}
  74. className="form-control"
  75. placeholder="Enter email"
  76. />
  77. </div>
  78. <div className="mb-3">
  79. <label className="form-label">Password</label>
  80. <div className="input-group input-group-flat">
  81. <input
  82. type="password"
  83. name="password"
  84. value={formValues.password}
  85. onChange={handleChange}
  86. className="form-control"
  87. placeholder="Password"
  88. />
  89. </div>
  90. </div>
  91. <div className="form-footer">
  92. <button className="btn btn-primary w-100" disabled={loading}>
  93. {loading ? 'loading...' : 'Create new account'}
  94. </button>
  95. </div>
  96. </div>
  97. </form>
  98. <div className="text-center text-secondary mt-3">
  99. Already have account?
  100. <a className="ml-2" onClick={() => router.push('/api/auth/signin')}>
  101. Sign in</a>
  102. </div> */}
  103. </>
  104. );
  105. }