feat: add machine rates screen toggle

This commit is contained in:
Sérgio Salgado 2022-07-15 19:59:41 +01:00 committed by Rafael
parent d0573daa74
commit 3b12dd5608
9 changed files with 151 additions and 4 deletions

View file

@ -61,6 +61,13 @@ const addReceiptInfo = receiptInfo => ret => {
}
const addMachineScreenOpts = addSmthInfo(
'screenOptions',
[
'rates.active'
]
)
/* TODO: Simplify this. */
const buildTriggers = allTriggers => {
const normalTriggers = []
@ -117,6 +124,7 @@ const staticConfig = ({ currentConfigVersion, deviceId, deviceName, pq, settings
configManager.getLocale(deviceId, settings.config),
configManager.getOperatorInfo(settings.config),
configManager.getReceipt(settings.config),
configManager.getAllMachineScreenOpts(settings.config),
!!configManager.getCashOut(deviceId, settings.config).active,
getMachine(deviceId, currentConfigVersion),
configManager.getCustomerAuthenticationMethod(settings.config)
@ -129,6 +137,7 @@ const staticConfig = ({ currentConfigVersion, deviceId, deviceName, pq, settings
localeInfo,
operatorInfo,
receiptInfo,
machineScreenOpts,
twoWayMode,
{ numberOfCassettes, numberOfRecyclers },
customerAuthentication,
@ -153,7 +162,8 @@ const staticConfig = ({ currentConfigVersion, deviceId, deviceName, pq, settings
urlsToPing,
}),
addOperatorInfo(operatorInfo),
addReceiptInfo(receiptInfo)
addReceiptInfo(receiptInfo),
addMachineScreenOpts(machineScreenOpts)
)(staticConf))
}

View file

@ -49,6 +49,14 @@ type ReceiptInfo {
addressQRCode: Boolean!
}
type MachineScreenOptions {
rates: RateScreenOptions!
}
type RateScreenOptions {
active: Boolean!
}
type SpeedtestFile {
url: String!
size: Int!
@ -147,6 +155,7 @@ type StaticConfig {
operatorInfo: OperatorInfo
machineInfo: MachineInfo!
receiptInfo: ReceiptInfo
screenOptions: MachineScreenOptions
speedtestFiles: [SpeedtestFile!]!
urlsToPing: [String!]!

View file

@ -13,7 +13,12 @@ const namespaces = {
TERMS_CONDITIONS: 'termsConditions',
CASH_OUT: 'cashOut',
CASH_IN: 'cashIn',
COMPLIANCE: 'compliance'
COMPLIANCE: 'compliance',
MACHINE_SCREENS: 'machineScreens'
}
const machineScreens = {
RATES: 'rates'
}
const stripl = _.curry((q, str) => _.startsWith(q, str) ? str.slice(q.length) : str)
@ -72,6 +77,8 @@ const getCoinAtmRadar = fromNamespace(namespaces.COIN_ATM_RADAR)
const getTermsConditions = fromNamespace(namespaces.TERMS_CONDITIONS)
const getReceipt = fromNamespace(namespaces.RECEIPT)
const getCompliance = fromNamespace(namespaces.COMPLIANCE)
const getMachineScreenOpts = (screenName, config) => _.compose(fromNamespace(screenName), fromNamespace(namespaces.MACHINE_SCREENS))(config)
const getAllMachineScreenOpts = config => _.reduce((acc, value) => ({ ...acc, [value]: getMachineScreenOpts(value, config) }), {}, _.values(machineScreens))
const getAllCryptoCurrencies = (config) => {
const locale = fromNamespace(namespaces.LOCALE)(config)
@ -180,6 +187,8 @@ module.exports = {
getWalletSettings,
getCashInSettings,
getOperatorInfo,
getMachineScreenOpts,
getAllMachineScreenOpts,
getNotifications,
getGlobalNotifications,
getLocale,

View file

@ -278,6 +278,7 @@ function plugins (settings, deviceId) {
const localeConfig = configManager.getLocale(deviceId, settings.config)
const fiatCode = localeConfig.fiatCurrency
const cryptoCodes = localeConfig.cryptoCurrencies
const machineScreenOpts = configManager.getAllMachineScreenOpts(settings.config)
const tickerPromises = cryptoCodes.map(c => getTickerRates(fiatCode, c))
const balancePromises = cryptoCodes.map(c => fiatBalance(fiatCode, c))
@ -327,7 +328,8 @@ function plugins (settings, deviceId) {
coins,
configVersion,
areThereAvailablePromoCodes: numberOfAvailablePromoCodes > 0,
timezone
timezone,
screenOptions: machineScreenOpts
}
})
}