@@ -181,14 +181,12 @@ export const AdminCMSPageEditor: React.FC = ErrorBoundary.with(
181
181
} ;
182
182
183
183
const onSubmit = ( ) => {
184
- bulkUpdateSectionsMutation . mutate (
185
- { sections : editorState . sections || [ ] } ,
186
- {
187
- onError : ( error ) => {
188
- addErrorSnackbar ( error ) ;
189
- } ,
190
- }
191
- ) ;
184
+ if ( id ) {
185
+ bulkUpdateSectionsMutation . mutate (
186
+ { sections : editorState . sections || [ ] } ,
187
+ { onError : addErrorSnackbar }
188
+ ) ;
189
+ }
192
190
} ;
193
191
194
192
return (
@@ -199,46 +197,58 @@ export const AdminCMSPageEditor: React.FC = ErrorBoundary.with(
199
197
extraActions = { [ openOnSiteButton ] }
200
198
afterSubmit = { onSubmit }
201
199
>
202
- < br />
203
- < Divider />
204
- < br />
205
- < Stack
206
- direction = "row"
207
- spacing = { 2 }
208
- sx = { { width : "100%" , height : "100%" , maxWidth : "100%" } }
209
- >
210
- < Tabs
211
- orientation = "vertical"
212
- value = { editorState . tab }
213
- onChange = { setTab }
214
- scrollButtons = { false }
215
- >
216
- < Tab wrapped label = "한국어" />
217
- < Tab wrapped label = "영어" />
218
- </ Tabs >
219
- < Stack sx = { { width : "100%" , height : "100%" , maxWidth : "100%" } } >
220
- < Button
221
- size = "small"
222
- onClick = { insertNewSection ( 0 ) }
223
- startIcon = { < Add /> }
200
+ { id ? (
201
+ < >
202
+ < br />
203
+ < Divider />
204
+ < br />
205
+ < Stack
206
+ direction = "row"
207
+ spacing = { 2 }
208
+ sx = { { width : "100%" , height : "100%" , maxWidth : "100%" } }
224
209
>
225
- 맨 처음에 섹션 추가
226
- </ Button >
227
- { editorState . sections ?. map ( ( section , index ) => (
228
- < SectionEditorField
229
- key = { section . id || index }
230
- defaultValue = { section }
231
- language = { editorState . tab === 0 ? "ko" : "en" }
232
- onInsertNewSection = { insertNewSection ( index + 1 ) }
233
- onChange = { onSectionDataChange ( index ) }
234
- onDelete = { deleteSection ( index ) }
235
- />
236
- ) ) }
210
+ < Tabs
211
+ orientation = "vertical"
212
+ value = { editorState . tab }
213
+ onChange = { setTab }
214
+ scrollButtons = { false }
215
+ >
216
+ < Tab wrapped label = "한국어" />
217
+ < Tab wrapped label = "영어" />
218
+ </ Tabs >
219
+ < Stack sx = { { width : "100%" , height : "100%" , maxWidth : "100%" } } >
220
+ < Button
221
+ size = "small"
222
+ onClick = { insertNewSection ( 0 ) }
223
+ startIcon = { < Add /> }
224
+ >
225
+ 맨 처음에 섹션 추가
226
+ </ Button >
227
+ { editorState . sections ?. map ( ( section , index ) => (
228
+ < SectionEditorField
229
+ key = { section . id || index }
230
+ defaultValue = { section }
231
+ language = { editorState . tab === 0 ? "ko" : "en" }
232
+ onInsertNewSection = { insertNewSection ( index + 1 ) }
233
+ onChange = { onSectionDataChange ( index ) }
234
+ onDelete = { deleteSection ( index ) }
235
+ />
236
+ ) ) }
237
+ </ Stack >
238
+ </ Stack >
239
+ < br />
240
+ < Divider />
241
+ < br />
242
+ </ >
243
+ ) : (
244
+ < Stack
245
+ justifyContent = "center"
246
+ alignItems = "center"
247
+ sx = { { color : "red" } }
248
+ >
249
+ 먼저 페이지를 만든 후 섹션 추가 / 수정이 가능합니다.
237
250
</ Stack >
238
- </ Stack >
239
- < br />
240
- < Divider />
241
- < br />
251
+ ) }
242
252
</ AdminEditor >
243
253
) ;
244
254
} )
0 commit comments