diff --git a/src/components/FeatureFlagModal/FeatureFlagModal.tsx b/src/components/FeatureFlagModal/FeatureFlagModal.tsx index fb01aa4d13d..caeb77d2c97 100644 --- a/src/components/FeatureFlagModal/FeatureFlagModal.tsx +++ b/src/components/FeatureFlagModal/FeatureFlagModal.tsx @@ -226,12 +226,13 @@ interface DynamicConfigDropdownProps { label: string options: any[] selected: any[] + parser: (opt: string) => any } -function DynamicConfigDropdown({ configName, label, options, selected }: DynamicConfigDropdownProps) { +function DynamicConfigDropdown({ configName, label, options, selected, parser }: DynamicConfigDropdownProps) { const updateConfig = useUpdateConfig() const handleSelectChange = (e: React.ChangeEvent) => { - const selectedValues = Array.from(e.target.selectedOptions, (opt) => Number.parseInt(opt.value)) + const selectedValues = Array.from(e.target.selectedOptions, (opt) => parser(opt.value)) // Saved to atom as { [configName]: { [configName]: values } } to match Statsig return format updateConfig(configName, { [configName]: selectedValues }) } @@ -299,6 +300,7 @@ export default function FeatureFlagModal() { !isNaN(Number(v))) as ChainId[]} + parser={Number.parseInt} configName={DynamicConfigName.quickRouteChains} label="Enable quick routes for these chains" /> diff --git a/src/featureFlags/dynamicConfig/quickRouteChains.ts b/src/featureFlags/dynamicConfig/quickRouteChains.ts index ef17b7fe7da..c6663632d24 100644 --- a/src/featureFlags/dynamicConfig/quickRouteChains.ts +++ b/src/featureFlags/dynamicConfig/quickRouteChains.ts @@ -8,10 +8,10 @@ export function useQuickRouteChains(): ChainId[] { const featureFlagsContext = useFeatureFlagsContext() let chains = statsigConfig.get(DynamicConfigName.quickRouteChains, []) as ChainId[] - const modalSetChains = - featureFlagsContext.configs[DynamicConfigName.quickRouteChains][DynamicConfigName.quickRouteChains] - if (Array.isArray(modalSetChains) && modalSetChains !== chains) { - chains = modalSetChains + const modalSettings = featureFlagsContext.configs[DynamicConfigName.quickRouteChains] + if (modalSettings) { + const modalSetChains = modalSettings[DynamicConfigName.quickRouteChains] + if (Array.isArray(modalSetChains) && modalSetChains !== chains) chains = modalSetChains } if (chains.every((c) => Object.values(ChainId).includes(c))) { return chains