fix: button display and revert button component changes

This commit is contained in:
José Oliveira 2021-10-18 15:48:17 +01:00
parent 550bc2b7a4
commit 8e83d184ba
2 changed files with 25 additions and 18 deletions

View file

@ -32,8 +32,8 @@ const styles = {
const useStyles = makeStyles(styles)
const FeatureButton = memo(
({ className, Icon, InverseIcon, children, active, ...props }) => {
const classes = useStyles({ active })
({ className, Icon, InverseIcon, children, ...props }) => {
const classes = useStyles()
const classNames = {
[classes.featureButton]: true,

View file

@ -123,8 +123,7 @@ const EditableCard = ({
[classes.label1Rejected]: state === OVERRIDE_REJECTED,
[classes.label1Accepted]: state === OVERRIDE_AUTHORIZED
}
const isNotAuthorized =
state === OVERRIDE_REJECTED || state === OVERRIDE_PENDING
const authorized =
state === OVERRIDE_PENDING
? { label: 'Pending', type: 'neutral' }
@ -208,20 +207,28 @@ const EditableCard = ({
Cancel
</ActionButton>
</div>
{authorized.label !== 'Accepted' && (
<div className={classes.button}>
<ActionButton
color="secondary"
Icon={isNotAuthorized ? AuthorizeIcon : CancelIcon}
InverseIcon={
isNotAuthorized
? AuthorizeReversedIcon
: CancelReversedIcon
}
Icon={AuthorizeIcon}
InverseIcon={AuthorizeReversedIcon}
type="submit"
onClick={
isNotAuthorized ? () => authorize() : () => reject()
}>
{isNotAuthorized ? 'Authorize' : 'Reject'}
onClick={() => authorize()}>
{'Authorize'}
</ActionButton>
</div>
)}
{authorized.label !== 'Rejected' && (
<ActionButton
color="secondary"
Icon={CancelIcon}
InverseIcon={CancelReversedIcon}
type="submit"
onClick={() => reject()}>
{'Reject'}
</ActionButton>
)}
{error && (
<ErrorMessage>Failed to save changes</ErrorMessage>
)}