Fakultas Ilmu Komputer UI

Sidebar.jsx 2.07 KB
Newer Older
1
2
3
4
5
6
7
8
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
import React from "react";
import { css } from "@emotion/core";
import { Center } from "./html/html";
import Logo from "./Logo";
import LinkSidebar from "./LinkSidebar";
import { useAuthContext } from "../utils/contex";
import styled from "@emotion/styled";

const logout = (token) => {
  fetch(`${process.env.REACT_APP_BASE_URL}/auth/logout/`, {
    method: "POST",
    headers: {
      Authorization: `Token ${token}`,
    },
  });
};

const Sidebar = () => {
  const { handleLogout, profile } = useAuthContext();
  return (
    <Center
      css={css`
        height: 100%;
        border: 1px solid #e0e0e0;
        box-sizing: border-box;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        background-color: white;
        align-items: center;
        justify-content: stretch;
      `}
    >
      <div
        css={css`
          margin-top: 12vh;
        `}
      />
      <Logo />
      <div
        css={css`
          margin-top: 2rem;
          font-style: normal;
          font-weight: 600;
          font-size: 24px;
          line-height: 29px;
          text-align: center;
          letter-spacing: 0.2em;
          margin-bottom: 4rem;
        `}
      >
        ADMIN DASHBOARD
      </div>
      <LinkSidebar to="/produk">PRODUK</LinkSidebar>
      <LinkSidebar to="/transaksi">TRANSAKSI</LinkSidebar>
      <LinkSidebar to="/program">PROGRAM</LinkSidebar>
55
      <LinkSidebar to="/donasi">DONASI</LinkSidebar>
56
57
58
59
60
61
62
63
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
      <LinkSidebar to="/pengguna">PENGGUNA</LinkSidebar>
      <Center
        css={css`
          width: 100%;
          text-align: center;
          height: 2.5rem;
        `}
      >
        <StyledA
          data-testid="logout"
          onClick={() => {
            logout(profile.token.repeat(1));
            handleLogout();
          }}
        >
          LOGOUT
        </StyledA>
      </Center>
    </Center>
  );
};

export default Sidebar;

const StyledA = styled.a`
  text-decoration: none;
  font-style: normal;
  font-weight: normal;
  font-size: 14px;
  line-height: 17px;
  letter-spacing: 0.2em;
  text-align: center;
  color: #3c8dbc;
  cursor: pointer;
`;