From 37500c3f9b2d0eb859252b5368d6b885c58965e5 Mon Sep 17 00:00:00 2001 From: Liordino Neto Date: Fri, 9 Oct 2020 15:50:49 -0300 Subject: [PATCH] feat: brought back the cashout component style: fixed the cashout component styles according to the specs --- .../src/components/inputs/cashbox/Cashbox.js | 29 ++++++++++----- .../inputs/cashbox/Cashbox.styles.js | 18 +++++----- .../src/pages/Maintenance/Cashboxes.js | 35 ++++++++++++++++++- .../src/pages/Maintenance/Cashboxes.styles.js | 6 ++++ 4 files changed, 70 insertions(+), 18 deletions(-) create mode 100644 new-lamassu-admin/src/pages/Maintenance/Cashboxes.styles.js diff --git a/new-lamassu-admin/src/components/inputs/cashbox/Cashbox.js b/new-lamassu-admin/src/components/inputs/cashbox/Cashbox.js index 91454e78..38dd9a2c 100644 --- a/new-lamassu-admin/src/components/inputs/cashbox/Cashbox.js +++ b/new-lamassu-admin/src/components/inputs/cashbox/Cashbox.js @@ -1,4 +1,5 @@ import { makeStyles } from '@material-ui/core/styles' +import classnames from 'classnames' import React from 'react' import Chip from 'src/components/Chip' @@ -12,10 +13,10 @@ import { cashboxStyles, gridStyles } from './Cashbox.styles' const cashboxClasses = makeStyles(cashboxStyles) const gridClasses = makeStyles(gridStyles) -const Cashbox = ({ percent = 0, cashOut = false }) => { +const Cashbox = ({ percent = 0, cashOut = false, className }) => { const classes = cashboxClasses({ percent, cashOut }) return ( -
+
{percent <= 50 && {percent.toFixed(0)}%}
@@ -86,20 +87,30 @@ const CashInFormik = ({ ) } -const CashOut = ({ capacity = 500, denomination = 0, currency, notes }) => { +const CashOut = ({ + capacity = 500, + denomination = 0, + currency, + notes, + className +}) => { const percent = (100 * notes) / capacity const classes = gridClasses() return ( <>
- +
-
-
- - {notes} - +
+
+ {notes} + +
+
{notes * denomination} {currency.code} diff --git a/new-lamassu-admin/src/components/inputs/cashbox/Cashbox.styles.js b/new-lamassu-admin/src/components/inputs/cashbox/Cashbox.styles.js index 2dff1eb2..909ce311 100644 --- a/new-lamassu-admin/src/components/inputs/cashbox/Cashbox.styles.js +++ b/new-lamassu-admin/src/components/inputs/cashbox/Cashbox.styles.js @@ -44,16 +44,15 @@ const cashboxStyles = { const gridStyles = { row: { - height: 36, - width: 183, - display: 'grid', - gridTemplateColumns: 'repeat(2,1fr)', - gridTemplateRows: '1fr', - gridColumnGap: 18, - gridRowGap: 0 + display: 'flex', + justifyContent: 'flex-end' + }, + innerRow: { + display: 'flex', + justifyContent: 'flex-start' }, col2: { - width: 117 + marginLeft: 16 }, noMarginText: { marginTop: 0, @@ -61,6 +60,9 @@ const gridStyles = { }, link: { marginTop: spacer + }, + chip: { + margin: [[0, 0, 0, 7]] } } diff --git a/new-lamassu-admin/src/pages/Maintenance/Cashboxes.js b/new-lamassu-admin/src/pages/Maintenance/Cashboxes.js index e8843f95..474715d5 100644 --- a/new-lamassu-admin/src/pages/Maintenance/Cashboxes.js +++ b/new-lamassu-admin/src/pages/Maintenance/Cashboxes.js @@ -1,22 +1,31 @@ import { useQuery, useMutation } from '@apollo/react-hooks' +import { makeStyles } from '@material-ui/core' import gql from 'graphql-tag' import React from 'react' import * as Yup from 'yup' import { Table as EditableTable } from 'src/components/editableTable' +import { CashOut } from 'src/components/inputs/cashbox/Cashbox' import { NumberInput } from 'src/components/inputs/formik' import TitleSection from 'src/components/layout/TitleSection' +import { fromNamespace } from 'src/utils/config' + +import styles from './Cashboxes.styles.js' + +const useStyles = makeStyles(styles) const ValidationSchema = Yup.object().shape({ name: Yup.string().required('Required'), cassette1: Yup.number() .required('Required') .integer() - .min(0), + .min(0) + .max(500), cassette2: Yup.number() .required('Required') .integer() .min(0) + .max(500) }) const GET_MACHINES_AND_CONFIG = gql` @@ -52,6 +61,8 @@ const RESET_CASHOUT_BILLS = gql` ` const Cashboxes = () => { + const classes = useStyles() + const { data } = useQuery(GET_MACHINES_AND_CONFIG) const [resetCashOut] = useMutation(RESET_CASHOUT_BILLS, { @@ -62,6 +73,10 @@ const Cashboxes = () => { } }) + const cashout = data?.config && fromNamespace('cashOut')(data.config) + const locale = data?.config && fromNamespace('locale')(data.config) + const fiatCurrency = locale?.fiatCurrency + const onSave = (...[, { id, cassette1, cassette2 }]) => { return resetCashOut({ variables: { @@ -73,6 +88,8 @@ const Cashboxes = () => { }) } + const getDenomination = id => fromNamespace(id)(cashout) + const elements = [ { name: 'name', @@ -86,6 +103,14 @@ const Cashboxes = () => { header: 'Cash-out 1', width: 265, textAlign: 'right', + view: (value, { id }) => ( + + ), input: NumberInput, inputProps: { decimalPlaces: 0 @@ -96,6 +121,14 @@ const Cashboxes = () => { header: 'Cash-out 2', width: 265, textAlign: 'right', + view: (value, { id }) => ( + + ), input: NumberInput, inputProps: { decimalPlaces: 0 diff --git a/new-lamassu-admin/src/pages/Maintenance/Cashboxes.styles.js b/new-lamassu-admin/src/pages/Maintenance/Cashboxes.styles.js new file mode 100644 index 00000000..8b574172 --- /dev/null +++ b/new-lamassu-admin/src/pages/Maintenance/Cashboxes.styles.js @@ -0,0 +1,6 @@ +export default { + cashbox: { + width: 80, + height: 36 + } +}