Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-CloudComputing
/
C_Team_KhuDrive
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
김재형
2020-06-17 16:34:31 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
afb8ed5b4af20175fe06749750a99707220abf57
afb8ed5b
1 parent
edcdecb8
Implement signup
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
2 deletions
frontend/src/App.tsx
frontend/src/auth/Login.tsx
frontend/src/auth/Signup.tsx
frontend/src/file/FileList.tsx
frontend/src/App.tsx
View file @
afb8ed5
...
...
@@ -2,6 +2,7 @@ import React from "react";
import { Switch, Route, Redirect } from "react-router-dom";
import { Login } from "auth/Login";
import { Signup } from "auth/Signup";
import { useAuth, TokenContext } from "auth/useAuth";
import { Page } from "layout/Page";
...
...
@@ -16,6 +17,9 @@ export function App() {
<Route path="/login">
<Login login={token.login} />
</Route>
<Route path="/signup">
<Signup />
</Route>
<Route>
{token.token !== null ? (
<TokenContext.Provider value={token}>
...
...
frontend/src/auth/Login.tsx
View file @
afb8ed5
import React, { useCallback, useState } from "react";
import { Form, Input, Button, Checkbox, Layout } from "antd";
import { UserOutlined, LockOutlined } from "@ant-design/icons";
import { useHistory } from "react-router-dom";
import { useHistory
, Link
} from "react-router-dom";
import styles from "./Login.module.scss";
...
...
@@ -49,7 +49,7 @@ export function Login({ login }: LoginProps) {
</Form.Item>
<Form.Item
name="password"
rules={[{ required: true, message: "
Please input your Password!
" }]}
rules={[{ required: true, message: "
비밀번호를 입력하세요
" }]}
{...(error && {
validateStatus: "error",
help: "로그인에 실패했습니다",
...
...
@@ -71,6 +71,9 @@ export function Login({ login }: LoginProps) {
<Button type="primary" htmlType="submit">
로그인
</Button>
<Link to="/signup" style={{ marginLeft: 24 }}>
회원가입
</Link>
</Form.Item>
</Form>
</Layout.Content>
...
...
frontend/src/auth/Signup.tsx
0 → 100644
View file @
afb8ed5
import React, { useCallback, useState } from "react";
import { Form, Input, Button, Layout, message } from "antd";
import { UserOutlined, LockOutlined, TagOutlined } from "@ant-design/icons";
import { useHistory } from "react-router-dom";
import styles from "./Login.module.scss";
import ky from "ky";
export function Signup() {
const [error, setError] = useState<boolean>(false);
const [check, setCheck] = useState<boolean>(false);
const history = useHistory();
const handleSignup = useCallback(
async ({ user_id, password, password_check, name }) => {
if (password !== password_check) {
return setCheck(true);
} else {
setCheck(false);
}
setError(false);
try {
const body = new URLSearchParams();
body.set("user_id", user_id);
body.set("password", password);
body.set("name", name);
await ky.post("/users/signup/", { body });
message.success("회원가입이 완료되었습니다");
history.push("/login");
} catch {
setError(true);
}
},
[history]
);
return (
<Layout className={styles.layout}>
<Layout.Content className={styles.content}>
<Form name="signup" onFinish={handleSignup}>
<Form.Item
name="user_id"
rules={[{ required: true, message: "아이디를 입력하세요" }]}
{...(error && {
validateStatus: "error",
})}
>
<Input prefix={<UserOutlined />} placeholder="아이디" />
</Form.Item>
<Form.Item
name="password"
rules={[{ required: true, message: "비밀번호를 입력하세요" }]}
{...(error && {
validateStatus: "error",
help: "로그인에 실패했습니다",
})}
>
<Input
prefix={<LockOutlined />}
type="password"
placeholder="비밀번호"
/>
</Form.Item>
<Form.Item
name="password_check"
rules={[
{ required: true, message: "비밀번호를 한번 더 입력하세요" },
]}
{...(error && {
validateStatus: "error",
help: "로그인에 실패했습니다",
})}
{...(check && {
validateStatus: "error",
help: "비밀번호가 일치하지 않습니다",
})}
>
<Input
prefix={<LockOutlined />}
type="password"
placeholder="비밀번호 확인"
/>
</Form.Item>
<Form.Item
name="name"
rules={[{ required: true, message: "이름을 입력하세요" }]}
{...(error && {
validateStatus: "error",
})}
>
<Input prefix={<TagOutlined />} placeholder="이름" />
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
회원 가입
</Button>
</Form.Item>
</Form>
</Layout.Content>
</Layout>
);
}
frontend/src/file/FileList.tsx
View file @
afb8ed5
...
...
@@ -178,6 +178,9 @@ export function FileList() {
})}
dataSource={list}
pagination={false}
locale={{
emptyText: "파일이 없습니다",
}}
/>
</div>
);
...
...
Please
register
or
login
to post a comment