43 lines
814 B
TypeScript
43 lines
814 B
TypeScript
'use client';
|
|
|
|
import { Loader2Icon } from 'lucide-react';
|
|
|
|
import { Button, type ButtonProps } from '@/shared/shadcn-ui/button';
|
|
|
|
import { useLanguage } from '../language';
|
|
|
|
interface SubmitButtonProps extends ButtonProps {
|
|
title?: string;
|
|
isLoading: boolean;
|
|
}
|
|
|
|
export const SubmitButton = ({
|
|
title = 'common.buttons.login',
|
|
size = 'default',
|
|
type = 'submit',
|
|
className,
|
|
disabled,
|
|
isLoading,
|
|
onClick,
|
|
...props
|
|
}: SubmitButtonProps) => {
|
|
const { t } = useLanguage();
|
|
|
|
return (
|
|
<Button
|
|
onClick={onClick}
|
|
type={type}
|
|
size={size}
|
|
className={className}
|
|
disabled={isLoading || disabled}
|
|
{...props}
|
|
>
|
|
{isLoading ? (
|
|
<Loader2Icon className='animate-spin' />
|
|
) : (
|
|
(props.children ?? t(title))
|
|
)}
|
|
</Button>
|
|
);
|
|
};
|