import styled, { css } from 'styled-components/macro'

import { isMobileDevice } from 'config/userAgent'
import { devices } from 'config'

import { useAuthStore } from 'features/AuthStore'
import { T9n } from 'features/T9n'

const Button = styled.button`
  border: none;
  background-color: transparent;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  font-weight: 500;
  font-size: 1.2rem;
  color: #FFFFFF;
  
  @media ${devices.tablet} {
    font-size: 2.8rem;
    position: static;
  }
`

const ExitIcon = styled.span`
  width: 24px;
  height: 24px;
  background-image: url(/images/logout.svg);
  background-repeat: no-repeat;
  background-size: contain;
  background-position: left;
  margin-right: 15px;

  ${isMobileDevice
    ? css`
     width: 19px;
     height: 19px;
    `
    : ''};
`

export const LogoutButton = () => {
  const { logout } = useAuthStore()

  return (
    <Button onClick={() => logout()}>
      <ExitIcon />
      <T9n t='logout' />
    </Button>
  )
}
