From fe879d45fc906f34aecaa8735b03d928993df6bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Salgado?= Date: Mon, 21 Feb 2022 16:13:30 +0000 Subject: [PATCH] fix: add default timezone migration --- migrations/1645459054117-default-timezone.js | 20 ++++++++++++++++++++ new-lamassu-admin/src/utils/timezone-list.js | 4 +++- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 migrations/1645459054117-default-timezone.js diff --git a/migrations/1645459054117-default-timezone.js b/migrations/1645459054117-default-timezone.js new file mode 100644 index 00000000..d2e64fb0 --- /dev/null +++ b/migrations/1645459054117-default-timezone.js @@ -0,0 +1,20 @@ +const _ = require('lodash/fp') +const { saveConfig, loadLatest } = require('../lib/new-settings-loader') + +exports.up = function (next) { + const newConfig = {} + return loadLatest() + .then(config => { + if (!_.isNil(config.config.locale_timezone)) return + newConfig[`locale_timezone`] = 'GMT' + return saveConfig(newConfig) + }) + .then(next) + .catch(err => { + return next(err) + }) +} + +module.exports.down = function (next) { + next() +} diff --git a/new-lamassu-admin/src/utils/timezone-list.js b/new-lamassu-admin/src/utils/timezone-list.js index 8683cfcd..f7984f7d 100644 --- a/new-lamassu-admin/src/utils/timezone-list.js +++ b/new-lamassu-admin/src/utils/timezone-list.js @@ -143,4 +143,6 @@ const buildTzLabels = timezoneList => { const labels = buildTzLabels(timezones) -export { labels, timezones } +const DEFAULT_TIMEZONE = 'GMT' + +export { labels, timezones, DEFAULT_TIMEZONE }