File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -74,8 +74,7 @@ const GameEditorPage = function GameEditorPage({ editMode }: IProps) {
74
74
getFieldProps,
75
75
getFieldMeta,
76
76
handleSubmit,
77
- // dirty,
78
- // isValid,
77
+ isValid,
79
78
setValues,
80
79
} = useFormik ( {
81
80
initialValues : initialForm ,
@@ -139,15 +138,21 @@ const GameEditorPage = function GameEditorPage({ editMode }: IProps) {
139
138
return < SyncLoader /> ;
140
139
}
141
140
142
- // const isSubmitDisabled = !dirty || !isValid;
141
+ const handleEditButtonClick = ( ) => {
142
+ if ( isUpdatingGameName && isValid ) {
143
+ handleSubmit ( )
144
+ } else {
145
+ setIsUpdatingGameName ( true )
146
+ }
147
+ }
143
148
144
149
return (
145
150
< div >
146
151
< h2 className = "text-2xl font-bold italic font-sans mb-8" >
147
152
{ editMode ? "UPDATE GAME" : "NEW GAME" }
148
153
</ h2 >
149
154
< div className = "flex flex-wrap" >
150
- < form onSubmit = { handleSubmit } className = "py-10 mr-8" >
155
+ < form className = "py-10 mr-8" >
151
156
< div className = "flex" >
152
157
< div >
153
158
{ isUpdatingGameName ?
@@ -180,8 +185,7 @@ const GameEditorPage = function GameEditorPage({ editMode }: IProps) {
180
185
</ div >
181
186
182
187
< div className = "mt-4" >
183
- { /* FIX THIS LOGIC */ }
184
- < Button onClick = { ( ) => setIsUpdatingGameName ( true ) } >
188
+ < Button type = "button" onClick = { handleEditButtonClick } >
185
189
{ editMode ? "Update Game" : "Create Game" }
186
190
</ Button >
187
191
</ div >
You can’t perform that action at this time.
0 commit comments