|
1 | 1 | import React, { useState } from 'react';
|
2 |
| -import { createClient } from '@supabase/supabase-js'; |
| 2 | +import fetchSignUp from '../Controller/fetch.signup'; |
3 | 3 |
|
4 |
| -const supabase = createClient( |
5 |
| - 'https://fsrotjrwllkimiidizgk.supabase.co', |
6 |
| - 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZzcm90anJ3bGxraW1paWRpemdrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzMwMjgzMTQsImV4cCI6MjA0ODYwNDMxNH0.uiFog4O3BbOZhBC1z0LRFTtEE4p4z3PK5VQ5wKrRHzg', |
7 |
| -); |
8 |
| - |
9 |
| -const Signup: React.FC = () => { |
| 4 | +const Login = () => { |
10 | 5 | const [email, setEmail] = useState('');
|
11 | 6 | const [password, setPassword] = useState('');
|
12 |
| - const [name, setName] = useState(''); |
| 7 | + const [admin, setAdmin] = useState(false); |
| 8 | + const [job, setJob] = useState(''); |
| 9 | + const [nickname, setNickName] = useState(''); |
13 | 10 | const [responseMessage, setResponseMessage] = useState('');
|
14 | 11 |
|
15 | 12 | const handleSignUp = async () => {
|
16 |
| - try { |
17 |
| - const { data, error } = await supabase.auth.signUp({ |
18 |
| - email, |
19 |
| - password, |
20 |
| - options: { |
21 |
| - data: { |
22 |
| - name, // ์ฌ์ฉ์ ์ ์ ๋ฉํ๋ฐ์ดํฐ๋ก ์ ๋ฌ |
23 |
| - }, |
24 |
| - }, |
25 |
| - }); |
26 |
| - |
27 |
| - if (error) { |
28 |
| - throw error; |
29 |
| - } |
30 |
| - |
31 |
| - setResponseMessage('Signup successful! Check your email for confirmation.'); |
32 |
| - } catch (error: any) { |
33 |
| - setResponseMessage(error.message || 'Signup failed. Please try again.'); |
34 |
| - } |
| 13 | + const { responseMessage } = await fetchSignUp({ |
| 14 | + email, |
| 15 | + password, |
| 16 | + admin, |
| 17 | + job, |
| 18 | + nickname, |
| 19 | + }); |
| 20 | + setResponseMessage(responseMessage); |
35 | 21 | };
|
36 | 22 |
|
37 | 23 | return (
|
38 |
| - <div style={{ maxWidth: '400px', margin: 'auto', padding: '20px' }}> |
39 |
| - <h1>Sign Up</h1> |
| 24 | + <div className='max-w-md p-5 mx-auto'> |
| 25 | + <h1 className='mb-5 text-2xl font-bold'>Sign Up</h1> |
| 26 | + {/* Nickname */} |
40 | 27 | <input
|
41 | 28 | type='text'
|
42 |
| - placeholder='Name' |
43 |
| - value={name} |
44 |
| - onChange={(e) => setName(e.target.value)} |
45 |
| - style={{ display: 'block', width: '100%', marginBottom: '10px', padding: '8px' }} |
| 29 | + placeholder='nickname' |
| 30 | + value={nickname} |
| 31 | + onChange={(e) => setNickName(e.target.value)} |
| 32 | + className='block w-full p-2 mb-3 border border-gray-300 rounded' |
46 | 33 | />
|
| 34 | + {/* Job */} |
| 35 | + <select |
| 36 | + value={job} |
| 37 | + onChange={(e) => setJob(e.target.value)} |
| 38 | + className='block w-full p-2 mb-3 border border-gray-300 rounded' |
| 39 | + > |
| 40 | + <option value=''>Select your job</option> |
| 41 | + <option value='Front-Developer'>ํ๋ก ํธ ๊ฐ๋ฐ์</option> |
| 42 | + <option value='Back-Developer'>๋ฐฑ์๋ ๊ฐ๋ฐ์</option> |
| 43 | + <option value='Full-Developer'>ํ์คํ ๊ฐ๋ฐ์</option> |
| 44 | + <option value='Designer'>๋์์ด๋</option> |
| 45 | + <option value='Manager'>๊ธฐํ์</option> |
| 46 | + <option value='Student'>ํ์</option> |
| 47 | + </select> |
| 48 | + {/* Email */} |
47 | 49 | <input
|
48 | 50 | type='email'
|
49 | 51 | placeholder='Email'
|
50 | 52 | value={email}
|
51 | 53 | onChange={(e) => setEmail(e.target.value)}
|
52 |
| - style={{ display: 'block', width: '100%', marginBottom: '10px', padding: '8px' }} |
| 54 | + className='block w-full p-2 mb-3 border border-gray-300 rounded' |
53 | 55 | />
|
| 56 | + {/* Password */} |
54 | 57 | <input
|
55 | 58 | type='password'
|
56 | 59 | placeholder='Password'
|
57 | 60 | value={password}
|
58 | 61 | onChange={(e) => setPassword(e.target.value)}
|
59 |
| - style={{ display: 'block', width: '100%', marginBottom: '10px', padding: '8px' }} |
| 62 | + className='block w-full p-2 mb-3 border border-gray-300 rounded' |
60 | 63 | />
|
| 64 | + {/* Sign Up Button */} |
61 | 65 | <button
|
62 | 66 | onClick={handleSignUp}
|
63 | 67 | type='button'
|
64 |
| - style={{ |
65 |
| - width: '100%', |
66 |
| - padding: '10px', |
67 |
| - backgroundColor: '#007bff', |
68 |
| - color: 'white', |
69 |
| - border: 'none', |
70 |
| - borderRadius: '5px', |
71 |
| - }} |
| 68 | + className='w-full p-3 font-bold text-white bg-blue-500 rounded hover:bg-blue-600' |
72 | 69 | >
|
73 | 70 | Sign Up
|
74 | 71 | </button>
|
75 |
| - {responseMessage && <p style={{ marginTop: '20px', color: 'red' }}>{responseMessage}</p>} |
| 72 | + {responseMessage && <p className='mt-5 text-red-500'>{responseMessage}</p>} |
76 | 73 | </div>
|
77 | 74 | );
|
78 | 75 | };
|
79 | 76 |
|
80 |
| -export default Signup; |
| 77 | +export default Login; |
0 commit comments