Commit ed3a5413 authored by baesangjune's avatar baesangjune
Browse files

중간

parent 1c18d0e1
......@@ -6,6 +6,7 @@ import { signin } from "./api-auth";
import auth from "./auth-helpers";
import { Redirect } from "react-router-dom";
import { useAuth } from "./auth-context";
import { Link } from "react-router-dom"
function Signin() {
const { setAuthUser } = useAuth();
......@@ -45,6 +46,7 @@ function Signin() {
return (
<Container className="col-sm-6 col-md-5 col-lg-4 p-5">
<h1 className="text-center mt-1 pb-3 font-italic text-danger">Korea<br />University</h1>
<Form>
<Form.Group controlId="email">
<Form.Label>Email</Form.Label>
......@@ -62,16 +64,20 @@ function Signin() {
<Form.Label>Password</Form.Label>
<Form.Control
type="password"
placeholder="Password"
placeholder="Enter Password"
onChange={handleChange("password")}
/>
</Form.Group>
<Button variant="primary" type="submit" onClick={clickSubmit}>
Submit
<Button block variant="danger" type="submit" onClick={clickSubmit}>
Sign in
</Button>
<Link to="/signup">
<Button block className="text-left" variant="default">New Account</Button>
</Link>
</Form>
</Container>
);
}
......
import React from 'react'
import Signin from '../auth/Signin'
import { useAuth } from "../auth/auth-context"
import Warning from './Warning'
function Home() {
const { authUser } = useAuth()
return (
<div>
Home
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/>
{authUser ? <Warning/>:<Signin />}
</div>
)
}
export default Home
import React, { useState } from "react"
import { useAuth } from "../auth/auth-context"
import Form from "react-bootstrap/Form";
import Container from "react-bootstrap/Container";
import { read as readUser } from '../user/api-user';
import { read as readCourse } from '../course/api-course';
import { useEffect } from "react";
function Warning() {
const { authUser } = useAuth()
useEffect(() => {
readUser(authUser.user._id, { t: authUser.token }).then(res => {
setData(res);
})
readCourse("5f7fc9071575948025e29ebb", { t: authUser.token }).then(res => {
console.log(res);
setCourse(res);
})
}, [])
const [data, setData] = useState({ name: "", })
const [course, setCourse] = useState({ name: "", description: "", code: "", })
return (
<div>
<Container className="col-sm-6 col-md-5 col-lg-4 p-5">
{console.log(data)}
<Form.Text className="text-muted">
<h1 className="text-center mt-1 pb-3 font-italic text-danger">Korea University</h1>
<p>응시자 정보 </p>
<p>이름 : {data.name}</p>
<p>e-mail : {data.email}</p>
<p>응시 과목 :{course.name}</p>
<p>담당 교수 :{course.description}</p>
{/* <p>시험문제 수 :</p>
<p>시험 시간 : </p>
<p>공지 사항 : </p> */}
</Form.Text>
</Container>
</div>
)
}
export default Warning
\ No newline at end of file
......@@ -14,6 +14,22 @@ const list = async (signal) => {
}
}
const read = async (courseId, credentials) => {
try {
const response = await fetch('/api/courses/' + courseId, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + credentials.t,
},
})
return await response.json()
} catch (error) {
console.log(error)
}
}
export {
list,
list, read
}
......@@ -47,6 +47,9 @@ function Signup() {
return (
<Container fluid>
<div>
<h1 className="mt-3 text-center mt-1 pb-3 font-italic text-danger">Korea<br/> University</h1>
</div>
<Row className="justify-content-center">
<Col className="col-sm-6 col-md-7">
<Form>
......
......@@ -14,6 +14,23 @@ const create = async (user) => {
}
}
const read = async (userId, credentials) => {
try {
const response = await fetch('/api/users/' + userId, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + credentials.t,
},
})
return await response.json()
} catch (error) {
console.log(error)
}
}
export {
create,
read,
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment