feat: add config migration

This commit is contained in:
Sérgio Salgado 2021-05-06 19:09:36 +01:00 committed by Josh Harvey
parent cf6e5354ec
commit da0d25c040
4 changed files with 26 additions and 5 deletions

View file

@ -129,7 +129,8 @@ function migrateLocales (config) {
country: 'country',
fiatCurrency: 'fiatCurrency',
machineLanguages: 'languages',
cryptoCurrencies: 'cryptoCurrencies'
cryptoCurrencies: 'cryptoCurrencies',
timezone: 'timezone'
}
const { global, scoped } = getConfigFields(_.keys(codes), config)

View file

@ -0,0 +1,18 @@
const _ = require('lodash/fp')
const settingsLoader = require('../lib/new-settings-loader')
exports.up = function (next) {
settingsLoader.loadLatest()
.then(({ config }) => {
if (!_.isEmpty(config))
config.locale.timezone = '0:0'
return settingsLoader.saveConfig(config)
})
.then(() => next())
.catch(err => next(err))
}
exports.down = function (next) {
next()
}

View file

@ -42,6 +42,8 @@ const allFields = (getData, onChange, auxElements = []) => {
const tzLabels = getTzLabels(timezonesData)
console.log(tzLabels)
const findSuggestion = it => {
const machine = R.find(R.propEq('deviceId', it.machine))(machineData)
return machine ? [machine] : []
@ -63,7 +65,7 @@ const allFields = (getData, onChange, auxElements = []) => {
},
{
name: 'country',
width: 150,
width: 200,
size: 'sm',
view: getView(countryData, 'display'),
input: Autocomplete,
@ -87,7 +89,7 @@ const allFields = (getData, onChange, auxElements = []) => {
},
{
name: 'languages',
width: 240,
width: 200,
size: 'sm',
view: displayCodeArray(languageData),
input: Autocomplete,
@ -165,7 +167,7 @@ const LocaleSchema = Yup.object().shape({
.label('Crypto Currencies')
.required()
.min(1),
timezone: Yup.object()
timezone: Yup.string()
.label('Timezone')
.required()
})

View file

@ -70,7 +70,7 @@ const buildLabel = tz => {
const getTzLabels = timezones =>
R.map(
it => ({ label: buildLabel(it), code: it }),
it => ({ label: buildLabel(it), code: `${it.utcOffset}:${it.dstOffset}` }),
getFinalTimezones(timezones)
)