feat: use the newest editableTable options

fix: new editableTable takes care of setEditing()
fix: new save() parameters in use
This commit is contained in:
Mauricio Navarro Miranda 2020-04-24 02:59:38 -05:00
parent 7cf82a407e
commit e255ba211e

View file

@ -13,7 +13,6 @@ import {
CashInFormik CashInFormik
} from 'src/components/inputs/cashbox/Cashbox' } from 'src/components/inputs/cashbox/Cashbox'
import { mainStyles } from 'src/pages/Transactions/Transactions.styles' import { mainStyles } from 'src/pages/Transactions/Transactions.styles'
import { ReactComponent as EditIcon } from 'src/styling/icons/action/edit/enabled.svg'
import { ReactComponent as ErrorIcon } from 'src/styling/icons/status/tomato.svg' import { ReactComponent as ErrorIcon } from 'src/styling/icons/status/tomato.svg'
const ValidationSchema = Yup.object().shape({ const ValidationSchema = Yup.object().shape({
@ -125,20 +124,20 @@ const Cashboxes = () => {
} }
}) })
const onSave = ({ cashin, cashout1, cashout2 }, { setSubmitting }) => const onSave = (_, { cashin, cashout1, cashout2 }) =>
resetCashOut({ resetCashOut({
variables: { variables: {
deviceId: cashin.deviceId, deviceId: cashin.deviceId,
action: 'resetCashOutBills', action: 'resetCashOutBills',
cassettes: [Number(cashout1.notes), Number(cashout2.notes)] cassettes: [Number(cashout1.notes), Number(cashout2.notes)]
} }
}).then(() => setSubmitting(false)) })
const elements = [ const elements = [
{ {
name: 'name', name: 'name',
header: 'Machine', header: 'Machine',
size: 254, width: 254,
textAlign: 'left', textAlign: 'left',
view: name => <>{name}</>, view: name => <>{name}</>,
input: ({ field: { value: name } }) => <>{name}</> input: ({ field: { value: name } }) => <>{name}</>
@ -146,7 +145,7 @@ const Cashboxes = () => {
{ {
name: 'cashin', name: 'cashin',
header: 'Cash-in', header: 'Cash-in',
size: 265, width: 265,
textAlign: 'left', textAlign: 'left',
view: props => <CashIn {...props} />, view: props => <CashIn {...props} />,
input: props => <CashInFormik onEmpty={onEmpty} {...props} /> input: props => <CashInFormik onEmpty={onEmpty} {...props} />
@ -154,7 +153,7 @@ const Cashboxes = () => {
{ {
name: 'cashout1', name: 'cashout1',
header: 'Cash-out 1', header: 'Cash-out 1',
size: 265, width: 265,
textAlign: 'left', textAlign: 'left',
view: props => <CashOut {...props} />, view: props => <CashOut {...props} />,
input: CashOutFormik input: CashOutFormik
@ -162,17 +161,10 @@ const Cashboxes = () => {
{ {
name: 'cashout2', name: 'cashout2',
header: 'Cash-out 2', header: 'Cash-out 2',
size: 265, width: 265,
textAlign: 'left', textAlign: 'left',
view: props => <CashOut {...props} />, view: props => <CashOut {...props} />,
input: CashOutFormik input: CashOutFormik
},
{
name: 'edit',
header: 'Update',
size: 151,
textAlign: 'right',
view: onclick => <EditIcon onClick={onclick} />
} }
] ]
@ -205,6 +197,8 @@ const Cashboxes = () => {
</div> </div>
</div> </div>
<EditableTable <EditableTable
name="cashboxes"
enableEdit
elements={elements} elements={elements}
data={data} data={data}
save={onSave} save={onSave}