fix: machine profile page changes
This commit is contained in:
parent
a5a869a734
commit
debb9ecafd
4 changed files with 46 additions and 14 deletions
|
|
@ -53,8 +53,10 @@ const MachinesTable = ({ machines, numToRender }) => {
|
||||||
return <TL2>{`${percent}%`}</TL2>
|
return <TL2>{`${percent}%`}</TL2>
|
||||||
}
|
}
|
||||||
|
|
||||||
const redirect = name => {
|
const redirect = ({ name, deviceId }) => {
|
||||||
return history.push('/machines', { selectedMachine: name })
|
return history.push('/machines/' + `${deviceId}`, {
|
||||||
|
selectedMachine: name
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -96,7 +98,7 @@ const MachinesTable = ({ machines, numToRender }) => {
|
||||||
if (idx < numToRender) {
|
if (idx < numToRender) {
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
onClick={() => redirect(machine.name)}
|
onClick={() => redirect(machine)}
|
||||||
className={classnames(classes.row, classes.clickableRow)}
|
className={classnames(classes.row, classes.clickableRow)}
|
||||||
key={machine.deviceId + idx}>
|
key={machine.deviceId + idx}>
|
||||||
<StyledCell align="left">
|
<StyledCell align="left">
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import React from 'react'
|
||||||
import * as Yup from 'yup'
|
import * as Yup from 'yup'
|
||||||
|
|
||||||
import { Table as EditableTable } from 'src/components/editableTable'
|
import { Table as EditableTable } from 'src/components/editableTable'
|
||||||
import { CashOut } from 'src/components/inputs/cashbox/Cashbox'
|
import { CashOut, CashIn } from 'src/components/inputs/cashbox/Cashbox'
|
||||||
import { NumberInput } from 'src/components/inputs/formik'
|
import { NumberInput } from 'src/components/inputs/formik'
|
||||||
import { fromNamespace } from 'src/utils/config'
|
import { fromNamespace } from 'src/utils/config'
|
||||||
|
|
||||||
|
|
@ -15,6 +15,12 @@ const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
const ValidationSchema = Yup.object().shape({
|
const ValidationSchema = Yup.object().shape({
|
||||||
name: Yup.string().required('Required'),
|
name: Yup.string().required('Required'),
|
||||||
|
cashbox: Yup.number()
|
||||||
|
.label('Cashbox')
|
||||||
|
.required()
|
||||||
|
.integer()
|
||||||
|
.min(0)
|
||||||
|
.max(1000),
|
||||||
cassette1: Yup.number()
|
cassette1: Yup.number()
|
||||||
.required('Required')
|
.required('Required')
|
||||||
.integer()
|
.integer()
|
||||||
|
|
@ -27,20 +33,23 @@ const ValidationSchema = Yup.object().shape({
|
||||||
.max(500)
|
.max(500)
|
||||||
})
|
})
|
||||||
|
|
||||||
const RESET_CASHOUT_BILLS = gql`
|
const SET_CASSETTE_BILLS = gql`
|
||||||
mutation MachineAction(
|
mutation MachineAction(
|
||||||
$deviceId: ID!
|
$deviceId: ID!
|
||||||
$action: MachineAction!
|
$action: MachineAction!
|
||||||
|
$cashbox: Int!
|
||||||
$cassette1: Int!
|
$cassette1: Int!
|
||||||
$cassette2: Int!
|
$cassette2: Int!
|
||||||
) {
|
) {
|
||||||
machineAction(
|
machineAction(
|
||||||
deviceId: $deviceId
|
deviceId: $deviceId
|
||||||
action: $action
|
action: $action
|
||||||
|
cashbox: $cashbox
|
||||||
cassette1: $cassette1
|
cassette1: $cassette1
|
||||||
cassette2: $cassette2
|
cassette2: $cassette2
|
||||||
) {
|
) {
|
||||||
deviceId
|
deviceId
|
||||||
|
cashbox
|
||||||
cassette1
|
cassette1
|
||||||
cassette2
|
cassette2
|
||||||
}
|
}
|
||||||
|
|
@ -60,6 +69,19 @@ const CashCassettes = ({ machine, config, refetchData }) => {
|
||||||
!getCashoutSettings(deviceId).active
|
!getCashoutSettings(deviceId).active
|
||||||
|
|
||||||
const elements = [
|
const elements = [
|
||||||
|
{
|
||||||
|
name: 'cashbox',
|
||||||
|
header: 'Cashbox',
|
||||||
|
width: 240,
|
||||||
|
stripe: true,
|
||||||
|
view: value => (
|
||||||
|
<CashIn currency={{ code: fiatCurrency }} notes={value} total={0} />
|
||||||
|
),
|
||||||
|
input: NumberInput,
|
||||||
|
inputProps: {
|
||||||
|
decimalPlaces: 0
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: 'cassette1',
|
name: 'cassette1',
|
||||||
header: 'Cash-out 1',
|
header: 'Cash-out 1',
|
||||||
|
|
@ -100,15 +122,16 @@ const CashCassettes = ({ machine, config, refetchData }) => {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
const [resetCashOut, { error }] = useMutation(RESET_CASHOUT_BILLS, {
|
const [setCassetteBills, { error }] = useMutation(SET_CASSETTE_BILLS, {
|
||||||
refetchQueries: () => refetchData()
|
refetchQueries: () => refetchData()
|
||||||
})
|
})
|
||||||
|
|
||||||
const onSave = (...[, { deviceId, cassette1, cassette2 }]) => {
|
const onSave = (...[, { deviceId, cashbox, cassette1, cassette2 }]) => {
|
||||||
return resetCashOut({
|
return setCassetteBills({
|
||||||
variables: {
|
variables: {
|
||||||
action: 'resetCashOutBills',
|
action: 'setCassetteBills',
|
||||||
deviceId: deviceId,
|
deviceId: deviceId,
|
||||||
|
cashbox,
|
||||||
cassette1,
|
cassette1,
|
||||||
cassette2
|
cassette2
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,6 @@ import Commissions from './MachineComponents/Commissions'
|
||||||
import Details from './MachineComponents/Details'
|
import Details from './MachineComponents/Details'
|
||||||
import Overview from './MachineComponents/Overview'
|
import Overview from './MachineComponents/Overview'
|
||||||
import Transactions from './MachineComponents/Transactions'
|
import Transactions from './MachineComponents/Transactions'
|
||||||
import Sidebar from './MachineSidebar'
|
|
||||||
import styles from './Machines.styles'
|
import styles from './Machines.styles'
|
||||||
const useStyles = makeStyles(styles)
|
const useStyles = makeStyles(styles)
|
||||||
|
|
||||||
|
|
@ -73,21 +72,21 @@ const Machines = () => {
|
||||||
<div className={classes.breadcrumbsContainer}>
|
<div className={classes.breadcrumbsContainer}>
|
||||||
<Breadcrumbs separator={<NavigateNextIcon fontSize="small" />}>
|
<Breadcrumbs separator={<NavigateNextIcon fontSize="small" />}>
|
||||||
<Link to="/dashboard" className={classes.breadcrumbLink}>
|
<Link to="/dashboard" className={classes.breadcrumbLink}>
|
||||||
<Label3 className={classes.subtitle}>Dashboard</Label3>
|
<Label3 className={classes.breadcrumbElem}>Dashboard</Label3>
|
||||||
</Link>
|
</Link>
|
||||||
<TL2 className={classes.subtitle}>{selectedMachine}</TL2>
|
<TL2 className={classes.breadcrumbElem}>{selectedMachine}</TL2>
|
||||||
</Breadcrumbs>
|
</Breadcrumbs>
|
||||||
<Overview data={machineInfo} onActionSuccess={refetch} />
|
<Overview data={machineInfo} onActionSuccess={refetch} />
|
||||||
</div>
|
</div>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12}>
|
<Grid item xs={12}>
|
||||||
<Sidebar
|
{/* on hold for now <Sidebar
|
||||||
isSelected={R.equals(selectedMachine)}
|
isSelected={R.equals(selectedMachine)}
|
||||||
selectItem={setSelectedMachine}
|
selectItem={setSelectedMachine}
|
||||||
data={machines}
|
data={machines}
|
||||||
getText={R.prop('name')}
|
getText={R.prop('name')}
|
||||||
getKey={R.prop('deviceId')}
|
getKey={R.prop('deviceId')}
|
||||||
/>
|
/> */}
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={9}>
|
<Grid item xs={9}>
|
||||||
|
|
|
||||||
|
|
@ -76,6 +76,14 @@ const styles = {
|
||||||
breadcrumbLink: {
|
breadcrumbLink: {
|
||||||
textDecoration: 'none'
|
textDecoration: 'none'
|
||||||
},
|
},
|
||||||
|
breadcrumbElem: {
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
flexDirection: 'row',
|
||||||
|
color: comet,
|
||||||
|
margin: 0
|
||||||
|
},
|
||||||
detailsMargin: {
|
detailsMargin: {
|
||||||
marginTop: 24
|
marginTop: 24
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue