mirror of
https://github.com/ahmadk953/tasko.git
synced 2025-02-07 11:42:55 +00:00
42 lines
724 B
TypeScript
42 lines
724 B
TypeScript
|
"Use client";
|
||
|
|
||
|
import { useFormStatus } from "react-dom";
|
||
|
|
||
|
import { cn } from "@/lib/utils";
|
||
|
import { Button } from "@/components/ui/button";
|
||
|
|
||
|
interface FormSubmitProps {
|
||
|
children: React.ReactNode;
|
||
|
disabled?: boolean;
|
||
|
className?: string;
|
||
|
variant?:
|
||
|
| "default"
|
||
|
| "destructive"
|
||
|
| "outline"
|
||
|
| "secondary"
|
||
|
| "ghost"
|
||
|
| "link"
|
||
|
| "primary";
|
||
|
}
|
||
|
|
||
|
export const FormSubmit = ({
|
||
|
children,
|
||
|
disabled,
|
||
|
className,
|
||
|
variant = "primary",
|
||
|
}: FormSubmitProps) => {
|
||
|
const { pending } = useFormStatus();
|
||
|
|
||
|
return (
|
||
|
<Button
|
||
|
disabled={pending || disabled}
|
||
|
type="submit"
|
||
|
variant={variant}
|
||
|
size="sm"
|
||
|
className={cn(className)}
|
||
|
>
|
||
|
{children}
|
||
|
</Button>
|
||
|
);
|
||
|
};
|