diff --git a/app/layouts/admin/navbar.tsx b/app/layouts/admin/navbar.tsx index 366faa7..9776ffe 100644 --- a/app/layouts/admin/navbar.tsx +++ b/app/layouts/admin/navbar.tsx @@ -1,4 +1,5 @@ -import { Link } from 'react-router' +import { Button, Popover, PopoverButton, PopoverPanel } from '@headlessui/react' +import { Link, useFetcher } from 'react-router' import { ChevronIcon } from '~/components/icons/chevron' import { NotificationIcon } from '~/components/icons/notification' @@ -7,6 +8,7 @@ import { useAdminContext } from '~/contexts/admin' export const Navbar = () => { const { adminProfile } = useAdminContext() + const fetcher = useFetcher() return (
@@ -21,13 +23,33 @@ export const Navbar = () => { />
-
-
-
- {adminProfile.name} -
- -
+ + +
+
+ {adminProfile.name} +
+ + + + + + + + { >
{group}
{items.map(({ title, url, icon: Icon }) => ( - { > {title} - + ))}
))} diff --git a/app/routes/actions.admin.logout.ts b/app/routes/actions.admin.logout.ts new file mode 100644 index 0000000..a67d82d --- /dev/null +++ b/app/routes/actions.admin.logout.ts @@ -0,0 +1,22 @@ +import { data } from 'react-router' + +import { setStaffLogoutHeaders } from '~/libs/logout-header.server' + +export const action = async () => { + try { + const responseHeaders = setStaffLogoutHeaders() + + return data( + { success: true }, + { headers: responseHeaders, status: 200, statusText: 'OK' }, + ) + } catch { + return data( + { + message: 'Something went wrong', + success: false, + }, + { status: 500 }, + ) + } +}