@@ -470,9 +470,28 @@ export const FeatureIndexPage: FC = memo(() => {
470
470
) ;
471
471
472
472
const handleArchive = useCallback (
473
- async ( data ) => {
474
- dispatch (
475
- data . feature . archived
473
+ async ( data , saveFeatureType ) => {
474
+ const handleDispatch = async ( action ) => {
475
+ await dispatch ( action ) ;
476
+ archiveReset ( ) ;
477
+ setIsArchiveConfirmDialogOpen ( false ) ;
478
+ history . replace (
479
+ `${ PAGE_PATH_ROOT } ${ currentEnvironment . urlCode } ${ PAGE_PATH_FEATURES } `
480
+ ) ;
481
+ updateFeatureList ( null , 1 ) ;
482
+ } ;
483
+
484
+ if ( saveFeatureType === SaveFeatureType . SCHEDULE ) {
485
+ handleDispatch (
486
+ updateFeature ( {
487
+ environmentId : currentEnvironment . id ,
488
+ id : data . feature . id ,
489
+ comment : data . comment ,
490
+ archived : ! data . feature . archived
491
+ } )
492
+ ) ;
493
+ } else {
494
+ const action = data . feature . archived
476
495
? unarchiveFeature ( {
477
496
environmentId : currentEnvironment . id ,
478
497
id : data . feature . id ,
@@ -482,15 +501,10 @@ export const FeatureIndexPage: FC = memo(() => {
482
501
environmentId : currentEnvironment . id ,
483
502
id : data . feature . id ,
484
503
comment : data . comment
485
- } )
486
- ) . then ( ( ) => {
487
- archiveReset ( ) ;
488
- setIsArchiveConfirmDialogOpen ( false ) ;
489
- history . replace (
490
- `${ PAGE_PATH_ROOT } ${ currentEnvironment . urlCode } ${ PAGE_PATH_FEATURES } `
491
- ) ;
492
- updateFeatureList ( null , 1 ) ;
493
- } ) ;
504
+ } ) ;
505
+
506
+ handleDispatch ( action ) ;
507
+ }
494
508
} ,
495
509
[ dispatch , archiveReset , setIsArchiveConfirmDialogOpen ]
496
510
) ;
@@ -620,8 +634,8 @@ export const FeatureIndexPage: FC = memo(() => {
620
634
featureId = { archiveMethod . getValues ( ) . feature ?. id }
621
635
feature = { archiveMethod . getValues ( ) . feature }
622
636
open = { isArchiveConfirmDialogOpen }
623
- handleSubmit = { ( ) => {
624
- archiveHandleSubmit ( handleArchive ) ( ) ;
637
+ handleSubmit = { ( arg ) => {
638
+ archiveHandleSubmit ( ( data ) => handleArchive ( data , arg ) ) ( ) ;
625
639
} }
626
640
onClose = { ( ) => setIsArchiveConfirmDialogOpen ( false ) }
627
641
title = {
0 commit comments