import React from 'react'
import { Checkbox, Text } from '@chakra-ui/react'
import { adminModeToggle, loggedInUser, adminMode } from '../../stateManagement/userState'
import { useHookstate } from '@hookstate/core'

export default function AdminMode() {
  const user = useHookstate(loggedInUser).get()
  const admin = useHookstate(adminMode).get()

  return (
    <Checkbox size={'lg'} onChange={() => adminModeToggle()} isChecked={admin} isDisabled={!(user.role === 'admin')}>
      <Text mt={'1'}>Administrator Mode</Text>
    </Checkbox>
  )
}