fix: Editing/saving fixes (#432)

* feat: table add button is now hidden when adding/editing

feat: disable every other action on editable table when editing/adding

feat: hide add button instead of disabling it when can't add

feat: disable every other action when adding/editing on the commissions
page

feat: disable every other action when adding/editing on the locales
page

feat: disable every other action when adding/editing on the
notifications page

feat: disable save buttons while waiting for server response on tables
and editable numbers

* chore: removed TODO
This commit is contained in:
Liordino Neto 2020-09-22 18:28:55 -03:00 committed by GitHub
parent 02474a0a6d
commit 0c3ae801d0
6 changed files with 62 additions and 18 deletions

View file

@ -26,13 +26,13 @@ const sizes = {
}
const width = R.sum(R.values(sizes)) + channelSize
const Row = ({ namespace }) => {
const Row = ({ namespace, forceDisable }) => {
const { data: rawData, save: rawSave } = useContext(NotificationsCtx)
const save = R.compose(rawSave(null), toNamespace(namespace))
const data = fromNamespace(namespace)(rawData)
const disabled = !data || !data.active
const disabled = forceDisable || !data || !data.active
const Cell = ({ name, disabled }) => {
const value = !!(data && data[name])
@ -58,7 +58,7 @@ const Row = ({ namespace }) => {
<Cell name="transactions" disabled={disabled} />
<Cell name="compliance" disabled={disabled} />
<Cell name="errors" disabled={disabled} />
<Cell name="active" />
<Cell name="active" disabled={forceDisable} />
</Tr>
)
}
@ -68,7 +68,7 @@ const useStyles = makeStyles({
width
}
})
const Setup = () => {
const Setup = ({ forceDisable }) => {
const classes = useStyles()
return (
<Table className={classes.mainTable}>
@ -81,8 +81,8 @@ const Setup = () => {
))}
</THead>
<TBody>
<Row namespace="email" />
<Row namespace="sms" />
<Row namespace="email" forceDisable={forceDisable} />
<Row namespace="sms" forceDisable={forceDisable} />
</TBody>
</Table>
)