30 lines
544 B
TypeScript
30 lines
544 B
TypeScript
"use client";
|
|
|
|
import { JSX } from "react";
|
|
import { useFormStatus } from "react-dom";
|
|
|
|
export default function SubmitButton({
|
|
label = "Add User",
|
|
}: {
|
|
label?: string;
|
|
}): JSX.Element {
|
|
const { pending } = useFormStatus();
|
|
|
|
return (
|
|
<button
|
|
type="submit"
|
|
disabled={pending}
|
|
className="btn btn-primary w-full md:w-auto"
|
|
>
|
|
{pending ? (
|
|
<>
|
|
<span className="loading loading-spinner loading-xs"></span>
|
|
Saving...
|
|
</>
|
|
) : (
|
|
label
|
|
)}
|
|
</button>
|
|
);
|
|
}
|