fix: update button components to include loading state and improve styling in navbar and login page

This commit is contained in:
Ardeman 2025-03-11 06:08:20 +08:00
parent dbeec8acf3
commit 66bc731b07
2 changed files with 13 additions and 9 deletions

View File

@ -1,8 +1,9 @@
import { Button, Popover, PopoverButton, PopoverPanel } from '@headlessui/react' import { Popover, PopoverButton, PopoverPanel } from '@headlessui/react'
import { Link, useFetcher, useRouteLoaderData } from 'react-router' import { Link, useFetcher, useRouteLoaderData } from 'react-router'
import { ChevronIcon } from '~/components/icons/chevron' import { ChevronIcon } from '~/components/icons/chevron'
import { ProfileIcon } from '~/components/icons/profile' import { ProfileIcon } from '~/components/icons/profile'
import { Button } from '~/components/ui/button'
import { APP } from '~/configs/meta' import { APP } from '~/configs/meta'
import type { loader } from '~/routes/_admin.lg-admin' import type { loader } from '~/routes/_admin.lg-admin'
@ -52,8 +53,10 @@ export const Navbar = () => {
className="grid" className="grid"
> >
<Button <Button
disabled={fetcher.state !== 'idle'}
isLoading={fetcher.state !== 'idle'}
type="submit" type="submit"
className="cursor-pointer rounded p-1 hover:bg-[#707FDD]/10 hover:text-[#5363AB]" className="w-full rounded p-1"
> >
Logout Logout
</Button> </Button>

View File

@ -23,14 +23,12 @@ export const AdminLoginPage = () => {
resolver: zodResolver(loginSchema), resolver: zodResolver(loginSchema),
}) })
const [error, setError] = useState<string>() const [error, setError] = useState<string>()
const [disabled, setDisabled] = useState(false)
const { handleSubmit } = formMethods const { handleSubmit } = formMethods
useEffect(() => { useEffect(() => {
if (!fetcher.data?.success) { if (!fetcher.data?.success) {
setError(fetcher.data?.message) setError(fetcher.data?.message)
setDisabled(false)
return return
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
@ -81,18 +79,21 @@ export const AdminLoginPage = () => {
{/* Lupa Kata Sandi */} {/* Lupa Kata Sandi */}
<div className="mb-4 flex justify-between"> <div className="mb-4 flex justify-between">
<span className="text-gray-600">Lupa Kata Sandi?</span> <span className="text-gray-600">Lupa Kata Sandi?</span>
<Link <Button
as={Link}
variant={'link'}
size="fit"
to="/lg-admin/auth/reset-password" to="/lg-admin/auth/reset-password"
className="font-semibold text-[#2E2F7C]"
> >
Reset Kata Sandi Reset Kata Sandi
</Link> </Button>
</div> </div>
<Button <Button
disabled={disabled} isLoading={fetcher.state !== 'idle'}
disabled={fetcher.state !== 'idle'}
type="submit" type="submit"
className="w-full rounded-md bg-[#2E2F7C] py-2 text-white transition hover:bg-blue-800" className="w-full rounded-md py-2"
> >
Masuk Masuk
</Button> </Button>