chore: clean up ValidationResult for NumericalInput problems (#2849)
This commit is contained in:
@@ -73,7 +73,7 @@ const AnswerOption = ({
|
||||
|
||||
if (problemType !== ProblemTypeKeys.NUMERIC || !answer.isAnswerRange) {
|
||||
return (
|
||||
<Form.Group isInvalid={!data?.isValid ?? true}>
|
||||
<Form.Group isInvalid={!data?.isValid}>
|
||||
<Form.Control
|
||||
as="textarea"
|
||||
className="answer-option-textarea text-gray-500 small"
|
||||
@@ -89,7 +89,7 @@ const AnswerOption = ({
|
||||
placeholder={intl.formatMessage(messages.answerTextboxPlaceholder)}
|
||||
|
||||
/>
|
||||
{(!data?.isValid ?? true) && (
|
||||
{(!data?.isValid) && (
|
||||
<Form.Control.Feedback type="invalid">
|
||||
<FormattedMessage {...messages.answerNumericErrorText} />
|
||||
</Form.Control.Feedback>
|
||||
|
||||
@@ -4,8 +4,14 @@ import api from '@src/editors/data/services/cms/api';
|
||||
|
||||
const getApiBaseUrl = () => getConfig().STUDIO_BASE_URL;
|
||||
|
||||
interface ValidationResult {
|
||||
isValid: boolean;
|
||||
error?: string;
|
||||
preview?: string;
|
||||
}
|
||||
|
||||
export const useValidateInputBlock = () => useMutation({
|
||||
mutationFn: async (title : string) => {
|
||||
mutationFn: async (title : string): Promise<ValidationResult> => {
|
||||
try {
|
||||
const res = await api.validateBlockNumericInput({ studioEndpointUrl: `${getApiBaseUrl()}`, data: { formula: title } });
|
||||
return camelCaseObject(res.data);
|
||||
|
||||
Reference in New Issue
Block a user