6
6
PROJECT_SUBJECT_INPUT_ID ,
7
7
} from "../../constants/projects" ;
8
8
import { Step } from "../../types/common" ;
9
+ import usePostCreateProject from "../../hooks/queries/project/usePostCreateProject" ;
9
10
10
11
interface ProjectCreateMainSectionProps {
11
12
currentStep : Step ;
@@ -16,8 +17,9 @@ const ProjectCreateMainSection = ({
16
17
currentStep,
17
18
setCurrentStep,
18
19
} : ProjectCreateMainSectionProps ) => {
19
- const projectNameRef = useRef < string > ( "" ) ;
20
+ const projectTitleRef = useRef < string > ( "" ) ;
20
21
const projectSubjectRef = useRef < string > ( "" ) ;
22
+ const mutation = usePostCreateProject ( ) ;
21
23
22
24
const handlePrevStepAreaClick = ( ) => {
23
25
setCurrentStep ( ( prevStep ) => {
@@ -29,25 +31,37 @@ const ProjectCreateMainSection = ({
29
31
} ) ;
30
32
} ;
31
33
32
- const handleCreateButtonClick = async ( ) => { } ;
34
+ const handleCreateButtonClick = async ( ) => {
35
+ mutation . mutate ( {
36
+ title : projectTitleRef . current ,
37
+ subject : projectSubjectRef . current ,
38
+ } ) ;
39
+ } ;
33
40
34
41
const handleNextButtonClick = ( ) => {
35
42
setCurrentStep ( PROJECT_CREATE_STEP . STEP2 ) ;
36
43
} ;
37
44
38
45
useEffect ( ( ) => {
39
- const nicknameInput = document . getElementById ( PROJECT_NAME_INPUT_ID ) ;
40
- const nicknameInputElement = document . getElementById (
46
+ const projectTitleInputElement = document . getElementById (
47
+ PROJECT_NAME_INPUT_ID
48
+ ) ;
49
+ const projectTitleInputBox = document . getElementById (
41
50
`${ PROJECT_NAME_INPUT_ID } -input-box`
42
51
) ;
43
52
44
53
switch ( currentStep . NUMBER ) {
45
54
case PROJECT_CREATE_STEP . STEP1 . NUMBER :
46
- nicknameInput ?. scrollIntoView ( { behavior : "smooth" , block : "center" } ) ;
55
+ projectTitleInputElement ?. focus ( ) ;
56
+ projectTitleInputElement ?. scrollIntoView ( {
57
+ behavior : "smooth" ,
58
+ block : "center" ,
59
+ } ) ;
47
60
break ;
48
61
49
62
case PROJECT_CREATE_STEP . STEP2 . NUMBER :
50
- nicknameInputElement ?. scrollIntoView ( {
63
+ document . getElementById ( PROJECT_SUBJECT_INPUT_ID ) ?. focus ( ) ;
64
+ projectTitleInputBox ?. scrollIntoView ( {
51
65
behavior : "smooth" ,
52
66
block : "start" ,
53
67
} ) ;
@@ -65,7 +79,7 @@ const ProjectCreateMainSection = ({
65
79
> </ div >
66
80
< section className = "h-[100%] overflow-y-hidden" >
67
81
< ProjectCreateInput
68
- inputRef = { projectNameRef }
82
+ inputRef = { projectTitleRef }
69
83
targetStepIsCurrentStep = { currentStep === PROJECT_CREATE_STEP . STEP1 }
70
84
setCurrentStep = { setCurrentStep }
71
85
onNextButtonClick = { handleNextButtonClick }
0 commit comments