2023-03-28 20:36:21 +08:00
|
|
|
import React from 'react';
|
2023-03-14 01:24:43 +08:00
|
|
|
import LogOutIcon from '../svg/LogOutIcon';
|
2023-03-28 20:36:21 +08:00
|
|
|
import { useRecoilValue } from 'recoil';
|
|
|
|
|
import store from '~/store';
|
2023-03-14 01:24:43 +08:00
|
|
|
|
|
|
|
|
export default function Logout() {
|
2023-03-28 20:36:21 +08:00
|
|
|
const user = useRecoilValue(store.user);
|
|
|
|
|
|
2023-03-14 01:24:43 +08:00
|
|
|
const clickHandler = () => {
|
2023-03-28 20:36:21 +08:00
|
|
|
window.location.href = '/auth/logout';
|
2023-03-14 01:24:43 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2023-04-07 19:25:30 +05:30
|
|
|
<button
|
2023-03-14 01:24:43 +08:00
|
|
|
className="flex cursor-pointer items-center gap-3 rounded-md py-3 px-3 text-sm text-white transition-colors duration-200 hover:bg-gray-500/10"
|
|
|
|
|
onClick={clickHandler}
|
|
|
|
|
>
|
|
|
|
|
<LogOutIcon />
|
|
|
|
|
{user?.display || user?.username || 'USER'}
|
|
|
|
|
<small>Log out</small>
|
2023-04-07 19:25:30 +05:30
|
|
|
</button>
|
2023-03-14 01:24:43 +08:00
|
|
|
);
|
|
|
|
|
}
|