add isSubmitting state to BeerForm

This commit is contained in:
Aaron William Po
2023-02-20 16:12:42 -05:00
parent c818dc6525
commit cee7942f1c
5 changed files with 37 additions and 9 deletions

View File

@@ -3,11 +3,19 @@ import { FunctionComponent } from 'react';
interface FormButtonProps {
children: string;
type: 'button' | 'submit' | 'reset';
isSubmitting?: boolean;
}
const Button: FunctionComponent<FormButtonProps> = ({ children, type }) => (
const Button: FunctionComponent<FormButtonProps> = ({
children,
type,
isSubmitting = false,
}) => (
// eslint-disable-next-line react/button-has-type
<button type={type} className="btn-primary btn mt-4 w-full rounded-xl">
<button
type={type}
className={`btn btn-primary mt-4 w-full rounded-xl ${isSubmitting ? 'loading' : ''}`}
>
{children}
</button>
);