chore: eslint continuation

This commit is contained in:
Rafael 2024-12-02 10:17:22 +00:00
parent 61790bc41b
commit 055ebfc171
21 changed files with 100 additions and 151 deletions

View file

@ -13,13 +13,20 @@ export default [
process: 'readonly' process: 'readonly'
} }
}, },
settings: {
react: {
version: '16'
}
}
}, },
pluginJs.configs.recommended, pluginJs.configs.recommended,
pluginReact.configs.flat.recommended, pluginReact.configs.flat.recommended,
{ {
rules: { rules: {
'react/prop-types': 'off', 'react/prop-types': 'off',
'react/display-name': 'off' 'react/display-name': 'off',
'react/no-unescaped-entities': 'off',
'no-unused-vars': 'off',
} }
} }
] ]

View file

@ -1,59 +0,0 @@
import { makeStyles } from '@material-ui/core/styles'
import classnames from 'classnames'
import React, { memo } from 'react'
import baseButtonStyles from './BaseButton.styles'
const { baseButton, primary } = baseButtonStyles
const styles = {
button: {
extend: baseButton,
borderRadius: baseButton.height / 2,
outline: 0,
padding: '0 20px'
},
primary,
buttonIcon: {
marginTop: 4,
marginRight: 4,
'& svg': {
width: 20,
height: 20,
overflow: 'visible'
}
},
buttonIconActive: {} // required to extend primary
}
const useStyles = makeStyles(styles)
const SimpleButton = memo(
({ className, Icon, InverseIcon, children, color, size, ...props }) => {
const classes = useStyles()
return (
<button
className={classnames(classes.primary, classes.button, className)}
{...props}>
{Icon && (
<div className={classes.buttonIcon}>
<Icon />
</div>
)}
{InverseIcon && (
<div
className={classnames(
classes.buttonIcon,
classes.buttonIconActive
)}>
<InverseIcon />
</div>
)}
{children}
</button>
)
}
)
export default SimpleButton

View file

@ -165,8 +165,9 @@ const ECol = ({ editing, focus, config, extraPaddingRight, extraPadding }) => {
return ( return (
<div className={classes.fields}> <div className={classes.fields}>
{R.map(f => ( {fields.map((f, idx) => (
<Td <Td
key={idx}
className={{ className={{
[classes.extraPaddingRight]: extraPaddingRight, [classes.extraPaddingRight]: extraPaddingRight,
[classes.extraPadding]: extraPadding, [classes.extraPadding]: extraPadding,
@ -204,7 +205,7 @@ const ECol = ({ editing, focus, config, extraPaddingRight, extraPadding }) => {
)} )}
{isHidden(values) && <StripesSvg />} {isHidden(values) && <StripesSvg />}
</Td> </Td>
))(fields)} ))}
</div> </div>
) )
} }

View file

@ -141,7 +141,7 @@ const Header = memo(({ tree, user }) => {
className={classnames(classes.link, classes.whiteLink)} className={classnames(classes.link, classes.whiteLink)}
activeClassName={classes.activeLink}> activeClassName={classes.activeLink}>
<li className={classes.li}> <li className={classes.li}>
<span className={classes.forceSize} forcesize={it.label}> <span className={classes.forceSize} data-forcesize={it.label}>
{it.label} {it.label}
</span> </span>
</li> </li>

View file

@ -90,7 +90,7 @@ const styles = {
textAlign: 'center', textAlign: 'center',
'&:after': { '&:after': {
display: 'block', display: 'block',
content: 'attr(forcesize)', content: 'attr(data-forcesize)',
fontWeight: 700, fontWeight: 700,
height: 0, height: 0,
overflow: 'hidden', overflow: 'hidden',

View file

@ -26,7 +26,7 @@ const Sidebar = ({
{loading && <P>Loading...</P>} {loading && <P>Loading...</P>}
{!loading && {!loading &&
data?.map((it, idx) => ( data?.map((it, idx) => (
<div className={classes.linkWrapper} onClick={() => onClick(it)}> <div key={idx} className={classes.linkWrapper} onClick={() => onClick(it)}>
<div <div
key={idx} key={idx}
className={classnames({ className={classnames({

View file

@ -485,7 +485,6 @@ const CustomerData = ({
hasImage={hasImage} hasImage={hasImage}
hasAdditionalData={hasAdditionalData} hasAdditionalData={hasAdditionalData}
fields={fields} fields={fields}
children={children}
validationSchema={validationSchema} validationSchema={validationSchema}
initialValues={initialValues} initialValues={initialValues}
save={save} save={save}
@ -493,7 +492,7 @@ const CustomerData = ({
deleteEditedData={deleteEditedData} deleteEditedData={deleteEditedData}
retrieveAdditionalData={retrieveAdditionalData} retrieveAdditionalData={retrieveAdditionalData}
checkAgainstSanctions={checkAgainstSanctions} checkAgainstSanctions={checkAgainstSanctions}
editable={editable}></EditableCard> editable={editable}>{children}</EditableCard>
) )
} }
@ -506,12 +505,11 @@ const CustomerData = ({
title={title} title={title}
key={idx} key={idx}
state={state} state={state}
children={children}
initialValues={initialValues} initialValues={initialValues}
titleIcon={titleIcon} titleIcon={titleIcon}
editable={false} editable={false}
hasImage={hasImage} hasImage={hasImage}
fields={fields}></EditableCard> fields={fields}>{children}</EditableCard>
) )
} }
@ -522,23 +520,24 @@ const CustomerData = ({
<div className={classes.header}> <div className={classes.header}>
<H3 className={classes.title}>{'Customer data'}</H3> <H3 className={classes.title}>{'Customer data'}</H3>
{// TODO: Remove false condition for next release {// TODO: Remove false condition for next release
false && ( // false && (
<> // <>
<FeatureButton // <FeatureButton
active={!listView} // active={!listView}
className={classes.viewIcons} // className={classes.viewIcons}
Icon={OverviewIcon} // Icon={OverviewIcon}
InverseIcon={OverviewReversedIcon} // InverseIcon={OverviewReversedIcon}
onClick={() => setListView(false)} // onClick={() => setListView(false)}
/> // />
<FeatureButton // <FeatureButton
active={listView} // active={listView}
className={classes.viewIcons} // className={classes.viewIcons}
Icon={CustomerListViewIcon} // Icon={CustomerListViewIcon}
InverseIcon={CustomerListViewReversedIcon} // InverseIcon={CustomerListViewReversedIcon}
onClick={() => setListView(true)}></FeatureButton> // onClick={() => setListView(true)}></FeatureButton>
</> // </>
)} // )
}
</div> </div>
<div> <div>
{!listView && customer && ( {!listView && customer && (

View file

@ -58,16 +58,15 @@ const CustomerNotes = ({
{R.isNil(editing) && ( {R.isNil(editing) && (
<div className={classes.notesChipList}> <div className={classes.notesChipList}>
<NewNoteCard setOpenModal={setOpenModal} /> <NewNoteCard setOpenModal={setOpenModal} />
{R.map( {customerNotes.map((it, idx) => (
it => (
<NoteCard <NoteCard
key={idx}
note={it} note={it}
deleteNote={deleteNote} deleteNote={deleteNote}
handleClick={setEditing} handleClick={setEditing}
timezone={timezone} timezone={timezone}
/> />
), )
customerNotes
)} )}
</div> </div>
)} )}

View file

@ -28,7 +28,7 @@ const CustomerPhotos = ({ photosData, timezone }) => {
<div className={classes.photosChipList}> <div className={classes.photosChipList}>
{photosData.map((elem, idx) => ( {photosData.map((elem, idx) => (
<PhotoCard <PhotoCard
idx={idx} key={idx}
date={elem.date} date={elem.date}
src={`/${elem.photoDir}/${elem.path}`} src={`/${elem.photoDir}/${elem.path}`}
setPhotosDialog={setPhotosDialog} setPhotosDialog={setPhotosDialog}

View file

@ -45,7 +45,9 @@ const getValidationSchema = countryCodes =>
}, countryCodes) }, countryCodes)
return R.any(it => it === true, validMap) return R.any(it => it === true, validMap)
} catch (e) {} } catch (e) {
return false
}
}) })
.trim() .trim()
}) })

View file

@ -45,8 +45,9 @@ const CustomerSidebar = ({ isSelected, onClick }) => {
return ( return (
<div className={classes.sidebar}> <div className={classes.sidebar}>
{sideBarOptions?.map(({ Icon, InverseIcon, display, code }) => ( {sideBarOptions?.map(({ Icon, InverseIcon, display, code }, idx) => (
<div <div
key={idx}
className={classnames({ className={classnames({
[classes.activeLink]: isSelected(code), [classes.activeLink]: isSelected(code),
[classes.link]: true [classes.link]: true

View file

@ -259,16 +259,16 @@ const EditableCard = ({
{!editing && ( {!editing && (
<div className={classes.editButton}> <div className={classes.editButton}>
<div className={classes.deleteButton}> <div className={classes.deleteButton}>
{false && ( {/*{false && (*/}
<ActionButton {/* <ActionButton*/}
color="primary" {/* color="primary"*/}
type="button" {/* type="button"*/}
Icon={DeleteIcon} {/* Icon={DeleteIcon}*/}
InverseIcon={DeleteReversedIcon} {/* InverseIcon={DeleteReversedIcon}*/}
onClick={() => deleteEditedData()}> {/* onClick={() => deleteEditedData()}>*/}
Delete {/* Delete*/}
</ActionButton> {/* </ActionButton>*/}
)} {/*)}*/}
{!hasAdditionalData && ( {!hasAdditionalData && (
<ActionButton <ActionButton
color="primary" color="primary"

View file

@ -1,3 +1,4 @@
import React from 'react'
import { makeStyles, Box } from '@material-ui/core' import { makeStyles, Box } from '@material-ui/core'
import classnames from 'classnames' import classnames from 'classnames'
import { parse, isValid, format } from 'date-fns/fp' import { parse, isValid, format } from 'date-fns/fp'
@ -325,8 +326,9 @@ const ManualDataEntry = ({ selectedValues, customInfoRequirementOptions }) => {
<div className={classes.field}> <div className={classes.field}>
{!upload && {!upload &&
!isCustomInfoRequirement && !isCustomInfoRequirement &&
elements.options.map(({ label, name }) => ( elements.options.map(({ label, name }, idx) => (
<Field <Field
key={idx}
name={name} name={name}
label={label} label={label}
component={TextInput} component={TextInput}

View file

@ -107,16 +107,14 @@ const MachinesTable = ({ machines = [], numToRender }) => {
<TxInIcon /> <TxInIcon />
</div> </div>
</HeaderCell> */} </HeaderCell> */}
{R.map( {R.times(R.identity, maxNumberOfCassettes).map((it, idx) => (
it => ( <HeaderCell key={idx}>
<HeaderCell>
<div className={classes.header}> <div className={classes.header}>
<TxOutIcon /> <TxOutIcon />
<Label2 className={classes.label}> {it + 1}</Label2> <Label2 className={classes.label}> {it + 1}</Label2>
</div> </div>
</HeaderCell> </HeaderCell>
), )
R.times(R.identity, maxNumberOfCassettes)
)} )}
</TableRow> </TableRow>
</TableHead> </TableHead>
@ -143,21 +141,19 @@ const MachinesTable = ({ machines = [], numToRender }) => {
<StyledCell> <StyledCell>
<Status status={machine.statuses[0]} /> <Status status={machine.statuses[0]} />
</StyledCell> </StyledCell>
{R.map( {R.range(1, maxNumberOfCassettes + 1).map((it, idx) =>
it =>
machine.numberOfCassettes >= it ? ( machine.numberOfCassettes >= it ? (
<StyledCell align="left"> <StyledCell key={idx} align="left">
{makePercentageText( {makePercentageText(
it, it,
machine.cashUnits[`cassette${it}`] machine.cashUnits[`cassette${it}`]
)} )}
</StyledCell> </StyledCell>
) : ( ) : (
<StyledCell align="left"> <StyledCell key={idx} align="left">
<TL2>{`— %`}</TL2> <TL2>{`— %`}</TL2>
</StyledCell> </StyledCell>
), )
R.range(1, maxNumberOfCassettes + 1)
)} )}
</TableRow> </TableRow>
) )

View file

@ -106,12 +106,12 @@ const CashUnitDetails = ({
<div className={classes.billList}> <div className={classes.billList}>
<Label1>Cash box</Label1> <Label1>Cash box</Label1>
{R.isEmpty(billCount) && <TL2 noMargin>Empty</TL2>} {R.isEmpty(billCount) && <TL2 noMargin>Empty</TL2>}
{R.map(it => ( {(R.keys(billCount)).map((it, idx) => (
<span> <span key={idx}>
<TL2 noMargin>{billCount[it]}</TL2> <TL2 noMargin>{billCount[it]}</TL2>
<Chip label={`${it} ${currency}`} /> <Chip label={`${it} ${currency}`} />
</span> </span>
))(R.keys(billCount))} ))}
</div> </div>
<div className={classes.unitList}> <div className={classes.unitList}>
{machine.numberOfRecyclers === 0 && {machine.numberOfRecyclers === 0 &&
@ -149,8 +149,9 @@ const CashUnitDetails = ({
noMargin noMargin
className={classes.label}>{`Loading boxes`}</Label1> className={classes.label}>{`Loading boxes`}</Label1>
<div className={classes.loadingBoxes}> <div className={classes.loadingBoxes}>
{R.map(it => ( {(R.range(1, machine.numberOfCassettes + 1)).map((it, idx) => (
<CashOut <CashOut
key={idx}
width={60} width={60}
height={40} height={40}
currency={{ code: currency }} currency={{ code: currency }}
@ -167,7 +168,7 @@ const CashUnitDetails = ({
} }
capacity={getCashUnitCapacity(machine.model, 'cassette')} capacity={getCashUnitCapacity(machine.model, 'cassette')}
/> />
))(R.range(1, machine.numberOfCassettes + 1))} ))}
</div> </div>
</div> </div>
<span className={classes.verticalLine} /> <span className={classes.verticalLine} />

View file

@ -1,3 +1,4 @@
import React from 'react'
import * as R from 'ramda' import * as R from 'ramda'
import { CashIn, CashOutLite } from 'src/components/inputs/cashbox/Cashbox' import { CashIn, CashOutLite } from 'src/components/inputs/cashbox/Cashbox'
import EditIcon from 'src/styling/icons/action/edit/enabled.svg?react' import EditIcon from 'src/styling/icons/action/edit/enabled.svg?react'
@ -56,8 +57,9 @@ const getElements = (
return ( return (
<div className={classes.unitsRow}> <div className={classes.unitsRow}>
<div className={classes.units}> <div className={classes.units}>
{R.map(it => ( {(R.range(1, m.numberOfCassettes + 1)).map((it, idx) => (
<CashOutLite <CashOutLite
key={idx}
width={'100%'} width={'100%'}
currency={{ code: fiatCurrency }} currency={{ code: fiatCurrency }}
notes={m.cashUnits[`cassette${it}`]} notes={m.cashUnits[`cassette${it}`]}
@ -69,7 +71,7 @@ const getElements = (
} }
capacity={getCashUnitCapacity(m.model, 'cassette')} capacity={getCashUnitCapacity(m.model, 'cassette')}
/> />
))(R.range(1, m.numberOfCassettes + 1))} ))}
</div> </div>
<div className={classes.units}> <div className={classes.units}>
{R.map(it => ( {R.map(it => (

View file

@ -132,8 +132,9 @@ const Setup = ({ wizard, forceDisable }) => {
))} ))}
</THead> </THead>
<TBody> <TBody>
{namespaces.map(namespace => ( {namespaces.map((namespace, idx) => (
<Row <Row
key={idx}
namespace={namespace.name} namespace={namespace.name}
forceDisable={namespace.forceDisable} forceDisable={namespace.forceDisable}
save={R.compose(rawSave(null), toNamespace(namespace.name))} save={R.compose(rawSave(null), toNamespace(namespace.name))}

View file

@ -34,13 +34,13 @@ const PREFILL = {
name: 'has-code', name: 'has-code',
message: 'The confirmation code is missing from the message!', message: 'The confirmation code is missing from the message!',
exclusive: false, exclusive: false,
test: value => value?.match(/#code/g || [])?.length > 0 test: value => value?.match(/#code/g)?.length > 0
}) })
.test({ .test({
name: 'has-single-code', name: 'has-single-code',
message: 'There should be a single confirmation code!', message: 'There should be a single confirmation code!',
exclusive: false, exclusive: false,
test: value => value?.match(/#code/g || [])?.length === 1 test: value => value?.match(/#code/g)?.length === 1
}) })
}, },
cashOutDispenseReady: { cashOutDispenseReady: {
@ -155,12 +155,13 @@ const SMSNoticesModal = ({
<Info2 noMargin>Values to attach</Info2> <Info2 noMargin>Values to attach</Info2>
)} )}
<div className={classes.chipButtons}> <div className={classes.chipButtons}>
{R.map( {R.splitEvery(3, CHIPS[sms?.event]).map(
it => ( (it, idx) => (
<div> <div key={idx}>
{R.map( {it.map(
ite => ( (ite, idx2) => (
<Chip <Chip
key={idx2}
label={ite.display} label={ite.display}
size="small" size="small"
style={{ backgroundColor: zircon }} style={{ backgroundColor: zircon }}
@ -176,12 +177,10 @@ const SMSNoticesModal = ({
) )
}} }}
/> />
), )
it
)} )}
</div> </div>
), ),
R.splitEvery(3, CHIPS[sms?.event])
)} )}
</div> </div>
<div className={classes.footer}> <div className={classes.footer}>

View file

@ -202,9 +202,9 @@ const DetailsRow = ({ it: tx, timezone }) => {
const walletScoreEl = ( const walletScoreEl = (
<div className={classes.walletScore}> <div className={classes.walletScore}>
<svg width={103} height={10}> <svg width={103} height={10}>
{R.map( {R.range(0, 10).map((it, idx) => (
it => (
<circle <circle
key={idx}
cx={it * 10 + 6} cx={it * 10 + 6}
cy={4} cy={4}
r={3.5} r={3.5}
@ -218,8 +218,7 @@ const DetailsRow = ({ it: tx, timezone }) => {
: offErrorColor : offErrorColor
} }
/> />
), )
R.range(0, 10)
)} )}
</svg> </svg>
<P <P

View file

@ -1,3 +1,4 @@
import React from 'react'
import { getCryptoCurrency } from '@lamassu/coins/lightUtils' import { getCryptoCurrency } from '@lamassu/coins/lightUtils'
import * as R from 'ramda' import * as R from 'ramda'
import * as Yup from 'yup' import * as Yup from 'yup'

View file

@ -120,12 +120,11 @@ const Routes = () => {
in={true} in={true}
mountOnEnter mountOnEnter
unmountOnExit unmountOnExit
children={ >
<div className={classes.wrapper}> <div className={classes.wrapper}>
<Dashboard /> <Dashboard />
</div> </div>
} </Transition>
/>
</PrivateRoute> </PrivateRoute>
<PrivateRoute path="/machines" component={Machines} /> <PrivateRoute path="/machines" component={Machines} />
<PrivateRoute path="/wizard" component={Wizard} /> <PrivateRoute path="/wizard" component={Wizard} />
@ -141,19 +140,18 @@ const Routes = () => {
in={!!matchPath(location.pathname, { path: route })} in={!!matchPath(location.pathname, { path: route })}
mountOnEnter mountOnEnter
unmountOnExit unmountOnExit
children={ >
<div className={classes.wrapper}> <div className={classes.wrapper}>
<PrivateRoute path={route} key={key}> <PrivateRoute path={route} key={key}>
<Page name={key} /> <Page name={key}/>
</PrivateRoute> </PrivateRoute>
</div> </div>
} </Transition>
/>
</PrivateRoute> </PrivateRoute>
))} ))}
<PublicRoute path="/404" /> <PublicRoute path="/404"/>
<PublicRoute path="*"> <PublicRoute path="*">
<Redirect to={{ pathname: '/404' }} /> <Redirect to={{ pathname: '/404' }}/>
</PublicRoute> </PublicRoute>
</Switch> </Switch>
) )