@@ -2,6 +2,7 @@ import MainLayout from "@/lib/@components/MainLayout";
22import useSols from "@/lib/@hooks/useSols" ;
33import { Button , Flex , Text , Textarea } from "@chakra-ui/react" ;
44import { useState } from "react" ;
5+ import { PostSolReqBody } from "./api/sol" ;
56
67export default function NewSol ( ) {
78 const [ solutionInfo , setSolutionInfo ] = useState ( "" ) ;
@@ -12,7 +13,12 @@ export default function NewSol() {
1213 const checkValid = ( ) => {
1314 try {
1415 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 !== "" ;
1622 setIsValid ( valid ) ;
1723 return valid ;
1824 } catch ( e ) {
@@ -23,11 +29,13 @@ export default function NewSol() {
2329
2430 const handleSumbit = ( ) => {
2531 if ( checkValid ( ) ) {
26- const info = JSON . parse ( solutionInfo ) ;
32+ const info = JSON . parse ( solutionInfo ) as PostSolReqBody ;
2733 addSolMutaiton . mutate (
2834 {
2935 author : info . author ,
3036 probId : info . probId ,
37+ lang : info . lang ,
38+ createdAt : info . createdAt ,
3139 code : solCode
3240 } ,
3341 {
@@ -54,17 +62,6 @@ export default function NewSol() {
5462 문제 추가
5563 </ Button >
5664 </ 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-
6865 < Text fontSize = "xl" > 제출한 정답</ Text >
6966 < Textarea
7067 placeholder = "function()"
@@ -75,6 +72,16 @@ export default function NewSol() {
7572 onBlur = { checkValid }
7673 h = "400px"
7774 />
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+ />
7885 </ Flex >
7986 </ MainLayout >
8087 ) ;
0 commit comments