Skip to content

Commit 496e691

Browse files
committed
fix: detect only timezone on the list
ref issue #4109
1 parent 40ea623 commit 496e691

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/components/IncompleteUserProfile/IncompleteUserProfile.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import PT from 'prop-types'
66
import { PROFILE_FIELDS_CONFIG } from '../../config/constants'
77
import ProfileSettingsForm from '../../routes/settings/routes/profile/components/ProfileSettingsForm'
88
import { getDefaultTopcoderRole } from '../../helpers/permissions'
9+
import { timezones } from 'appirio-tech-react-components/constants/timezones'
910

1011
const IncompleteUserProfile = ({
1112
profileSettings,
@@ -31,7 +32,12 @@ const IncompleteUserProfile = ({
3132
// if time zone is required and doesn't have a value yet,
3233
// then detect timezone using browser feature and prefill the form
3334
if (fieldsConfig.timeZone && !profileSettings.settings.timeZone) {
34-
prefilledProfileSettings.settings.timeZone = (new Intl.DateTimeFormat()).resolvedOptions().timeZone
35+
const autodetectedTimeZone = (new Intl.DateTimeFormat()).resolvedOptions().timeZone
36+
// only use autodetected timezone if it's on our timezone list, otherwise leave it empty
37+
if (_.find(timezones, { zoneName: autodetectedTimeZone})) {
38+
prefilledProfileSettings.settings.timeZone = autodetectedTimeZone
39+
}
40+
console.log('Auto-detected timezone', prefilledProfileSettings.settings.timeZone)
3541
}
3642

3743
if (isTopcoderUser) {

0 commit comments

Comments
 (0)