chore: prettier config

husky needs to be delegated to v11 since it breaks with node 14 + 22
combo
This commit is contained in:
Rafael 2024-12-03 09:33:06 +00:00
parent dbca0c8a8c
commit d3c3de66fe
65 changed files with 1542 additions and 22553 deletions

View file

@ -0,0 +1,8 @@
{
"trailingComma": "none",
"tabWidth": 2,
"semi": false,
"singleQuote": true,
"arrowParens": "avoid",
"bracketSameLine": true
}

View file

@ -2,6 +2,7 @@ import globals from 'globals'
import pluginJs from '@eslint/js'
import pluginReact from 'eslint-plugin-react'
import reactCompiler from 'eslint-plugin-react-compiler'
import eslintConfigPrettier from 'eslint-config-prettier'
/** @type {import('eslint').Linter.Config[]} */
export default [
@ -17,7 +18,7 @@ export default [
settings: {
react: {
version: '16'
},
}
},
plugins: {
'react-compiler': reactCompiler
@ -31,7 +32,8 @@ export default [
'react/prop-types': 'off',
'react/display-name': 'off',
'react/no-unescaped-entities': 'off',
'react-compiler/react-compiler': 'warn',
}
'react-compiler/react-compiler': 'warn'
}
},
eslintConfigPrettier
]

File diff suppressed because it is too large Load diff

View file

@ -56,26 +56,19 @@
"@vitejs/plugin-react-swc": "^3.7.2",
"esbuild-plugin-react-virtualized": "^1.0.4",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-react": "^7.37.2",
"eslint-plugin-react-compiler": "^19.0.0-beta-df7b47d-20241124",
"globals": "^15.13.0",
"husky": "^3.1.0",
"lint-staged": "^9.5.0",
"react-scripts": "4.0.0",
"lint-staged": "^15.2.10",
"prettier": "3.4.1",
"vite": "^6.0.1",
"vite-plugin-svgr": "^4.3.0"
},
"lint-staged": {
"src/**/*.{js,jsx,ts,tsx,json,css,scss,md}": [
"eslint --fix",
"git add"
]
},
"scripts": {
"start": "vite",
"build": "vite build",
"preview": "vite preview",
"fix": "eslint --fix --ext .js,.md,.json src/"
"preview": "vite preview"
},
"browserslist": {
"production": [
@ -88,5 +81,9 @@
"last 1 firefox version",
"last 1 safari version"
]
},
"lint-staged": {
"*.{js,jsx,md,json}": "eslint --cache --fix",
"*.{js,jsx,css,md,json}": "prettier --write"
}
}

View file

@ -115,12 +115,7 @@ const Main = () => {
)}
<main className={classes.wrapper}>
{sidebar && !is404 && wizardTested && (
<Slide
direction="left"
in={true}
mountOnEnter
unmountOnExit
>
<Slide direction="left" in={true} mountOnEnter unmountOnExit>
<div>
<TitleSection title={parent.title}></TitleSection>
</div>

View file

@ -6,7 +6,8 @@ import { styles } from './TextInput.styles'
const useStyles = makeStyles(styles)
const mask = /(\+)(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)(\d{1,3}){0,1}(\d{1,3}){0,1}(\d{1,3}){0,1}(\d{1,3}){0,1}(\d{1,2}){0,1}$/
const mask =
/(\+)(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)(\d{1,3}){0,1}(\d{1,3}){0,1}(\d{1,3}){0,1}(\d{1,3}){0,1}(\d{1,2}){0,1}$/
const maskValue = value =>
value ? value.replace(mask, '$1 $2 $3 $4 $5 $6') : ''

View file

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

View file

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

View file

@ -50,7 +50,6 @@ const Graph = ({
const step = R.clone(start)
while (step <= end) {
ticks.push(R.clone(step))
step.setUTCHours(step.getUTCHours() + interval)
@ -105,19 +104,25 @@ const Graph = ({
])
.rangeRound([GRAPH_MARGIN.left, GRAPH_WIDTH - GRAPH_MARGIN.right])
const groupedByDateInterval = R.map(it => {
const groupedByDateInterval = R.map(
it => {
const lowerBound = R.clone(it)
it.setUTCHours(it.getUTCHours() + 2)
const upperBound = R.clone(it)
return [lowerBound, filterByHourInterval(lowerBound, upperBound)]
}, R.init(getTickIntervals(x.domain(), 2)))
},
R.init(getTickIntervals(x.domain(), 2))
)
const groupedByTxClass = R.map(it => {
const groupedByTxClass = R.map(
it => {
const lowerBound = R.clone(it)
it.setUTCHours(it.getUTCHours() + 2)
const upperBound = R.clone(it)
return [lowerBound, txClassByHourInterval(lowerBound, upperBound)]
}, R.init(getTickIntervals(x.domain(), 2)))
},
R.init(getTickIntervals(x.domain(), 2))
)
const y = d3
.scaleLinear()
@ -416,9 +421,7 @@ const Graph = ({
])
useEffect(() => {
d3.select(ref.current)
.selectAll('*')
.remove()
d3.select(ref.current).selectAll('*').remove()
drawChart()
}, [drawChart])

View file

@ -404,10 +404,7 @@ const Graph = ({
)
// Left side breakpoint label
.call(g => {
const separator = d3
?.select('.dateSeparator')
?.node()
?.getBBox()
const separator = d3?.select('.dateSeparator')?.node()?.getBBox()
if (!separator) return
@ -428,10 +425,7 @@ const Graph = ({
})
// Right side breakpoint label
.call(g => {
const separator = d3
?.select('.dateSeparator')
?.node()
?.getBBox()
const separator = d3?.select('.dateSeparator')?.node()?.getBBox()
if (!separator) return
@ -560,9 +554,7 @@ const Graph = ({
])
useEffect(() => {
d3.select(ref.current)
.selectAll('*')
.remove()
d3.select(ref.current).selectAll('*').remove()
drawChart()
}, [drawChart])

View file

@ -455,10 +455,7 @@ const Graph = ({
)
// Left side breakpoint label
.call(g => {
const separator = d3
?.select('.dateSeparator')
?.node()
?.getBBox()
const separator = d3?.select('.dateSeparator')?.node()?.getBBox()
if (!separator) return
@ -479,10 +476,7 @@ const Graph = ({
})
// Right side breakpoint label
.call(g => {
const separator = d3
?.select('.dateSeparator')
?.node()
?.getBBox()
const separator = d3?.select('.dateSeparator')?.node()?.getBBox()
if (!separator) return
@ -636,9 +630,7 @@ const Graph = ({
])
useEffect(() => {
d3.select(ref.current)
.selectAll('*')
.remove()
d3.select(ref.current).selectAll('*').remove()
drawChart()
}, [drawChart])

View file

@ -36,10 +36,13 @@ const Graph = ({ data, machines, currency, selectedMachine }) => {
const filledMachines =
R.length(machines) >= AMOUNT_OF_MACHINES
? machinesClone
: R.map(it => {
: R.map(
it => {
if (!R.isNil(machinesClone[it])) return machinesClone[it]
return { code: `ghostMachine${it}`, display: `` }
}, R.times(R.identity, AMOUNT_OF_MACHINES))
},
R.times(R.identity, AMOUNT_OF_MACHINES)
)
const txByDevice = R.reduce(
(acc, value) => {
@ -108,8 +111,9 @@ const Graph = ({ data, machines, currency, selectedMachine }) => {
.axisBottom(x)
.tickFormat(
d =>
`${R.find(it => it.code === d[0], filledMachines).display ??
''}`
`${
R.find(it => it.code === d[0], filledMachines).display ?? ''
}`
)
.tickSize(0)
.tickPadding(10)
@ -295,9 +299,7 @@ const Graph = ({ data, machines, currency, selectedMachine }) => {
])
useEffect(() => {
d3.select(ref.current)
.selectAll('*')
.remove()
d3.select(ref.current).selectAll('*').remove()
drawChart()
}, [drawChart])

View file

@ -48,10 +48,7 @@ const GET_USER_DATA = gql`
`
const validationSchema = Yup.object().shape({
email: Yup.string()
.label('Email')
.required()
.email(),
email: Yup.string().label('Email').required().email(),
password: Yup.string().required('Password field is required'),
rememberMe: Yup.boolean()
})

View file

@ -109,9 +109,7 @@ const BlacklistAdvanced = ({
const validationSchema = Yup.object().shape({
label: Yup.string().required('A label is required!'),
content: Yup.string()
.required('The message content is required!')
.trim()
content: Yup.string().required('The message content is required!').trim()
})
return (

View file

@ -36,9 +36,7 @@ const BlackListModal = ({ onClose, addToBlacklist, errorMsg }) => {
address: ''
}}
validationSchema={Yup.object({
address: Yup.string()
.trim()
.required('An address is required')
address: Yup.string().trim().required('An address is required')
})}
onSubmit={({ address }) => {
handleAddToBlacklist(address.trim())

View file

@ -83,63 +83,43 @@ const Wizard = ({ machine, locale, onClose, save, error }) => {
cassette1:
machine.numberOfCassettes >= 1 && step >= 1
? Yup.number().required()
: Yup.number()
.transform(transformNumber)
.nullable(),
: Yup.number().transform(transformNumber).nullable(),
cassette2:
machine.numberOfCassettes >= 2 && step >= 2
? Yup.number().required()
: Yup.number()
.transform(transformNumber)
.nullable(),
: Yup.number().transform(transformNumber).nullable(),
cassette3:
machine.numberOfCassettes >= 3 && step >= 3
? Yup.number().required()
: Yup.number()
.transform(transformNumber)
.nullable(),
: Yup.number().transform(transformNumber).nullable(),
cassette4:
machine.numberOfCassettes >= 4 && step >= 4
? Yup.number().required()
: Yup.number()
.transform(transformNumber)
.nullable(),
: Yup.number().transform(transformNumber).nullable(),
recycler1:
machine.numberOfRecyclers >= 1 && step >= machine.numberOfCassettes + 1
? Yup.number().required()
: Yup.number()
.transform(transformNumber)
.nullable(),
: Yup.number().transform(transformNumber).nullable(),
recycler2:
machine.numberOfRecyclers >= 2 && step >= machine.numberOfCassettes + 2
? Yup.number().required()
: Yup.number()
.transform(transformNumber)
.nullable(),
: Yup.number().transform(transformNumber).nullable(),
recycler3:
machine.numberOfRecyclers >= 3 && step >= machine.numberOfCassettes + 3
? Yup.number().required()
: Yup.number()
.transform(transformNumber)
.nullable(),
: Yup.number().transform(transformNumber).nullable(),
recycler4:
machine.numberOfRecyclers >= 4 && step >= machine.numberOfCassettes + 4
? Yup.number().required()
: Yup.number()
.transform(transformNumber)
.nullable(),
: Yup.number().transform(transformNumber).nullable(),
recycler5:
machine.numberOfRecyclers >= 5 && step >= machine.numberOfCassettes + 5
? Yup.number().required()
: Yup.number()
.transform(transformNumber)
.nullable(),
: Yup.number().transform(transformNumber).nullable(),
recycler6:
machine.numberOfRecyclers >= 6 && step >= machine.numberOfCassettes + 6
? Yup.number().required()
: Yup.number()
.transform(transformNumber)
.nullable()
: Yup.number().transform(transformNumber).nullable()
})
return (

View file

@ -325,10 +325,7 @@ const getOverridesSchema = (values, rawData, locale) => {
const highestBill = R.isEmpty(bills) ? CURRENCY_MAX : Math.max(...bills)
return Yup.object().shape({
machine: Yup.string()
.nullable()
.label('Machine')
.required(),
machine: Yup.string().nullable().label('Machine').required(),
cryptoCurrencies: Yup.array()
.test({
test() {
@ -474,13 +471,8 @@ const getListCommissionsSchema = locale => {
const highestBill = R.isEmpty(bills) ? CURRENCY_MAX : Math.max(...bills)
return Yup.object().shape({
machine: Yup.string()
.label('Machine')
.required(),
cryptoCurrencies: Yup.array()
.label('Crypto currency')
.required()
.min(1),
machine: Yup.string().label('Machine').required(),
cryptoCurrencies: Yup.array().label('Crypto currency').required().min(1),
cashIn: Yup.number()
.label('Cash-in')
.min(percentMin)

View file

@ -263,9 +263,7 @@ const CustomerData = ({
src={
!R.isNil(previewPhoto)
? URL.createObjectURL(previewPhoto)
: `/front-camera-photo/${R.path(['frontCameraPath'])(
customer
)}`
: `/front-camera-photo/${R.path(['frontCameraPath'])(customer)}`
}
/>
) : null
@ -304,9 +302,7 @@ const CustomerData = ({
src={
!R.isNil(previewCard)
? URL.createObjectURL(previewCard)
: `/id-card-photo/${R.path(['idCardPhotoPath'])(
customer
)}`
: `/id-card-photo/${R.path(['idCardPhotoPath'])(customer)}`
}
/>
) : null
@ -386,7 +382,8 @@ const CustomerData = ({
})
}, customInfoRequests)
R.forEach(it => {
R.forEach(
it => {
customFields.push({
fields: [
{
@ -413,9 +410,12 @@ const CustomerData = ({
[it.label]: it.value ?? ''
}
})
}, R.path(['customFields'])(customer) ?? [])
},
R.path(['customFields'])(customer) ?? []
)
R.forEach(it => {
R.forEach(
it => {
initialValues.smsData[it] = smsData[it]
smsDataElements.push({
name: it,
@ -423,7 +423,9 @@ const CustomerData = ({
component: TextInput,
editable: false
})
}, R.keys(smsData) ?? [])
},
R.keys(smsData) ?? []
)
const externalCompliance = R.map(it => ({
fields: [
@ -492,7 +494,9 @@ const CustomerData = ({
deleteEditedData={deleteEditedData}
retrieveAdditionalData={retrieveAdditionalData}
checkAgainstSanctions={checkAgainstSanctions}
editable={editable}>{children}</EditableCard>
editable={editable}>
{children}
</EditableCard>
)
}
@ -509,7 +513,9 @@ const CustomerData = ({
titleIcon={titleIcon}
editable={false}
hasImage={hasImage}
fields={fields}>{children}</EditableCard>
fields={fields}>
{children}
</EditableCard>
)
}
@ -519,7 +525,8 @@ const CustomerData = ({
<div>
<div className={classes.header}>
<H3 className={classes.title}>{'Customer data'}</H3>
{// TODO: Remove false condition for next release
{
// TODO: Remove false condition for next release
// false && (
// <>
// <FeatureButton

View file

@ -66,8 +66,7 @@ const CustomerNotes = ({
handleClick={setEditing}
timezone={timezone}
/>
)
)}
))}
</div>
)}
{!R.isNil(editing) && (

View file

@ -120,9 +120,8 @@ const Customers = () => {
onCompleted: data => setFilteredCustomers(R.path(['customers'])(data))
})
const { data: filtersResponse, loading: loadingFilters } = useQuery(
GET_CUSTOMER_FILTERS
)
const { data: filtersResponse, loading: loadingFilters } =
useQuery(GET_CUSTOMER_FILTERS)
const [createNewCustomer] = useMutation(CREATE_CUSTOMER, {
onCompleted: () => setShowCreationModal(false),

View file

@ -38,9 +38,7 @@ const IdCardPhotoCard = memo(({ customerData, updateCustomer }) => {
{customerData.idCardPhotoPath ? (
<img
className={classes.idCardPhoto}
src={`/id-card-photo/${R.path(['idCardPhotoPath'])(
customerData
)}`}
src={`/id-card-photo/${R.path(['idCardPhotoPath'])(customerData)}`}
alt=""
/>
) : (

View file

@ -18,10 +18,7 @@ const initialValues = {
}
const validationSchema = Yup.object().shape({
title: Yup.string()
.required()
.trim()
.max(25),
title: Yup.string().required().trim().max(25),
content: Yup.string().required()
})

View file

@ -143,9 +143,9 @@ const getFormattedPhone = (phone, country) => {
const getName = it => {
const idData = R.path(['idCardData'])(it)
return `${R.path(['firstName'])(idData) ?? ''} ${R.path(['lastName'])(
idData
) ?? ''}`.trim()
return `${R.path(['firstName'])(idData) ?? ''} ${
R.path(['lastName'])(idData) ?? ''
}`.trim()
}
// Manual Entry Wizard

View file

@ -186,9 +186,7 @@ const RefLineChart = ({
useEffect(() => {
// first we clear old chart DOM elements on component update
d3.select(svgRef.current)
.selectAll('*')
.remove()
d3.select(svgRef.current).selectAll('*').remove()
drawGraph()
}, [drawGraph, realData])

View file

@ -211,12 +211,7 @@ const Graph = ({ data, timeFrame, timezone }) => {
g
.append('g')
.selectAll('line')
.data(
d3
.axisLeft(y)
.scale()
.ticks(5)
)
.data(d3.axisLeft(y).scale().ticks(5))
.join('line')
.attr('y1', d => 0.5 + y(d))
.attr('y2', d => 0.5 + y(d))
@ -240,10 +235,7 @@ const Graph = ({ data, timeFrame, timezone }) => {
)
// Left side breakpoint label
.call(g => {
const separator = d3
?.select('.dateSeparator')
?.node()
?.getBBox()
const separator = d3?.select('.dateSeparator')?.node()?.getBBox()
if (!separator) return
@ -261,10 +253,7 @@ const Graph = ({ data, timeFrame, timezone }) => {
})
// Right side breakpoint label
.call(g => {
const separator = d3
?.select('.dateSeparator')
?.node()
?.getBBox()
const separator = d3?.select('.dateSeparator')?.node()?.getBBox()
if (!separator) return
@ -355,9 +344,7 @@ const Graph = ({ data, timeFrame, timezone }) => {
])
useEffect(() => {
d3.select(ref.current)
.selectAll('*')
.remove()
d3.select(ref.current).selectAll('*').remove()
drawChart()
}, [drawChart])

View file

@ -114,8 +114,7 @@ const MachinesTable = ({ machines = [], numToRender }) => {
<Label2 className={classes.label}> {it + 1}</Label2>
</div>
</HeaderCell>
)
)}
))}
</TableRow>
</TableHead>
<TableBody>

View file

@ -153,42 +153,18 @@ const overrides = (auxData, auxElements, configureCoin) => {
}
const LocaleSchema = Yup.object().shape({
country: Yup.string()
.label('Country')
.required(),
fiatCurrency: Yup.string()
.label('Fiat currency')
.required(),
languages: Yup.array()
.label('Languages')
.required()
.min(1)
.max(4),
cryptoCurrencies: Yup.array()
.label('Crypto currencies')
.required()
.min(1),
timezone: Yup.string()
.label('Timezone')
.required()
country: Yup.string().label('Country').required(),
fiatCurrency: Yup.string().label('Fiat currency').required(),
languages: Yup.array().label('Languages').required().min(1).max(4),
cryptoCurrencies: Yup.array().label('Crypto currencies').required().min(1),
timezone: Yup.string().label('Timezone').required()
})
const OverridesSchema = Yup.object().shape({
machine: Yup.string()
.label('Machine')
.required(),
country: Yup.string()
.label('Country')
.required(),
languages: Yup.array()
.label('Languages')
.required()
.min(1)
.max(4),
cryptoCurrencies: Yup.array()
.label('Crypto currencies')
.required()
.min(1)
machine: Yup.string().label('Machine').required(),
country: Yup.string().label('Country').required(),
languages: Yup.array().label('Languages').required().min(1).max(4),
cryptoCurrencies: Yup.array().label('Crypto currencies').required().min(1)
})
const localeDefaults = {

View file

@ -65,9 +65,8 @@ const IndividualDiscounts = () => {
const { data: discountResponse, loading: discountLoading } = useQuery(
GET_INDIVIDUAL_DISCOUNTS
)
const { data: customerData, loading: customerLoading } = useQuery(
GET_CUSTOMERS
)
const { data: customerData, loading: customerLoading } =
useQuery(GET_CUSTOMERS)
const [createDiscount, { error: creationError }] = useMutation(
CREATE_DISCOUNT,

View file

@ -21,14 +21,8 @@ const initialValues = {
}
const validationSchema = Yup.object().shape({
code: Yup.string()
.required()
.trim()
.max(25),
discount: Yup.number()
.required()
.min(0)
.max(100)
code: Yup.string().required().trim().max(25),
discount: Yup.number().required().min(0).max(100)
})
const PromoCodesModal = ({ showModal, onClose, errorMsg, addCode }) => {

View file

@ -81,9 +81,8 @@ const Logs = () => {
const deviceId = selected?.deviceId
const { data: machineResponse, loading: machinesLoading } = useQuery(
GET_MACHINES
)
const { data: machineResponse, loading: machinesLoading } =
useQuery(GET_MACHINES)
const { data: configResponse, loading: configLoading } = useQuery(GET_DATA)
const timezone = R.path(['config', 'locale_timezone'], configResponse)

View file

@ -106,7 +106,7 @@ const CashUnitDetails = ({
<div className={classes.billList}>
<Label1>Cash box</Label1>
{R.isEmpty(billCount) && <TL2 noMargin>Empty</TL2>}
{(R.keys(billCount)).map((it, idx) => (
{R.keys(billCount).map((it, idx) => (
<span key={idx}>
<TL2 noMargin>{billCount[it]}</TL2>
<Chip label={`${it} ${currency}`} />
@ -149,7 +149,7 @@ const CashUnitDetails = ({
noMargin
className={classes.label}>{`Loading boxes`}</Label1>
<div className={classes.loadingBoxes}>
{(R.range(1, machine.numberOfCassettes + 1)).map((it, idx) => (
{R.range(1, machine.numberOfCassettes + 1).map((it, idx) => (
<CashOut
key={idx}
width={60}

View file

@ -182,10 +182,8 @@ const WizardStep = ({
const numberOfCassettes = machine.numberOfCassettes
const numberOfRecyclers = machine.numberOfRecyclers
const {
name: cashUnitField,
category: cashUnitCategory
} = getCashUnitFieldName(step, numberOfCassettes, numberOfRecyclers)
const { name: cashUnitField, category: cashUnitCategory } =
getCashUnitFieldName(step, numberOfCassettes, numberOfRecyclers)
const originalCashUnitCount = machine?.cashUnits?.[cashUnitField]
const cashUnitDenomination = cashoutSettings?.[cashUnitField]

View file

@ -57,7 +57,7 @@ const getElements = (
return (
<div className={classes.unitsRow}>
<div className={classes.units}>
{(R.range(1, m.numberOfCassettes + 1)).map((it, idx) => (
{R.range(1, m.numberOfCassettes + 1).map((it, idx) => (
<CashOutLite
key={idx}
width={'100%'}

View file

@ -33,14 +33,8 @@ const SingleFieldEditableNumber = ({
setSaving(false)
}
const {
save,
data,
currency,
isEditing,
isDisabled,
setEditing
} = useContext(NotificationsCtx)
const { save, data, currency, isEditing, isDisabled, setEditing } =
useContext(NotificationsCtx)
const schema = Yup.object().shape({
[name]: Yup.number()

View file

@ -14,14 +14,8 @@ const useStyles = makeStyles(styles)
const CryptoBalanceAlerts = ({ section, fieldWidth }) => {
const classes = useStyles()
const {
data,
save,
currency,
setEditing,
isEditing,
isDisabled
} = useContext(NotificationsCtx)
const { data, save, currency, setEditing, isEditing, isDisabled } =
useContext(NotificationsCtx)
return (
<div className={classes.cryptoBalanceAlerts}>

View file

@ -79,9 +79,7 @@ const FiatBalanceOverrides = ({ config, section }) => {
const percentMax = 100
const validationSchema = Yup.object()
.shape({
[MACHINE_KEY]: Yup.string()
.label('Machine')
.required(),
[MACHINE_KEY]: Yup.string().label('Machine').required(),
[CASHBOX_KEY]: Yup.number()
.label('Cash box')
.transform(transformNumber)

View file

@ -11,9 +11,12 @@ import NotificationsCtx from '../NotificationsContext'
const filterClass = type => R.filter(it => it.class === type)
const ThirdPartyProvider = () => {
const { save, data: _data, error, accountsConfig } = useContext(
NotificationsCtx
)
const {
save,
data: _data,
error,
accountsConfig
} = useContext(NotificationsCtx)
const data = fromNamespace('thirdParty')(_data)

View file

@ -82,7 +82,8 @@ const formatContent = content => {
const TOOLTIPS = {
smsCode: ``,
cashOutDispenseReady: ``,
smsReceipt: formatContent(`The contents of this notice will be appended to the end of the SMS receipt sent, and not replace it.\n
smsReceipt:
formatContent(`The contents of this notice will be appended to the end of the SMS receipt sent, and not replace it.\n
To edit the contents of the SMS receipt, please go to the 'Receipt' tab`)
}
@ -124,9 +125,8 @@ const SMSNotices = () => {
const [previewCoords, setPreviewCoords] = useState({ x: 0, y: 0 })
const [errorMsg, setErrorMsg] = useState('')
const { data: messagesData, loading: messagesLoading } = useQuery(
GET_SMS_NOTICES
)
const { data: messagesData, loading: messagesLoading } =
useQuery(GET_SMS_NOTICES)
const timezone = R.path(['config', 'locale_timezone'])(messagesData)

View file

@ -44,9 +44,7 @@ const PREFILL = {
})
},
cashOutDispenseReady: {
validator: Yup.string()
.required('The message content is required!')
.trim()
validator: Yup.string().required('The message content is required!').trim()
},
smsReceipt: {
validator: Yup.string().trim()
@ -89,9 +87,7 @@ const SMSNoticesModal = ({
event: Yup.string().required('An event is required!'),
message:
PREFILL[sms?.event]?.validator ??
Yup.string()
.required('The message content is required!')
.trim()
Yup.string().required('The message content is required!').trim()
})
const handleSubmit = values => {
@ -155,11 +151,9 @@ const SMSNoticesModal = ({
<Info2 noMargin>Values to attach</Info2>
)}
<div className={classes.chipButtons}>
{R.splitEvery(3, CHIPS[sms?.event]).map(
(it, idx) => (
{R.splitEvery(3, CHIPS[sms?.event]).map((it, idx) => (
<div key={idx}>
{it.map(
(ite, idx2) => (
{it.map((ite, idx2) => (
<Chip
key={idx2}
label={ite.display}
@ -177,11 +171,9 @@ const SMSNoticesModal = ({
)
}}
/>
)
)}
))}
</div>
),
)}
))}
</div>
<div className={classes.footer}>
{getErrorMsg(errors, touched, creationError) && (

View file

@ -30,10 +30,7 @@ const leadingZerosTest = (value, context) => {
}
const buildCurrencyOptions = markets => {
const prunedCoins = R.compose(
R.uniq,
R.map(getEquivalentCode)
)(ALL_CRYPTOS)
const prunedCoins = R.compose(R.uniq, R.map(getEquivalentCode))(ALL_CRYPTOS)
return R.map(it => {
const unavailableCryptos = R.difference(prunedCoins, markets[it])
const unavailableCryptosFiltered = R.difference(unavailableCryptos, [it]) // As the markets can have stablecoins to trade against other crypto, filter them out, as there can't be pairs such as USDT/USDT

View file

@ -132,14 +132,10 @@ const DetailsRow = ({ it: tx, timezone }) => {
Number.parseFloat(tx.commissionPercentage, 2) * 100
).toFixed(2, 1) // ROUND_DOWN
const fixedFee = Number.parseFloat(tx.fixedFee) || 0
const fiat = BigNumber(tx.fiat)
.minus(fixedFee)
.toFixed(2, 1) // ROUND_DOWN
const fiat = BigNumber(tx.fiat).minus(fixedFee).toFixed(2, 1) // ROUND_DOWN
const crypto = getCryptoAmount(tx)
const cryptoFee = tx.fee ? `${getCryptoFeeAmount(tx)} ${tx.fiatCode}` : 'N/A'
const exchangeRate = BigNumber(fiat)
.div(crypto)
.toFixed(2, 1) // ROUND_DOWN
const exchangeRate = BigNumber(fiat).div(crypto).toFixed(2, 1) // ROUND_DOWN
const displayExRate = `1 ${tx.cryptoCode} = ${exchangeRate} ${tx.fiatCode}`
const discount = tx.discount ? `-${tx.discount}%` : null
@ -218,8 +214,7 @@ const DetailsRow = ({ it: tx, timezone }) => {
: offErrorColor
}
/>
)
)}
))}
</svg>
<P
noMargin

View file

@ -65,9 +65,7 @@ const ChooseType = () => {
}
const validationSchema = Yup.object().shape({
inputType: Yup.string()
.label('Input type')
.required()
inputType: Yup.string().label('Input type').required()
})
const defaultValues = {

View file

@ -31,12 +31,8 @@ const Screen1Information = () => {
}
const validationSchema = Yup.object().shape({
screen1Title: Yup.string()
.label('Screen title')
.required(),
screen1Text: Yup.string()
.label('Screen text')
.required()
screen1Title: Yup.string().label('Screen title').required(),
screen1Text: Yup.string().label('Screen text').required()
})
const defaultValues = {

View file

@ -29,12 +29,8 @@ const ScreenInformation = () => {
}
const validationSchema = Yup.object().shape({
screen2Title: Yup.string()
.label('Screen title')
.required(),
screen2Text: Yup.string()
.label('Screen text')
.required()
screen2Title: Yup.string().label('Screen title').required(),
screen2Text: Yup.string().label('Screen text').required()
})
const defaultValues = {

View file

@ -40,38 +40,27 @@ const validationSchema = Yup.lazy(values => {
switch (values.inputType) {
case 'numerical':
return Yup.object({
constraintType: Yup.string()
.label('Constraint type')
.required(),
constraintType: Yup.string().label('Constraint type').required(),
inputLength: Yup.number().when('constraintType', {
is: 'length',
then: schema => schema
.min(0)
.required('The number of digits is required'),
then: schema =>
schema.min(0).required('The number of digits is required'),
otherwise: schema => schema.mixed().notRequired()
})
})
case 'text':
return Yup.object({
constraintType: Yup.string()
.label('Constraint type')
.required(),
inputLabel1: Yup.string()
.label('Text entry label')
.required(),
constraintType: Yup.string().label('Constraint type').required(),
inputLabel1: Yup.string().label('Text entry label').required(),
inputLabel2: Yup.string().when('constraintType', {
is: 'spaceSeparation',
then: schema => schema
.label('Second word label')
.required(),
then: schema => schema.label('Second word label').required(),
otherwise: schema => schema.mixed().notRequired()
})
})
case 'choiceList':
return Yup.object({
constraintType: Yup.string()
.label('Constraint type')
.required(),
constraintType: Yup.string().label('Constraint type').required(),
listChoices: Yup.array().test(
'has-2-or-more',
'Choice list needs to have two or more non empty fields',

View file

@ -65,9 +65,8 @@ const Triggers = () => {
const classes = useStyles()
const [wizardType, setWizard] = useState(false)
const { data, loading: configLoading, refetch } = useQuery(GET_CONFIG)
const { data: customInfoReqData, loading: customInfoLoading } = useQuery(
GET_CUSTOM_REQUESTS
)
const { data: customInfoReqData, loading: customInfoLoading } =
useQuery(GET_CUSTOM_REQUESTS)
const [error, setError] = useState(null)
const [subMenu, setSubMenu] = useState(false)

View file

@ -45,9 +45,8 @@ const AdvancedTriggersSettings = memo(() => {
const [isEditingOverrides, setEditingOverrides] = useState(false)
const { data, loading: configLoading } = useQuery(GET_INFO)
const { data: customInfoReqData, loading: customInfoLoading } = useQuery(
GET_CUSTOM_REQUESTS
)
const { data: customInfoReqData, loading: customInfoLoading } =
useQuery(GET_CUSTOM_REQUESTS)
const customInfoRequests =
R.path(['customInfoRequests'])(customInfoReqData) ?? []

View file

@ -30,9 +30,7 @@ const displayRequirement = (code, customInfoRequests) => {
}
const defaultSchema = Yup.object().shape({
expirationTime: Yup.string()
.label('Expiration time')
.required(),
expirationTime: Yup.string().label('Expiration time').required(),
automation: Yup.string()
.label('Automation')
.matches(/(Manual|Automatic)/)
@ -60,9 +58,7 @@ const getOverridesSchema = (values, customInfoRequests) => {
return true
}
}),
expirationTime: Yup.string()
.label('Expiration time')
.required(),
expirationTime: Yup.string().label('Expiration time').required(),
automation: Yup.string()
.label('Automation')
.matches(/(Manual|Automatic)/)

View file

@ -110,9 +110,7 @@ const threshold = Yup.object().shape({
const requirement = Yup.object().shape({
requirement: Yup.string().required(),
suspensionDays: Yup.number()
.transform(transformNumber)
.nullable()
suspensionDays: Yup.number().transform(transformNumber).nullable()
})
const Schema = Yup.object()
@ -266,12 +264,8 @@ const typeSchema = Yup.object()
'The trigger type is required'
),
threshold: Yup.object({
threshold: Yup.number()
.transform(transformNumber)
.nullable(),
thresholdDays: Yup.number()
.transform(transformNumber)
.nullable()
threshold: Yup.number().transform(transformNumber).nullable(),
thresholdDays: Yup.number().transform(transformNumber).nullable()
})
})
.test(({ threshold, triggerType }, context) => {
@ -327,13 +321,8 @@ const typeOptions = [
const Type = ({ ...props }) => {
const classes = useStyles()
const {
errors,
touched,
values,
setTouched,
handleChange
} = useFormikContext()
const { errors, touched, values, setTouched, handleChange } =
useFormikContext()
const typeClass = {
[classes.error]: errors.triggerType && touched.triggerType
@ -484,24 +473,16 @@ const requirementSchema = Yup.object()
requirement: Yup.string().required(),
suspensionDays: Yup.number().when('requirement', {
is: value => value === 'suspend',
then: schema => schema
.nullable()
.transform(transformNumber),
otherwise: schema => schema
.nullable()
.transform(() => null)
then: schema => schema.nullable().transform(transformNumber),
otherwise: schema => schema.nullable().transform(() => null)
}),
customInfoRequestId: Yup.string().when('requirement', {
is: value => value !== 'custom',
then: schema => schema
.nullable()
.transform(() => '')
then: schema => schema.nullable().transform(() => '')
}),
externalService: Yup.string().when('requirement', {
is: value => value !== 'external',
then: schema => schema
.nullable()
.transform(() => '')
then: schema => schema.nullable().transform(() => '')
})
}).required()
})
@ -583,13 +564,8 @@ const Requirement = ({
customInfoRequests = []
}) => {
const classes = useStyles()
const {
touched,
errors,
values,
handleChange,
setTouched
} = useFormikContext()
const { touched, errors, values, handleChange, setTouched } =
useFormikContext()
const isSuspend = values?.requirement?.requirement === 'suspend'
const isCustom = values?.requirement?.requirement === 'custom'
@ -766,9 +742,9 @@ const RequirementInput = ({ customInfoRequests = [] }) => {
R.path(['requirement', 'customInfoRequestId'])(values) ?? ''
const isSuspend = requirement === 'suspend'
const display = customRequestId
? R.path(['customRequest', 'name'])(
? (R.path(['customRequest', 'name'])(
R.find(customReqIdMatches(customRequestId))(customInfoRequests)
) ?? ''
) ?? '')
: getView(requirementOptions, 'display')(requirement)
return (
@ -798,9 +774,9 @@ const RequirementView = ({
const classes = useStyles()
const display =
requirement === 'custom'
? R.path(['customRequest', 'name'])(
? (R.path(['customRequest', 'name'])(
R.find(customReqIdMatches(customInfoRequestId))(customInfoRequests)
) ?? ''
) ?? '')
: requirement === 'external'
? `External verification (${onlyFirstToUpper(externalService)})`
: getView(requirementOptions, 'display')(requirement)

View file

@ -119,8 +119,7 @@ const Routes = () => {
{...transitionProps}
in={true}
mountOnEnter
unmountOnExit
>
unmountOnExit>
<div className={classes.wrapper}>
<Dashboard />
</div>
@ -139,8 +138,7 @@ const Routes = () => {
{...transitionProps}
in={!!matchPath(location.pathname, { path: route })}
mountOnEnter
unmountOnExit
>
unmountOnExit>
<div className={classes.wrapper}>
<PrivateRoute path={route} key={key}>
<Page name={key} />

View file

@ -6,7 +6,8 @@ const WALLET_SCORING_DEFAULT_THRESHOLD = 9
const AUTOMATIC = 'automatic'
const MANUAL = 'manual'
const IP_CHECK_REGEX = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
const IP_CHECK_REGEX =
/^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/
const SWEEPABLE_CRYPTOS = ['ETH']

View file

@ -20,11 +20,7 @@ const splitOnUpper = R.compose(
R.replace(/([A-Z])/g, ' $1'),
toFirstLower
)
const startCase = R.compose(
R.join(' '),
R.map(onlyFirstToUpper),
splitOnUpper
)
const startCase = R.compose(R.join(' '), R.map(onlyFirstToUpper), splitOnUpper)
const sentenceCase = R.compose(onlyFirstToUpper, R.join(' '), splitOnUpper)

View file

@ -7,6 +7,9 @@ import fixReactVirtualized from 'esbuild-plugin-react-virtualized'
export default defineConfig({
base: '/',
build: {
outDir: 'build'
},
server: {
port: 3001,
proxy: {
@ -19,18 +22,13 @@ export default defineConfig({
},
optimizeDeps: {
esbuildOptions: {
plugins: [
fixReactVirtualized,
],
plugins: [fixReactVirtualized]
}
},
plugins: [
react(),
svgr(),
],
plugins: [react(), svgr()],
resolve: {
alias: {
'src': fileURLToPath(new URL('./src', import.meta.url))
},
},
src: fileURLToPath(new URL('./src', import.meta.url))
}
}
})