@@ -4,20 +4,24 @@ import axios from "axios";
4
4
import PropTypes from "prop-types" ;
5
5
import { useNavigate } from "react-router-dom" ;
6
6
7
- import ErrorModal from "@/shared/components/ErrorModal" ;
8
7
import LoadingModal from "@/shared/components/LoadingModal" ;
9
8
import Modal from "@/shared/components/Modal" ;
10
9
11
10
import CharacterSelectFrom from "./CharacterSelectForm" ;
12
11
import EmailInputForm from "./EmailInputForm" ;
13
12
import SubmitResultModal from "./SubmitResultModal" ;
14
13
15
- const VideoSubmitModal = ( { videoId, trim } ) => {
16
- const [ step , setStep ] = useState ( 1 ) ;
14
+ const VideoSubmitModal = ( {
15
+ videoId,
16
+ trim,
17
+ closeModal,
18
+ setError,
19
+ step,
20
+ setStep,
21
+ } ) => {
17
22
const [ selectedCharacter , setSelectedCharacter ] = useState ( null ) ;
18
23
const [ email , setEmail ] = useState ( "" ) ;
19
24
const [ isSubmitSuccess , setIsSubmitSuccess ] = useState ( false ) ;
20
- const [ error , setError ] = useState ( null ) ;
21
25
const [ isLoading , setIsLoading ] = useState ( false ) ;
22
26
const navigate = useNavigate ( ) ;
23
27
@@ -73,43 +77,44 @@ const VideoSubmitModal = ({ videoId, trim }) => {
73
77
setStep ( 1 ) ;
74
78
} ;
75
79
76
- const closeModal = ( ) => {
77
- setError ( null ) ;
78
- } ;
79
-
80
80
return (
81
- < >
82
- { ! isSubmitSuccess && ! error && (
83
- < Modal
84
- onClick = { step === 1 ? selectCharacter : handleSubmit }
85
- buttonText = { step === 1 ? "다음" : "제출" }
86
- >
87
- { step === 1 ? (
88
- < CharacterSelectFrom
89
- selectedCharacter = { selectedCharacter }
90
- onCharacterSelect = { setSelectedCharacter }
91
- />
92
- ) : (
93
- < EmailInputForm
94
- email = { email }
95
- onEmailChange = { setEmail }
96
- goToPreviousStep = { goToPreviousStep }
97
- />
98
- ) }
99
- </ Modal >
100
- ) }
81
+ < div >
82
+ < Modal
83
+ onClose = { closeModal }
84
+ onClick = { step === 1 ? selectCharacter : handleSubmit }
85
+ buttonText = { step === 1 ? "다음" : "제출" }
86
+ >
87
+ { step === 1 ? (
88
+ < CharacterSelectFrom
89
+ selectedCharacter = { selectedCharacter }
90
+ onCharacterSelect = { setSelectedCharacter }
91
+ />
92
+ ) : (
93
+ < EmailInputForm
94
+ email = { email }
95
+ onEmailChange = { setEmail }
96
+ goToPreviousStep = { goToPreviousStep }
97
+ />
98
+ ) }
99
+ </ Modal >
101
100
{ isSubmitSuccess && (
102
- < SubmitResultModal onClick = { handleSuccessModalClose } />
101
+ < SubmitResultModal
102
+ onClose = { handleSuccessModalClose }
103
+ onClick = { handleSuccessModalClose }
104
+ />
103
105
) }
104
106
{ isLoading && < LoadingModal /> }
105
- { error && < ErrorModal onClick = { closeModal } message = { error } /> }
106
- </ >
107
+ </ div >
107
108
) ;
108
109
} ;
109
110
110
111
VideoSubmitModal . propTypes = {
111
112
videoId : PropTypes . string . isRequired ,
112
113
trim : PropTypes . arrayOf ( PropTypes . number ) . isRequired ,
114
+ closeModal : PropTypes . func . isRequired ,
115
+ setError : PropTypes . func . isRequired ,
116
+ step : PropTypes . number . isRequired ,
117
+ setStep : PropTypes . func . isRequired ,
113
118
} ;
114
119
115
120
export default VideoSubmitModal ;
0 commit comments