Files
pterodactyl-panel/resources/scripts/components/form/SubmitButton.tsx
T
6c0413e39b Start 2.0 development
Co-authored-by: Anthony <anthony@infraly.co>
Co-authored-by: Sky Mulley <daniel.mulley@outlook.com>
2026-10-05 18:10:18 -04:00

21 lines
769 B
TypeScript

import React from 'react';
import { useFormContext } from './context';
import Button from '@/components/elements/Button';
type Props = Omit<React.ComponentProps<typeof Button>, 'type'>;
/** Disabled while the form cannot submit; shows a spinner while it submits. */
export function SubmitButton({ children, disabled, ...props }: Props) {
const form = useFormContext();
return (
<form.Subscribe selector={(state) => ({ canSubmit: state.canSubmit, isSubmitting: state.isSubmitting })}>
{({ canSubmit, isSubmitting }) => (
<Button type={'submit'} disabled={disabled || !canSubmit} isLoading={isSubmitting} {...props}>
{children}
</Button>
)}
</form.Subscribe>
);
}