@@ -19,6 +19,7 @@ import {createCampaignPage, getCampaignOptionsWindowData, useCampaignEntityRecor
19
19
20
20
import styles from './CampaignDetailsPage.module.scss' ;
21
21
import { useEntityRecord } from '@wordpress/core-data' ;
22
+ import CampaignDetailsErrorBoundary from '@givewp/campaigns/admin/components/CampaignDetailsPage/Components/CampaignDetailsErrorBoundary' ;
22
23
23
24
interface Show {
24
25
contextMenu ?: boolean ;
@@ -251,123 +252,125 @@ export default function CampaignsDetailsPage({campaignId}) {
251
252
}
252
253
253
254
return (
254
- < FormProvider { ...methods } >
255
- < form onSubmit = { handleSubmit ( onSubmit ) } >
256
- < article className = { `interface-interface-skeleton__content ${ styles . page } ` } >
257
- < header className = { styles . pageHeader } >
258
- < div className = { styles . breadcrumb } >
259
- < a href = { `${ adminUrl } edit.php?post_type=give_forms&page=give-campaigns` } >
260
- { __ ( 'Campaigns' , 'give' ) }
261
- </ a >
262
- < BreadcrumbSeparatorIcon />
263
- < span > { campaign . title } </ span >
264
- </ div >
265
- < div className = { styles . flexContainer } >
266
- < div className = { styles . flexRow } >
267
- < h1 className = { styles . pageTitle } > { campaign . title } </ h1 >
268
- < StatusBadge status = { campaign . status } />
255
+ < CampaignDetailsErrorBoundary >
256
+ < FormProvider { ...methods } >
257
+ < form onSubmit = { handleSubmit ( onSubmit ) } >
258
+ < article className = { `interface-interface-skeleton__content ${ styles . page } ` } >
259
+ < header className = { styles . pageHeader } >
260
+ < div className = { styles . breadcrumb } >
261
+ < a href = { `${ adminUrl } edit.php?post_type=give_forms&page=give-campaigns` } >
262
+ { __ ( 'Campaigns' , 'give' ) }
263
+ </ a >
264
+ < BreadcrumbSeparatorIcon />
265
+ < span > { campaign . title } </ span >
269
266
</ div >
267
+ < div className = { styles . flexContainer } >
268
+ < div className = { styles . flexRow } >
269
+ < h1 className = { styles . pageTitle } > { campaign . title } </ h1 >
270
+ < StatusBadge status = { campaign . status } />
271
+ </ div >
272
+
273
+ < div className = { `${ styles . flexRow } ${ styles . justifyContentEnd } ` } >
274
+ { ! isCreatingPage && campaign . pageId > 0 ? (
275
+ < a
276
+ className = { `button button-secondary ${ styles . editCampaignPageButton } ` }
277
+ href = { `${ adminUrl } post.php?post=${ campaign . pageId } &action=edit` }
278
+ rel = "noopener noreferrer"
279
+ >
280
+ { __ ( 'Edit campaign page' , 'give' ) }
281
+ </ a >
282
+ ) : (
283
+ < button
284
+ type = "button"
285
+ className = { `button button-tertiary ${ styles . createCampaignPageButton } ` }
286
+ onClick = { handleCampaignPageCreation }
287
+ disabled = { isCreatingPage }
288
+ >
289
+ { isCreatingPage
290
+ ? __ ( 'Creating Campaign Page' , 'give' )
291
+ : __ ( 'Create Campaign Page' , 'give' ) }
292
+ </ button >
293
+ ) }
270
294
271
- < div className = { `${ styles . flexRow } ${ styles . justifyContentEnd } ` } >
272
- { ! isCreatingPage && campaign . pageId > 0 ? (
273
- < a
274
- className = { `button button-secondary ${ styles . editCampaignPageButton } ` }
275
- href = { `${ adminUrl } post.php?post=${ campaign . pageId } &action=edit` }
276
- rel = "noopener noreferrer"
295
+ < button
296
+ type = "submit"
297
+ disabled = { campaign . status !== 'draft' && ! formState . isDirty }
298
+ className = { `button button-primary ${ styles . updateCampaignButton } ` }
299
+ onClick = { ( e ) => {
300
+ setValue ( 'status' , 'active' , { shouldDirty : true } ) ;
301
+ } }
277
302
>
278
- { __ ( 'Edit campaign page' , 'give' ) }
279
- </ a >
280
- ) : (
303
+ { isSaving === 'active' ? (
304
+ < >
305
+ { __ ( 'Updating campaign' , 'give' ) }
306
+ < Spinner />
307
+ </ >
308
+ ) : (
309
+ __ ( 'Update campaign' , 'give' )
310
+ ) }
311
+ </ button >
312
+
281
313
< button
282
- type = "button"
283
- className = { `button button-tertiary ${ styles . createCampaignPageButton } ` }
284
- onClick = { handleCampaignPageCreation }
285
- disabled = { isCreatingPage }
314
+ className = { `button button-secondary ${ styles . campaignButtonDots } ` }
315
+ onClick = { ( e ) => {
316
+ e . preventDefault ( ) ;
317
+ setShow ( { contextMenu : ! show . contextMenu } ) ;
318
+ } }
286
319
>
287
- { isCreatingPage
288
- ? __ ( 'Creating Campaign Page' , 'give' )
289
- : __ ( 'Create Campaign Page' , 'give' ) }
320
+ < DotsIcons />
290
321
</ button >
291
- ) }
292
-
293
- < button
294
- type = "submit"
295
- disabled = { campaign . status !== 'draft' && ! formState . isDirty }
296
- className = { `button button-primary ${ styles . updateCampaignButton } ` }
297
- onClick = { ( e ) => {
298
- setValue ( 'status' , 'active' , { shouldDirty : true } ) ;
299
- } }
300
- >
301
- { isSaving === 'active' ? (
302
- < >
303
- { __ ( 'Updating campaign' , 'give' ) }
304
- < Spinner />
305
- </ >
306
- ) : (
307
- __ ( 'Update campaign' , 'give' )
322
+
323
+ { ! isSaving && show . contextMenu && (
324
+ < div className = { styles . contextMenu } >
325
+ { campaign . pagePermalink && (
326
+ < a
327
+ href = { campaign . pagePermalink }
328
+ aria-label = { __ ( 'View Campaign' , 'give' ) }
329
+ className = { styles . contextMenuItem }
330
+ >
331
+ < ViewIcon /> { __ ( 'View Campaign' , 'give' ) }
332
+ </ a >
333
+ ) }
334
+ { campaign . status === 'archived' ? (
335
+ < a
336
+ href = "#"
337
+ className = { cx ( styles . contextMenuItem , styles . draft ) }
338
+ onClick = { ( ) => {
339
+ updateStatus ( 'draft' ) ;
340
+ dispatch . dismissNotification ( 'update-archive-notice' ) ;
341
+ } }
342
+ >
343
+ < ArrowReverse /> { __ ( 'Move to draft' , 'give' ) }
344
+ </ a >
345
+ ) : (
346
+ < a
347
+ href = "#"
348
+ className = { cx ( styles . contextMenuItem , styles . archive ) }
349
+ onClick = { ( ) => setShow ( { confirmationModal : true } ) }
350
+ >
351
+ < TrashIcon /> { __ ( 'Archive Campaign' , 'give' ) }
352
+ </ a >
353
+ ) }
354
+ </ div >
308
355
) }
309
- </ button >
310
-
311
- < button
312
- className = { `button button-secondary ${ styles . campaignButtonDots } ` }
313
- onClick = { ( e ) => {
314
- e . preventDefault ( ) ;
315
- setShow ( { contextMenu : ! show . contextMenu } ) ;
316
- } }
317
- >
318
- < DotsIcons />
319
- </ button >
320
-
321
- { ! isSaving && show . contextMenu && (
322
- < div className = { styles . contextMenu } >
323
- { campaign . pagePermalink && (
324
- < a
325
- href = { campaign . pagePermalink }
326
- aria-label = { __ ( 'View Campaign' , 'give' ) }
327
- className = { styles . contextMenuItem }
328
- >
329
- < ViewIcon /> { __ ( 'View Campaign' , 'give' ) }
330
- </ a >
331
- ) }
332
- { campaign . status === 'archived' ? (
333
- < a
334
- href = "#"
335
- className = { cx ( styles . contextMenuItem , styles . draft ) }
336
- onClick = { ( ) => {
337
- updateStatus ( 'draft' ) ;
338
- dispatch . dismissNotification ( 'update-archive-notice' ) ;
339
- } }
340
- >
341
- < ArrowReverse /> { __ ( 'Move to draft' , 'give' ) }
342
- </ a >
343
- ) : (
344
- < a
345
- href = "#"
346
- className = { cx ( styles . contextMenuItem , styles . archive ) }
347
- onClick = { ( ) => setShow ( { confirmationModal : true } ) }
348
- >
349
- < TrashIcon /> { __ ( 'Archive Campaign' , 'give' ) }
350
- </ a >
351
- ) }
352
- </ div >
353
- ) }
356
+ </ div >
354
357
</ div >
355
- </ div >
356
- </ header >
357
- < Tabs />
358
- < ArchiveCampaignDialog
359
- title = { __ ( 'Archive Campaign' , 'give' ) }
360
- isOpen = { show . confirmationModal }
361
- handleClose = { ( ) => setShow ( { confirmationModal : false , contextMenu : false } ) }
362
- handleConfirm = { ( ) => {
363
- updateStatus ( 'archived ') ;
364
- dispatch . dismissNotification ( 'update-campaign-draft-page-notice' ) ;
365
- } }
366
- / >
367
- </ article >
368
- </ form >
369
- < NotificationPlaceholder type = "snackbar" /> ;
370
- </ FormProvider >
358
+ </ header >
359
+ < Tabs / >
360
+ < ArchiveCampaignDialog
361
+ title = { __ ( 'Archive Campaign' , 'give' ) }
362
+ isOpen = { show . confirmationModal }
363
+ handleClose = { ( ) => setShow ( { confirmationModal : false , contextMenu : false } ) }
364
+ handleConfirm = { ( ) => {
365
+ updateStatus ( 'archived' ) ;
366
+ dispatch . dismissNotification ( 'update-campaign-draft-page-notice ') ;
367
+ } }
368
+ />
369
+ </ article >
370
+ </ form >
371
+ < NotificationPlaceholder type = "snackbar" /> ;
372
+ </ FormProvider >
373
+ </ CampaignDetailsErrorBoundary >
371
374
) ;
372
375
}
373
376
0 commit comments