-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MDS-5949] New Code Edit error (#3066)
* re-initialize form when new values are added so they don't get discarded as changes. Did put in render submit button and async changes because it was already done, fixed classname that was accidentally doing boolean math instead of string concatenation. Put spaces between rows
- Loading branch information
Showing
16 changed files
with
101 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
services/common/src/components/forms/RenderSubmitButton.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React, { FC, ReactNode, useContext } from "react"; | ||
import { useSelector } from "react-redux"; | ||
import { isDirty, isSubmitting } from "redux-form"; | ||
import { FormContext } from "./FormWrapper"; | ||
import { Button } from "antd"; | ||
import { BaseButtonProps } from "antd/lib/button/button"; | ||
|
||
interface RenderSubmitButtonProps { | ||
buttonText?: string | ReactNode; | ||
buttonProps?: BaseButtonProps; | ||
} | ||
|
||
const RenderSubmitButton: FC<RenderSubmitButtonProps> = ({ | ||
buttonText = "Save Changes", | ||
buttonProps, | ||
}) => { | ||
const { formName, isEditMode } = useContext(FormContext); | ||
const submitting = useSelector(isSubmitting(formName)); | ||
const isFormDirty = useSelector(isDirty(formName)); | ||
|
||
return ( | ||
<> | ||
{isEditMode && ( | ||
<Button | ||
type="primary" | ||
disabled={!isFormDirty || submitting} | ||
loading={submitting} | ||
htmlType="submit" | ||
{...buttonProps} | ||
> | ||
{buttonText} | ||
</Button> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default RenderSubmitButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.