2025-02-27 23:50:46 +08:00
|
|
|
import { Link, useFetcher, useRouteLoaderData } from 'react-router'
|
2025-01-31 19:34:22 +08:00
|
|
|
|
2025-02-01 04:59:28 +08:00
|
|
|
import { Button } from '~/components/ui/button'
|
2025-02-25 06:07:45 +08:00
|
|
|
import { APP } from '~/configs/meta'
|
2025-02-22 17:34:25 +08:00
|
|
|
import { useNewsContext } from '~/contexts/news'
|
2025-02-27 19:37:31 +08:00
|
|
|
import type { loader } from '~/routes/_layout.news'
|
2025-01-31 19:34:22 +08:00
|
|
|
|
|
|
|
|
export const HeaderTop = () => {
|
2025-02-22 17:34:25 +08:00
|
|
|
const { setIsLoginOpen } = useNewsContext()
|
2025-02-27 19:37:31 +08:00
|
|
|
const loaderData = useRouteLoaderData<typeof loader>('routes/_layout.news')
|
2025-02-27 23:50:46 +08:00
|
|
|
const fetcher = useFetcher()
|
2025-02-27 19:37:31 +08:00
|
|
|
|
2025-01-31 19:34:22 +08:00
|
|
|
return (
|
2025-02-28 09:10:45 +08:00
|
|
|
<div className="flex h-[60px] items-center justify-between bg-white px-5 align-middle sm:h-[100px] sm:gap-[15px] sm:px-[50px] sm:py-[20px]">
|
|
|
|
|
<Link
|
|
|
|
|
to="/news"
|
|
|
|
|
className="mt-2 h-full py-2"
|
|
|
|
|
>
|
|
|
|
|
<img
|
|
|
|
|
src={APP.logo}
|
|
|
|
|
alt={APP.title}
|
|
|
|
|
className="h-3/4 w-auto sm:h-full"
|
|
|
|
|
/>
|
|
|
|
|
</Link>
|
|
|
|
|
<div className="hidden h-full items-center py-1.5 font-light whitespace-pre-line sm:flex">
|
|
|
|
|
{APP.description}
|
|
|
|
|
</div>
|
|
|
|
|
<div className="flex items-center gap-[15px]">
|
|
|
|
|
<Button className="h-8 w-auto rounded-none px-3 text-xs sm:h-[50px] sm:w-[150px] sm:text-lg">
|
|
|
|
|
About Us
|
|
|
|
|
</Button>
|
|
|
|
|
{loaderData?.userToken ? (
|
|
|
|
|
<fetcher.Form
|
|
|
|
|
method="POST"
|
|
|
|
|
action="/actions/news/logout"
|
|
|
|
|
>
|
2025-02-27 23:50:46 +08:00
|
|
|
<Button
|
|
|
|
|
variant="newsSecondary"
|
|
|
|
|
className="hidden sm:block"
|
2025-02-28 09:10:45 +08:00
|
|
|
type="submit"
|
2025-02-27 23:50:46 +08:00
|
|
|
>
|
2025-02-28 09:10:45 +08:00
|
|
|
Logout
|
2025-02-27 23:50:46 +08:00
|
|
|
</Button>
|
2025-02-28 09:10:45 +08:00
|
|
|
</fetcher.Form>
|
|
|
|
|
) : (
|
|
|
|
|
<Button
|
|
|
|
|
variant="newsSecondary"
|
|
|
|
|
className="hidden sm:block"
|
|
|
|
|
onClick={() => setIsLoginOpen(true)}
|
|
|
|
|
>
|
|
|
|
|
Masuk
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
2025-01-31 19:34:22 +08:00
|
|
|
</div>
|
2025-02-28 09:10:45 +08:00
|
|
|
</div>
|
2025-01-31 19:34:22 +08:00
|
|
|
)
|
|
|
|
|
}
|