header.tsx 2.4 KB
Newer Older
Kim, MinGyu's avatar
Kim, MinGyu committed
1
import React, { useReducer, useState } from "react";
2
3
import { Link, Outlet } from "react-router-dom";
import { useAuth } from "../auth/auth.context";
백승민's avatar
theme1    
백승민 committed
4
5
6
7

import "tailwindcss/tailwind.css";

export default function Header() {
8
  const { logout } = useAuth();
Kim, MinGyu's avatar
Kim, MinGyu committed
9
10
11
12
13
14
15
  const [search, setSearch] = useState("");

  const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
    const newvalue = e.target.value;
    setSearch(newvalue);
  };

16
17
  return (
    <div className="flex flex-col ">
Kim, MinGyu's avatar
Kim, MinGyu committed
18
19
      <div className="flex py-10 ">
        <button className="shrink-0  mx-5">
백승민's avatar
백승민 committed
20
          <Link to="/" className="hover:text-sky-300 focus:text-purple-500">
21
22
23
            Travel Report
          </Link>
        </button>
Kim, MinGyu's avatar
Kim, MinGyu committed
24

Kim, MinGyu's avatar
Kim, MinGyu committed
25
        <input
백승민's avatar
백승민 committed
26
          className="md:ml-20 placeholder:text-white focus:outline-none focus:border-y-4 focus:border-l-4 focus:border-sky-500 md:placeholder:text-slate-400 w-20 md:w-1/2 border-y-4 border-l-4 border-sky-300 pl-9 rounded-l-full focus:border-0"
Kim, MinGyu's avatar
Kim, MinGyu committed
27
          placeholder="어디로 여행가고 싶나요?"
Kim, MinGyu's avatar
Kim, MinGyu committed
28
          onChange={handleChange}
Kim, MinGyu's avatar
Kim, MinGyu committed
29
30
        />
        <button className="shrink-0 border-y-4  border-r-4 border-sky-500 rounded-r-full pr-4">
Kim, MinGyu's avatar
Kim, MinGyu committed
31
32
33
          {/* <Link to="/search" state={}>
            검색
          </Link> */}
Kim, MinGyu's avatar
Kim, MinGyu committed
34
35
        </button>

Kim, MinGyu's avatar
Kim, MinGyu committed
36
        <div className="shrink-0 p-3 md:ml-40 h-12">
Kim, MinGyu's avatar
Kim, MinGyu committed
37
          {useAuth().user.isLoggedIn ? (
Kim, MinGyu's avatar
Kim, MinGyu committed
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
            <div className="flex">
              <Link to="/profile" className="mr-2 ">
                프로필
              </Link>
              <div className="border-0 border-r-2"></div>
              <div></div>
              <button
                className="ml-2 mr-2"
                onClick={() => {
                  logout();
                }}
              >
                로그아웃
              </button>
              <div className="border-0 border-r-2"></div>
              <div></div>
            </div>
Kim, MinGyu's avatar
Kim, MinGyu committed
55
56
57
          ) : (
            <button className="shrink-0 bg-white ">
              <Link
백승민's avatar
백승민 committed
58
                className="hover:text-sky-300 focus:text-purple-500"
Kim, MinGyu's avatar
Kim, MinGyu committed
59
60
61
62
63
64
                to="/login"
              >
                로그인
              </Link>
            </button>
          )}
백승민's avatar
theme1    
백승민 committed
65
        </div>
Kim, MinGyu's avatar
Kim, MinGyu committed
66
        <button className="shrink-0 bg-white">
Kim, MinGyu's avatar
Kim, MinGyu committed
67
68
          <Link
            to="/board"
백승민's avatar
백승민 committed
69
            className="hover:text-sky-300 focus:text-purple-500"
Kim, MinGyu's avatar
Kim, MinGyu committed
70
71
72
73
          >
            게시판
          </Link>
        </button>
백승민's avatar
theme1    
백승민 committed
74
      </div>
Kim, MinGyu's avatar
Kim, MinGyu committed
75

76
77
78
79
      <Outlet />
    </div>
  );
}