Skip to content

Commit 24f4ca1

Browse files
committed
✨: Signup 페이지 구현 및 Post요청 확인
1 parent 9f2132b commit 24f4ca1

File tree

4 files changed

+103
-3
lines changed

4 files changed

+103
-3
lines changed

front/src/App.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom';
2+
import Signup from './Page/Signup';
23
import MyTest from './Page/MyTest';
34

45
const App = () => {
56
return (
67
<Router>
78
<Routes>
89
<Route path='/' element={<MyTest />} />
10+
<Route path='/Signup' element={<Signup />} />
911
</Routes>
1012
</Router>
1113
);

front/src/Module/fetch.instance.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import axios from 'axios';
2+
3+
const axiosInstance = axios.create({
4+
baseURL: 'https://fsrotjrwllkimiidizgk.supabase.co', // Supabase API Base URL
5+
headers: {
6+
'Content-Type': 'application/json',
7+
apikey:
8+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZzcm90anJ3bGxraW1paWRpemdrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzMwMjgzMTQsImV4cCI6MjA0ODYwNDMxNH0.uiFog4O3BbOZhBC1z0LRFTtEE4p4z3PK5VQ5wKrRHzg',
9+
},
10+
});
11+
12+
export default axiosInstance;

front/src/Page/Signup.tsx

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import React, { useState } from 'react';
2+
import { createClient } from '@supabase/supabase-js';
3+
4+
const supabase = createClient(
5+
'https://fsrotjrwllkimiidizgk.supabase.co',
6+
'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6ImZzcm90anJ3bGxraW1paWRpemdrIiwicm9sZSI6ImFub24iLCJpYXQiOjE3MzMwMjgzMTQsImV4cCI6MjA0ODYwNDMxNH0.uiFog4O3BbOZhBC1z0LRFTtEE4p4z3PK5VQ5wKrRHzg',
7+
);
8+
9+
const Signup: React.FC = () => {
10+
const [email, setEmail] = useState('');
11+
const [password, setPassword] = useState('');
12+
const [name, setName] = useState('');
13+
const [responseMessage, setResponseMessage] = useState('');
14+
15+
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+
}
35+
};
36+
37+
return (
38+
<div style={{ maxWidth: '400px', margin: 'auto', padding: '20px' }}>
39+
<h1>Sign Up</h1>
40+
<input
41+
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' }}
46+
/>
47+
<input
48+
type='email'
49+
placeholder='Email'
50+
value={email}
51+
onChange={(e) => setEmail(e.target.value)}
52+
style={{ display: 'block', width: '100%', marginBottom: '10px', padding: '8px' }}
53+
/>
54+
<input
55+
type='password'
56+
placeholder='Password'
57+
value={password}
58+
onChange={(e) => setPassword(e.target.value)}
59+
style={{ display: 'block', width: '100%', marginBottom: '10px', padding: '8px' }}
60+
/>
61+
<button
62+
onClick={handleSignUp}
63+
type='button'
64+
style={{
65+
width: '100%',
66+
padding: '10px',
67+
backgroundColor: '#007bff',
68+
color: 'white',
69+
border: 'none',
70+
borderRadius: '5px',
71+
}}
72+
>
73+
Sign Up
74+
</button>
75+
{responseMessage && <p style={{ marginTop: '20px', color: 'red' }}>{responseMessage}</p>}
76+
</div>
77+
);
78+
};
79+
80+
export default Signup;

front/src/index.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
import React from 'react';
22
import ReactDOM from 'react-dom/client';
3+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
34
import './index.css';
45
import App from './App';
56
import reportWebVitals from './reportWebVitals';
67

8+
const queryClient = new QueryClient();
9+
710
const root = ReactDOM.createRoot(document.getElementById('root') as HTMLElement);
811
root.render(
9-
<React.StrictMode>
10-
<App />
11-
</React.StrictMode>,
12+
<QueryClientProvider client={queryClient}>
13+
<React.StrictMode>
14+
<App />
15+
</React.StrictMode>
16+
,
17+
</QueryClientProvider>,
1218
);
1319

1420
// If you want to start measuring performance in your app, pass a function

0 commit comments

Comments
 (0)