import { Button } from 'antd'
import React from 'react'

import auth from 'apiClient/auth'

export default function PermissionErrorContent({
  method,
  url
}: {
  method: string
  url: string
}) {
  const email = localStorage.getItem('sign_in_email')

  const handleSwitch = () => {
    auth.logout()
  }

  return (
    <>
      Forbidden: Your current account {email && <strong>{email}</strong>}{' '}
      doesn't have the permission to access this resource, please contact the
      administrator.
      <br />
      Request Method=<b>{method}</b> URL=<b>{url}</b>
      <Button
        type="link"
        onClick={handleSwitch}
        style={{ display: 'inline-block' }}
      >
        Switch Account
      </Button>
    </>
  )
}
