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 nmd = require('nano-markdown')
|
||||
|
||||
const { accounts: accountsConfig, countries, languages } = require('../new-admin/config')
|
||||
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) =>
|
||||
Promise.all([
|
||||
plugins(settings, deviceId).staticConfigQueries(),
|
||||
|
|
@ -75,6 +88,7 @@ const staticConfig = (parent, { currentConfigVersion }, { deviceId, deviceName,
|
|||
configManager.getLocale(deviceId, settings.config),
|
||||
configManager.getOperatorInfo(settings.config),
|
||||
configManager.getReceipt(settings.config),
|
||||
massageTerms(configManager.getTermsConditions(settings.config)),
|
||||
!!configManager.getCashOut(deviceId, settings.config).active,
|
||||
])
|
||||
.then(([
|
||||
|
|
@ -86,6 +100,7 @@ const staticConfig = (parent, { currentConfigVersion }, { deviceId, deviceName,
|
|||
localeInfo,
|
||||
operatorInfo,
|
||||
receiptInfo,
|
||||
terms,
|
||||
twoWayMode,
|
||||
]) =>
|
||||
(currentConfigVersion && currentConfigVersion >= staticConf.configVersion) ?
|
||||
|
|
@ -105,6 +120,7 @@ const staticConfig = (parent, { currentConfigVersion }, { deviceId, deviceName,
|
|||
twoWayMode,
|
||||
speedtestFiles,
|
||||
urlsToPing,
|
||||
terms,
|
||||
}),
|
||||
_.update('triggersAutomation', _.mapValues(_.eq('Automatic'))),
|
||||
addOperatorInfo(operatorInfo),
|
||||
|
|
|
|||
|
|
@ -69,6 +69,14 @@ type Trigger {
|
|||
thresholdDays: Int
|
||||
}
|
||||
|
||||
type Terms {
|
||||
delay: Boolean!
|
||||
title: String!
|
||||
text: String!
|
||||
accept: String!
|
||||
cancel: String!
|
||||
}
|
||||
|
||||
type StaticConfig {
|
||||
configVersion: Int!
|
||||
|
||||
|
|
@ -90,6 +98,8 @@ type StaticConfig {
|
|||
|
||||
triggersAutomation: TriggersAutomation!
|
||||
triggers: [Trigger!]!
|
||||
|
||||
terms: Terms
|
||||
}
|
||||
|
||||
type DynamicCoinValues {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue