feat: add T&C configs to GraphQL API
This commit is contained in:
parent
b380e2845c
commit
df2213566e
2 changed files with 26 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
const _ = require('lodash/fp')
|
const _ = require('lodash/fp')
|
||||||
|
const nmd = require('nano-markdown')
|
||||||
|
|
||||||
const { accounts: accountsConfig, countries, languages } = require('../new-admin/config')
|
const { accounts: accountsConfig, countries, languages } = require('../new-admin/config')
|
||||||
const plugins = require('../plugins')
|
const plugins = require('../plugins')
|
||||||
|
|
@ -65,6 +66,18 @@ const buildTriggers = (allTriggers) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TODO: From `lib/routes/termsAndConditionsRoutes.js` -- remove this after
|
||||||
|
* terms are removed from the GraphQL API too.
|
||||||
|
*/
|
||||||
|
const massageTerms = terms => (terms.active && terms.text) ? ({
|
||||||
|
delay: Boolean(terms.delay),
|
||||||
|
title: terms.title,
|
||||||
|
text: nmd(terms.text),
|
||||||
|
accept: terms.acceptButtonText,
|
||||||
|
cancel: terms.cancelButtonText,
|
||||||
|
}) : null
|
||||||
|
|
||||||
const staticConfig = (parent, { currentConfigVersion }, { deviceId, deviceName, settings }, info) =>
|
const staticConfig = (parent, { currentConfigVersion }, { deviceId, deviceName, settings }, info) =>
|
||||||
Promise.all([
|
Promise.all([
|
||||||
plugins(settings, deviceId).staticConfigQueries(),
|
plugins(settings, deviceId).staticConfigQueries(),
|
||||||
|
|
@ -75,6 +88,7 @@ const staticConfig = (parent, { currentConfigVersion }, { deviceId, deviceName,
|
||||||
configManager.getLocale(deviceId, settings.config),
|
configManager.getLocale(deviceId, settings.config),
|
||||||
configManager.getOperatorInfo(settings.config),
|
configManager.getOperatorInfo(settings.config),
|
||||||
configManager.getReceipt(settings.config),
|
configManager.getReceipt(settings.config),
|
||||||
|
massageTerms(configManager.getTermsConditions(settings.config)),
|
||||||
!!configManager.getCashOut(deviceId, settings.config).active,
|
!!configManager.getCashOut(deviceId, settings.config).active,
|
||||||
])
|
])
|
||||||
.then(([
|
.then(([
|
||||||
|
|
@ -86,6 +100,7 @@ const staticConfig = (parent, { currentConfigVersion }, { deviceId, deviceName,
|
||||||
localeInfo,
|
localeInfo,
|
||||||
operatorInfo,
|
operatorInfo,
|
||||||
receiptInfo,
|
receiptInfo,
|
||||||
|
terms,
|
||||||
twoWayMode,
|
twoWayMode,
|
||||||
]) =>
|
]) =>
|
||||||
(currentConfigVersion && currentConfigVersion >= staticConf.configVersion) ?
|
(currentConfigVersion && currentConfigVersion >= staticConf.configVersion) ?
|
||||||
|
|
@ -105,6 +120,7 @@ const staticConfig = (parent, { currentConfigVersion }, { deviceId, deviceName,
|
||||||
twoWayMode,
|
twoWayMode,
|
||||||
speedtestFiles,
|
speedtestFiles,
|
||||||
urlsToPing,
|
urlsToPing,
|
||||||
|
terms,
|
||||||
}),
|
}),
|
||||||
_.update('triggersAutomation', _.mapValues(_.eq('Automatic'))),
|
_.update('triggersAutomation', _.mapValues(_.eq('Automatic'))),
|
||||||
addOperatorInfo(operatorInfo),
|
addOperatorInfo(operatorInfo),
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,14 @@ type Trigger {
|
||||||
thresholdDays: Int
|
thresholdDays: Int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Terms {
|
||||||
|
delay: Boolean!
|
||||||
|
title: String!
|
||||||
|
text: String!
|
||||||
|
accept: String!
|
||||||
|
cancel: String!
|
||||||
|
}
|
||||||
|
|
||||||
type StaticConfig {
|
type StaticConfig {
|
||||||
configVersion: Int!
|
configVersion: Int!
|
||||||
|
|
||||||
|
|
@ -90,6 +98,8 @@ type StaticConfig {
|
||||||
|
|
||||||
triggersAutomation: TriggersAutomation!
|
triggersAutomation: TriggersAutomation!
|
||||||
triggers: [Trigger!]!
|
triggers: [Trigger!]!
|
||||||
|
|
||||||
|
terms: Terms
|
||||||
}
|
}
|
||||||
|
|
||||||
type DynamicCoinValues {
|
type DynamicCoinValues {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue