From c06563a14bf876b375a576d0f8111a138b1523eb Mon Sep 17 00:00:00 2001 From: Oksamies <34424527+Oksamies@users.noreply.github.com> Date: Mon, 27 Nov 2023 17:45:41 +0200 Subject: [PATCH] FormSubmitButton text to customizable (#930) --- .../src/components/FormSubmitButton.tsx | 26 ++++++++++--------- .../src/forms/CreateTeamForm.tsx | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/cyberstorm-forms/src/components/FormSubmitButton.tsx b/packages/cyberstorm-forms/src/components/FormSubmitButton.tsx index 3d4216b44..16ac459e0 100644 --- a/packages/cyberstorm-forms/src/components/FormSubmitButton.tsx +++ b/packages/cyberstorm-forms/src/components/FormSubmitButton.tsx @@ -7,21 +7,23 @@ import { faArrowsRotate } from "@fortawesome/free-solid-svg-icons"; import { useFormState } from "react-hook-form"; import styles from "./FormSubmitButton.module.css"; -const SubmitButtonContent = React.memo((props: { isSubmitting: boolean }) => { - if (props.isSubmitting) { - return ( - - - - ); - } else { - return Create; +const SubmitButtonContent = React.memo( + (props: { isSubmitting: boolean; text: string }) => { + if (props.isSubmitting) { + return ( + + + + ); + } else { + return {props.text}; + } } -}); +); SubmitButtonContent.displayName = "SubmitButtonContent"; -export function FormSubmitButton() { +export function FormSubmitButton({ text }: { text: string }) { const { isSubmitting, disabled } = useFormState(); return ( @@ -31,7 +33,7 @@ export function FormSubmitButton() { colorScheme="success" disabled={isSubmitting || disabled} > - + ); } diff --git a/packages/cyberstorm-forms/src/forms/CreateTeamForm.tsx b/packages/cyberstorm-forms/src/forms/CreateTeamForm.tsx index 6dd3f01fd..2e3b01a02 100644 --- a/packages/cyberstorm-forms/src/forms/CreateTeamForm.tsx +++ b/packages/cyberstorm-forms/src/forms/CreateTeamForm.tsx @@ -38,7 +38,7 @@ export function CreateTeamForm() {
- +
);