1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-06-18 01:18:23 +02:00
unleash.unleash/frontend/src/utils/formatConstraintValue.ts
2025-03-24 14:26:58 +01:00

19 lines
637 B
TypeScript

import { formatDateYMDHMS } from 'utils/formatDate';
import type { ILocationSettings } from 'hooks/useLocationSettings';
import { CURRENT_TIME_CONTEXT_FIELD } from 'utils/operatorsForContext';
import type { ConstraintSchema } from 'openapi';
export const formatConstraintValue = (
constraint: Pick<ConstraintSchema, 'value' | 'contextName'>,
locationSettings: ILocationSettings,
): string | undefined => {
if (
constraint.value &&
constraint.contextName === CURRENT_TIME_CONTEXT_FIELD
) {
return formatDateYMDHMS(constraint.value, locationSettings.locale);
}
return constraint.value;
};