Skip to content

Commit c2328a7

Browse files
Some mild refactoring
1 parent d912dc7 commit c2328a7

File tree

1 file changed

+13
-19
lines changed
  • frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/StrategyExecution/ConstraintExecution

1 file changed

+13
-19
lines changed

frontend/src/component/playground/Playground/PlaygroundResultsTable/FeatureResultInfoPopoverCell/FeatureStrategyList/StrategyList/StrategyItem/StrategyExecution/ConstraintExecution/ConstraintExecution.tsx

+13-19
Original file line numberDiff line numberDiff line change
@@ -40,27 +40,11 @@ const ConstraintOk = () => {
4040
);
4141
};
4242

43-
export const ConstraintError = ({
44-
constraint,
45-
input,
46-
}: {
47-
constraint: PlaygroundConstraintSchema;
48-
input?: PlaygroundRequestSchema;
49-
}) => {
50-
const formatText = () => {
51-
const value = input?.context[constraint.contextName];
52-
53-
if (value) {
54-
return `Constraint not met – the value in the context: { ${value} } is not ${constraint.operator} ${constraint.contextName}`;
55-
}
56-
57-
return `Constraint not met – no value was specified for ${constraint.contextName}`;
58-
};
59-
43+
export const ConstraintError = ({ text }: { text: string }) => {
6044
return (
6145
<StyledContainer variant='error'>
6246
<Cancel aria-hidden='true' />
63-
<p>{formatText()}</p>
47+
<p>{text}</p>
6448
</StyledContainer>
6549
);
6650
};
@@ -71,13 +55,23 @@ export const ConstraintExecution: FC<IConstraintExecutionProps> = ({
7155
}) => {
7256
if (!constraint) return null;
7357

58+
const errorText = () => {
59+
const value = input?.context[constraint.contextName];
60+
61+
if (value) {
62+
return `Constraint not met – the value in the context: { ${value} } is not ${constraint.operator} ${constraint.contextName}`;
63+
}
64+
65+
return `Constraint not met – no value was specified for ${constraint.contextName}`;
66+
};
67+
7468
return (
7569
<>
7670
<ConstraintItem {...constraint} />
7771
{constraint.result ? (
7872
<ConstraintOk />
7973
) : (
80-
<ConstraintError input={input} constraint={constraint} />
74+
<ConstraintError text={errorText()} />
8175
)}
8276
</>
8377
);

0 commit comments

Comments
 (0)