From 222881474daf4293d0aa3eaebd697cbd75f8f7d4 Mon Sep 17 00:00:00 2001 From: Charisma Kausar Date: Wed, 15 Nov 2023 08:29:01 +0800 Subject: [PATCH] feat: add error messages for invalid test cases --- frontend/src/pages/questions/_form.tsx | 31 ++++++++++++++------------ 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/frontend/src/pages/questions/_form.tsx b/frontend/src/pages/questions/_form.tsx index dd475b6f..487c3c06 100644 --- a/frontend/src/pages/questions/_form.tsx +++ b/frontend/src/pages/questions/_form.tsx @@ -45,7 +45,7 @@ if __name__ == "__main__": target = int(input()) print(" ".join(twoSum(nums, target)))`, -'java': `import java.util.*; + 'java': `import java.util.*; class Solution { public int[] twoSum(int[] nums, int target) { @@ -66,7 +66,7 @@ class Solution { } }`, -'c++': `#include + 'c++': `#include #include using namespace std; @@ -105,7 +105,7 @@ interface QuestionsFormProps { export default function QuestionsForm({ form, onSubmit, - onDelete = () => {}, + onDelete = () => { }, type = "add", loading = false, }: QuestionsFormProps) { @@ -179,7 +179,7 @@ export default function QuestionsForm({ Question Description - { + { field.onChange(e); forceUpdate(); }} /> @@ -210,7 +210,7 @@ export default function QuestionsForm({ })}
+ { form.getFieldState('testCasesInputs').invalid &&

Test case inputs cannot be empty

} + { form.getFieldState('testCasesOutputs').invalid &&

Test case outputs cannot be empty

} Default Java Code { - field.onChange(e); - forceUpdate(); - }} /> + field.onChange(e); + forceUpdate(); + }} />
@@ -261,10 +263,10 @@ export default function QuestionsForm({ Default Python Code - { - field.onChange(e); - forceUpdate(); - }} /> + { + field.onChange(e); + forceUpdate(); + }} /> @@ -293,8 +295,9 @@ export default function QuestionsForm({ ) : (