diff --git a/src/layouts/dashboard.tsx b/src/layouts/dashboard.tsx index be6f6ec..22ad67c 100644 --- a/src/layouts/dashboard.tsx +++ b/src/layouts/dashboard.tsx @@ -1,5 +1,7 @@ import { ReactElement } from 'react' import { NavLink, Outlet } from 'react-router-dom' +import { useQuery } from '@tanstack/react-query' + import { Cog6ToothIcon, HomeIcon, @@ -7,7 +9,14 @@ import { LightBulbIcon } from '@heroicons/react/24/solid' -function Dashboard(): ReactElement { +import { me } from '../api/users' + +export default function Dashboard(): ReactElement { + const { isPending, isError, data } = useQuery({ + queryKey: ['me'], + queryFn: me + }) + return (
-
  • - - `w-full flex items-center gap-x-3.5 py-2 px-2.5 text-sm text-white rounded-lg focus:outline-none focus:ring-1 focus:ring-gray-600 ${ - isActive - ? 'bg-sky-900' - : 'hover:bg-sky-900 hover:text-white-300' - }` - } - > - - Administration - -
  • + {!isPending && + !isError && + data.is_admin && ( +
  • + + `w-full flex items-center gap-x-3.5 py-2 px-2.5 text-sm text-white rounded-lg focus:outline-none focus:ring-1 focus:ring-gray-600 ${ + isActive + ? 'bg-sky-900' + : 'hover:bg-sky-900 hover:text-white-300' + }` + } + > + + Administration + +
  • + )}
    @@ -90,5 +103,3 @@ function Dashboard(): ReactElement {
    ) } - -export default Dashboard