Skip to content

Commit

Permalink
fix: feature state value conversion (#3946)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyle-ssg authored Jun 13, 2024
1 parent 9db236a commit d4f948d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion frontend/common/types/responses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ export type FeatureStateValue = {
float_value?: number | null
integer_value?: boolean | null
string_value: string
type: string
type: 'int' | 'unicode' | 'bool' | 'float'
}

export type MultivariateOption = {
Expand Down
19 changes: 10 additions & 9 deletions frontend/common/utils/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,17 @@ const Utils = Object.assign({}, require('./base/_utils'), {
return null
}

if (typeof featureState.integer_value === 'number') {
return Utils.getTypedValue(featureState.integer_value)
}
if (typeof featureState.float_value === 'number') {
return Utils.getTypedValue(featureState.float_value)
//@ts-ignore value_type is the type key on core traits
switch (featureState.value_type || featureState.type) {
case 'bool':
return featureState.boolean_value
case 'float':
return featureState.float_value
case 'int':
return featureState.integer_value
default:
return featureState.string_value
}

return Utils.getTypedValue(
featureState.string_value || featureState.boolean_value,
)
},
findOperator(
operator: SegmentCondition['operator'],
Expand Down

0 comments on commit d4f948d

Please sign in to comment.