mirror of
https://github.com/umami-software/umami.git
synced 2026-02-18 03:25:40 +01:00
Fix build type errors in LinkButton and useMessages
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
6a9e732457
commit
365895c389
2 changed files with 16 additions and 14 deletions
|
|
@ -25,17 +25,15 @@ export function LinkButton({
|
||||||
}: LinkButtonProps) {
|
}: LinkButtonProps) {
|
||||||
const { dir } = useLocale();
|
const { dir } = useLocale();
|
||||||
|
|
||||||
return (
|
const linkElement = asAnchor ? (
|
||||||
<Button {...props} variant={variant} asChild>
|
<a href={href} target={target}>
|
||||||
{asAnchor ? (
|
{children}
|
||||||
<a href={href} target={target}>
|
</a>
|
||||||
{children}
|
) : (
|
||||||
</a>
|
<Link href={href} dir={dir} scroll={scroll} target={target} prefetch={prefetch}>
|
||||||
) : (
|
{children}
|
||||||
<Link href={href} dir={dir} scroll={scroll} target={target} prefetch={prefetch}>
|
</Link>
|
||||||
{children}
|
|
||||||
</Link>
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return <Button {...props} variant={variant} render={linkElement} />;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,12 +7,16 @@ export function useMessages() {
|
||||||
|
|
||||||
const getMessage = (id: string) => t(`message.${id}`);
|
const getMessage = (id: string) => t(`message.${id}`);
|
||||||
|
|
||||||
const getErrorMessage = (error: ApiError) => {
|
const getErrorMessage = (error: string | Error | undefined) => {
|
||||||
if (!error) {
|
if (!error) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const code = error?.code;
|
if (typeof error === 'string') {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const code = (error as ApiError)?.code;
|
||||||
|
|
||||||
return code ? getMessage(code) : error?.message || 'Unknown error';
|
return code ? getMessage(code) : error?.message || 'Unknown error';
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue