@@ -2,6 +2,7 @@ import MainLayout from "@/lib/@components/MainLayout";
2
2
import useSols from "@/lib/@hooks/useSols" ;
3
3
import { Button , Flex , Text , Textarea } from "@chakra-ui/react" ;
4
4
import { useState } from "react" ;
5
+ import { PostSolReqBody } from "./api/sol" ;
5
6
6
7
export default function NewSol ( ) {
7
8
const [ solutionInfo , setSolutionInfo ] = useState ( "" ) ;
@@ -12,7 +13,12 @@ export default function NewSol() {
12
13
const checkValid = ( ) => {
13
14
try {
14
15
const info = JSON . parse ( solutionInfo ) ;
15
- const valid = info . probId && info . author && solCode !== "" ;
16
+ const valid =
17
+ info . probId &&
18
+ info . author &&
19
+ info . lang &&
20
+ info . createdAt &&
21
+ solCode !== "" ;
16
22
setIsValid ( valid ) ;
17
23
return valid ;
18
24
} catch ( e ) {
@@ -23,11 +29,13 @@ export default function NewSol() {
23
29
24
30
const handleSumbit = ( ) => {
25
31
if ( checkValid ( ) ) {
26
- const info = JSON . parse ( solutionInfo ) ;
32
+ const info = JSON . parse ( solutionInfo ) as PostSolReqBody ;
27
33
addSolMutaiton . mutate (
28
34
{
29
35
author : info . author ,
30
36
probId : info . probId ,
37
+ lang : info . lang ,
38
+ createdAt : info . createdAt ,
31
39
code : solCode
32
40
} ,
33
41
{
@@ -54,17 +62,6 @@ export default function NewSol() {
54
62
문제 추가
55
63
</ Button >
56
64
</ Flex >
57
- < Text fontSize = "xl" > 풀이 데이터</ Text >
58
- < Textarea
59
- h = "120px"
60
- placeholder = "probId, author in json format"
61
- value = { solutionInfo }
62
- onChange = { e => {
63
- setSolutionInfo ( e . target . value ) ;
64
- } }
65
- onBlur = { checkValid }
66
- />
67
-
68
65
< Text fontSize = "xl" > 제출한 정답</ Text >
69
66
< Textarea
70
67
placeholder = "function()"
@@ -75,6 +72,16 @@ export default function NewSol() {
75
72
onBlur = { checkValid }
76
73
h = "400px"
77
74
/>
75
+ < Text fontSize = "xl" > 풀이 데이터</ Text >
76
+ < Textarea
77
+ h = "120px"
78
+ placeholder = "probId, author, lang, createdAt in json format"
79
+ value = { solutionInfo }
80
+ onChange = { e => {
81
+ setSolutionInfo ( e . target . value ) ;
82
+ } }
83
+ onBlur = { checkValid }
84
+ />
78
85
</ Flex >
79
86
</ MainLayout >
80
87
) ;
0 commit comments