This commit is contained in:
rizky 2024-08-20 23:10:27 -07:00
parent 06712d6c7a
commit 72c85b75d0
2 changed files with 29 additions and 14 deletions

View File

@ -135,7 +135,7 @@ export const FieldInput: FC<{
{prefix && prefix !== "" ? ( {prefix && prefix !== "" ? (
<div <div
className={cx( className={cx(
"c-px-2 c-flex c-flex-row c-items-center", "c-pl-2 c-flex c-flex-row c-items-center",
css` css`
color: gray; color: gray;
` `
@ -199,7 +199,7 @@ export const FieldInput: FC<{
{suffix && suffix !== "" ? ( {suffix && suffix !== "" ? (
<div <div
className={cx( className={cx(
"c-px-2 c-flex c-flex-row c-items-center", "c-pr-2 c-flex c-flex-row c-items-center",
css` css`
color: gray; color: gray;
` `

View File

@ -3,8 +3,11 @@ import { useLocal } from "lib/utils/use-local";
import { FC, HTMLProps } from "react"; import { FC, HTMLProps } from "react";
navigate; navigate;
export const NavLink: FC< export const NavLink: FC<{
HTMLProps<HTMLAnchorElement> & { className?: string;
href?: string;
children?: any;
back_title?: string;
params?: { params?: {
name?: string; name?: string;
where?: any; where?: any;
@ -12,8 +15,7 @@ export const NavLink: FC<
update?: any; update?: any;
breads?: { label: string; url?: string }[]; breads?: { label: string; url?: string }[];
}; };
} }> = (props) => {
> = (props) => {
const local = useLocal({ loading: false }); const local = useLocal({ loading: false });
let href = props.href || ""; let href = props.href || "";
@ -42,13 +44,26 @@ export const NavLink: FC<
setTimeout(() => { setTimeout(() => {
local.loading = false; local.loading = false;
}, 3000); }, 3000);
} else if (props.back_title) {
local.loading = true;
local.render();
navigate(props.href, { breads: [{ label: props.back_title }] });
setTimeout(() => {
local.loading = false;
}, 3000);
} else { } else {
navigate(props.href); navigate(props.href);
} }
} }
}} }}
> >
{local.loading ? <Spinner /> : props.children} {local.loading ? (
<div className="c-flex c-flex-1 c-items-center c-justify-center c-w-full c-h-full">
<Spinner />
</div>
) : (
props.children
)}
</a> </a>
); );
}; };