@@ -181,14 +181,12 @@ export const AdminCMSPageEditor: React.FC = ErrorBoundary.with(
181181 } ;
182182
183183 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+ }
192190 } ;
193191
194192 return (
@@ -199,46 +197,58 @@ export const AdminCMSPageEditor: React.FC = ErrorBoundary.with(
199197 extraActions = { [ openOnSiteButton ] }
200198 afterSubmit = { onSubmit }
201199 >
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%" } }
224209 >
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+ 먼저 페이지를 만든 후 섹션 추가 / 수정이 가능합니다.
237250 </ Stack >
238- </ Stack >
239- < br />
240- < Divider />
241- < br />
251+ ) }
242252 </ AdminEditor >
243253 ) ;
244254 } )
0 commit comments