Skip to content

Commit

Permalink
add dynamic ReplyEditor submit button text
Browse files Browse the repository at this point in the history
  • Loading branch information
glenwid committed May 3, 2021
1 parent eb54b14 commit b7be194
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/components/ReplyEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ const ReplyEditor: React.FC<ReplyEditorProps> = ({
}
}

const getSubmitButtonText = () => {
if(type === "Edit")
return "Edit"
else {
return "Add " + type
}
}

return (
<div className="replyEditor" data-testid="replyEditor">
<TextArea
Expand Down Expand Up @@ -83,7 +91,7 @@ const ReplyEditor: React.FC<ReplyEditorProps> = ({
type="primary"
data-testid="replyButton"
>
{'Add ' + type}
{getSubmitButtonText()}
</Button>
)}

Expand All @@ -95,7 +103,7 @@ const ReplyEditor: React.FC<ReplyEditorProps> = ({
data-testid="replyButton"
disabled
>
{'Add ' + type}
{getSubmitButtonText()}
</Button>
)}
</Space>
Expand Down

0 comments on commit b7be194

Please sign in to comment.