2025-03-03 19:03:04 +08:00
|
|
|
import { Button, Popover, PopoverButton, PopoverPanel } from '@headlessui/react'
|
2025-03-03 19:10:50 +08:00
|
|
|
import { Link, useFetcher, useRouteLoaderData } from 'react-router'
|
2025-02-23 17:00:17 +08:00
|
|
|
|
2025-02-24 14:10:15 +07:00
|
|
|
import { ChevronIcon } from '~/components/icons/chevron'
|
2025-03-04 04:41:59 +07:00
|
|
|
import { ProfileIcon } from '~/components/icons/profile'
|
2025-02-25 06:07:45 +08:00
|
|
|
import { APP } from '~/configs/meta'
|
2025-03-03 19:10:50 +08:00
|
|
|
import type { loader } from '~/routes/_admin.lg-admin'
|
2025-02-23 17:00:17 +08:00
|
|
|
|
2025-02-23 12:18:10 +08:00
|
|
|
export const Navbar = () => {
|
2025-03-03 19:10:50 +08:00
|
|
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_admin.lg-admin')
|
|
|
|
|
const staffData = loaderData?.staffData
|
2025-03-03 19:03:04 +08:00
|
|
|
const fetcher = useFetcher()
|
2025-02-23 17:41:54 +08:00
|
|
|
|
2025-02-23 17:00:17 +08:00
|
|
|
return (
|
|
|
|
|
<div className="flex h-20 items-center justify-between border-b border-[#ECECEC] bg-white px-10 py-5">
|
|
|
|
|
<Link
|
2025-02-28 11:49:51 +08:00
|
|
|
to="/"
|
2025-02-23 17:00:17 +08:00
|
|
|
className="h-full"
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
src={APP.logo}
|
|
|
|
|
alt={APP.title}
|
|
|
|
|
className="h-3/4 w-auto sm:h-full"
|
|
|
|
|
/>
|
|
|
|
|
</Link>
|
2025-02-23 17:41:54 +08:00
|
|
|
<div className="flex items-center gap-x-8">
|
2025-03-03 19:03:04 +08:00
|
|
|
<Popover className="relative">
|
|
|
|
|
<PopoverButton className="flex w-3xs cursor-pointer items-center justify-between focus:outline-none">
|
|
|
|
|
<div className="flex items-center">
|
2025-03-04 04:41:59 +07:00
|
|
|
{staffData?.profile_picture === '' ? (
|
|
|
|
|
<ProfileIcon className="mr-3 h-8 w-8 rounded-full bg-[#C4C4C4]" />
|
|
|
|
|
) : (
|
|
|
|
|
<img
|
|
|
|
|
src={staffData?.profile_picture}
|
|
|
|
|
alt={staffData?.name}
|
|
|
|
|
className="mr-3 h-8 w-8 rounded-full bg-[#C4C4C4] object-cover"
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
|
2025-03-03 19:10:50 +08:00
|
|
|
<span className="text-xs">{staffData?.name}</span>
|
2025-03-03 19:03:04 +08:00
|
|
|
</div>
|
|
|
|
|
<ChevronIcon className="opacity-50" />
|
|
|
|
|
</PopoverButton>
|
|
|
|
|
<PopoverPanel
|
|
|
|
|
anchor={{ to: 'bottom', gap: '8px' }}
|
|
|
|
|
transition
|
|
|
|
|
className="flex w-3xs flex-col rounded-xl border border-[#ECECEC] bg-white p-3 transition duration-200 ease-in-out data-[closed]:-translate-y-1 data-[closed]:opacity-0"
|
|
|
|
|
>
|
|
|
|
|
<fetcher.Form
|
|
|
|
|
method="POST"
|
|
|
|
|
action="/actions/admin/logout"
|
|
|
|
|
className="grid"
|
|
|
|
|
>
|
|
|
|
|
<Button
|
|
|
|
|
type="submit"
|
|
|
|
|
className="cursor-pointer rounded p-1 hover:bg-[#707FDD]/10 hover:text-[#5363AB]"
|
|
|
|
|
>
|
|
|
|
|
Logout
|
|
|
|
|
</Button>
|
|
|
|
|
</fetcher.Form>
|
|
|
|
|
</PopoverPanel>
|
|
|
|
|
</Popover>
|
2025-02-23 17:00:17 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
2025-02-23 12:18:10 +08:00
|
|
|
}
|