-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feat/#29
- Loading branch information
Showing
38 changed files
with
1,034 additions
and
381 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import welcomeLogo from "../assets/welcomeLogo.svg"; | ||
import { FormLayoutProps } from "../types/FormTypes"; | ||
|
||
const FormLayout: React.FC<FormLayoutProps> = ({ title, description, children, onSubmit }) => { | ||
return ( | ||
<div className="form-container"> | ||
<form onSubmit={onSubmit} className="form"> | ||
<h1>{title}</h1> | ||
<p>{description}</p> | ||
{children} | ||
</form> | ||
<div className="rightlogo-container"> | ||
<img src={welcomeLogo} alt="welcomelogo" /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default FormLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from 'react'; | ||
import { InputProps } from "../types/InputTypes"; | ||
const Input: React.FC<InputProps> = ({ type, id, name, placeholder, value, onChange, required = false }) => { | ||
return ( | ||
<div className="form-group"> | ||
<label htmlFor={id}>{placeholder}</label> | ||
<input | ||
type={type} | ||
id={id} | ||
name={name} | ||
placeholder={placeholder} | ||
value={value} | ||
onChange={onChange} | ||
required={required} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Input; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import React, { useState } from 'react'; | ||
import { AiFillEye, AiFillEyeInvisible } from 'react-icons/ai'; | ||
|
||
interface PasswordToggleProps { | ||
password: string; | ||
name: string; | ||
placeholder: string; | ||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void; | ||
} | ||
|
||
const PasswordToggle: React.FC<PasswordToggleProps> = ({ password, name, placeholder, onChange }) => { | ||
const [showPassword, setShowPassword] = useState(false); | ||
|
||
const togglePasswordVisibility = () => { | ||
setShowPassword(!showPassword); | ||
}; | ||
|
||
return ( | ||
<div className="password-container"> | ||
<input | ||
type={showPassword ? "text" : "password"} | ||
name={name} | ||
placeholder={placeholder} | ||
value={password} | ||
onChange={onChange} | ||
required | ||
/> | ||
<button type="button" onClick={togglePasswordVisibility}> | ||
{showPassword ? <AiFillEyeInvisible /> : <AiFillEye />} | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default PasswordToggle; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { useState } from "react"; | ||
import axios from "axios"; | ||
import { User, AuthResponse } from "../types/AuthTypes"; | ||
|
||
const baseurl = 'https://kdt.frontend.5th.programmers.co.kr:5006'; | ||
|
||
export const useAuth = () => { | ||
const [token, setToken] = useState<string | null>(null); | ||
const [user, setUser] = useState<User | null>(null); | ||
|
||
const api = axios.create({ | ||
baseURL: baseurl, | ||
}); | ||
|
||
// 로그인 | ||
const login = async (email: string, password: string) => { | ||
try { | ||
const response = await api.post<AuthResponse>("/login", { | ||
email, | ||
password, | ||
}); | ||
setToken(response.data.token); | ||
setUser(response.data.user); | ||
console.log("로그인 성공", response.data); | ||
} catch (e) { | ||
console.log("실패 cbcb", e); | ||
} | ||
}; | ||
|
||
// 회원가입 | ||
const signup = async (email: string, fullName: string, password: string) => { | ||
try { | ||
const response = await api.post<AuthResponse>("/signup", { | ||
email, | ||
fullName, | ||
password, | ||
}); | ||
setToken(response.data.token); | ||
setUser(response.data.user); | ||
console.log("회원가입 성공", response.data); | ||
} catch (e) { | ||
console.log("실패ㅡㅡ", e); | ||
} | ||
}; | ||
return { login, signup, token, user }; | ||
}; |
Oops, something went wrong.