login.tsx 2.51 KB
Newer Older
Kim, MinGyu's avatar
Kim, MinGyu committed
1
2
import { Link } from "react-router-dom";
import React, { useState, FormEventHandler } from "react";
Kim, MinGyu's avatar
처음    
Kim, MinGyu committed
3

Kim, MinGyu's avatar
Kim, MinGyu committed
4
interface login {
Kim, MinGyu's avatar
Kim, MinGyu committed
5
6
  id: string;
  password: string;
Kim, MinGyu's avatar
Kim, MinGyu committed
7
}
Kim, MinGyu's avatar
signup    
Kim, MinGyu committed
8

Kim, MinGyu's avatar
Kim, MinGyu committed
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// const fake = { id: "asdf", password: "qwer" };

function Logindata() {
  const [id, setId] = useState("");
  const [password, setPassword] = useState("");

  function login() {
    fetch(`http://localhost:3000/api/auth/login`, {
      method: "POST",

      body: JSON.stringify({
        email: `${id}`,
        password: `${password}`,
      }),
    }).then((response) => {
      console.log(response.json());
    });
  }
  return (
    <div className="flex flex-col md:w-2/3 md:gap-2">
      <input
        className="placeholder:text-slate-300
                bg-white border border-slate-500 rounded-2xl
                py-2 pl-9 pr-3 
                focus:border-black
                "
        placeholder="Id"
        type="text"
        name="Id"
        onChange={(e) => setId(e.target.value)}
      />
      <input
        className="placeholder:italic placeholder:text-slate-300
                bg-white border border-slate-500 rounded-2xl
                py-2 pl-9 pr-3 
                focus:border-black
                "
        placeholder="Password"
        type="password"
        name="Password"
        onChange={(e) => setPassword(e.target.value)}
      />

      <button
        type="submit"
        className="md:w-1/3 bg-sky-600 hover:bg-sky-700 rounded-xl"
        onClick={login}
      >
        <Link to={"/"}>login</Link>
      </button>
Kim, MinGyu's avatar
Kim, MinGyu committed
59
    </div>
Kim, MinGyu's avatar
Kim, MinGyu committed
60
  );
Kim, MinGyu's avatar
Kim, MinGyu committed
61
62
63
}

export default function Login() {
Kim, MinGyu's avatar
Kim, MinGyu committed
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
  return (
    <div>
      {/* <form onSubmit={loginsubmit}> */}
      <div className="flex flex-row grid grid-rows-2">
        <div className=" p-12 w-1/2 h-1/2 md:w-40 md:h-40 bg-red-400 place-self-center rounded-2xl">
          <Link to="/">Travel Report</Link>
        </div>

        <div className=" flex-row w-auto h-60 md:w-1/2 bg-white border-2 border-black grid place-items-center rounded-xl place-self-center">
          <div className="flex flex-col w-full  md:flex-row md:p-20 md:gap-10">
            <Logindata />
          </div>
          <div className="flex-row grid grid-cols-3">
            <button className="bg-white bottom-0 right-0">
              <Link to="/signup">회원가입</Link>
            </button>
            <div></div>
            <button className="bg-white inset-x-0">
              <Link to="/forgot">비밀번호 찾기</Link>
            </button>
          </div>
        </div>
      </div>
      {/* </form> */}
    </div> // Login Page
  );
}