@@ -35,6 +35,7 @@ import { useMessageContext } from '../context/UserMessages';
35
35
import PostProcessingToast from './Popups/GraphEnhancementDialog/PostProcessingCheckList/PostProcessingToast' ;
36
36
import { getChunkText } from '../services/getChunkText' ;
37
37
import ChunkPopUp from './Popups/ChunkPopUp' ;
38
+ import { isExpired } from '../utils/Utils' ;
38
39
39
40
const ConfirmationDialog = lazy ( ( ) => import ( './Popups/LargeFilePopUp/ConfirmationDialog' ) ) ;
40
41
@@ -55,8 +56,10 @@ const Content: React.FC<ContentProps> = ({
55
56
const [ openGraphView , setOpenGraphView ] = useState < boolean > ( false ) ;
56
57
const [ inspectedName , setInspectedName ] = useState < string > ( '' ) ;
57
58
const [ documentName , setDocumentName ] = useState < string > ( '' ) ;
58
- const { setUserCredentials, userCredentials, setConnectionStatus, isGdsActive, isReadOnlyUser } = useCredentials ( ) ;
59
+ const { setUserCredentials, userCredentials, setConnectionStatus, isGdsActive, isReadOnlyUser, isGCSActive } =
60
+ useCredentials ( ) ;
59
61
const [ showConfirmationModal , setshowConfirmationModal ] = useState < boolean > ( false ) ;
62
+ const [ showExpirationModal , setshowExpirationModal ] = useState < boolean > ( false ) ;
60
63
const [ extractLoading , setextractLoading ] = useState < boolean > ( false ) ;
61
64
const [ retryFile , setRetryFile ] = useState < string > ( '' ) ;
62
65
const [ retryLoading , setRetryLoading ] = useState < boolean > ( false ) ;
@@ -662,7 +665,8 @@ const Content: React.FC<ContentProps> = ({
662
665
const onClickHandler = ( ) => {
663
666
const selectedRows = childRef . current ?. getSelectedRows ( ) ;
664
667
if ( selectedRows ?. length ) {
665
- let selectedLargeFiles : CustomFile [ ] = [ ] ;
668
+ const selectedLargeFiles : CustomFile [ ] = [ ] ;
669
+ const expiredFiles : CustomFile [ ] = [ ] ;
666
670
for ( let index = 0 ; index < selectedRows . length ; index ++ ) {
667
671
const parsedData : CustomFile = selectedRows [ index ] ;
668
672
if (
@@ -673,9 +677,18 @@ const Content: React.FC<ContentProps> = ({
673
677
) {
674
678
selectedLargeFiles . push ( parsedData ) ;
675
679
}
680
+ if (
681
+ parsedData . fileSource === 'local file' &&
682
+ ( parsedData . status === 'New' || parsedData . status == 'Ready to Reprocess' ) &&
683
+ isExpired ( parsedData ?. createdAt as Date )
684
+ ) {
685
+ expiredFiles . push ( parsedData ) ;
686
+ }
676
687
}
677
688
if ( selectedLargeFiles . length ) {
678
689
setshowConfirmationModal ( true ) ;
690
+ } else if ( expiredFiles . length && isGCSActive ) {
691
+ setshowExpirationModal ( true ) ;
679
692
} else {
680
693
handleGenerateGraph ( selectedRows . filter ( ( f ) => f . status === 'New' || f . status === 'Ready to Reprocess' ) ) ;
681
694
}
@@ -690,16 +703,34 @@ const Content: React.FC<ContentProps> = ({
690
703
}
691
704
return false ;
692
705
} ) ;
706
+ const expiredFiles = filesData . filter ( ( f ) => {
707
+ console . log (
708
+ f . fileSource === 'local file'
709
+ ? { isExpired : isExpired ( f ?. createdAt as Date ) , name : f . name , createdAt : f . createdAt }
710
+ : 'Not Local File'
711
+ ) ;
712
+ if (
713
+ f . fileSource === 'local file' &&
714
+ ( f . status === 'New' || f . status == 'Ready to Reprocess' ) &&
715
+ isExpired ( f ?. createdAt as Date )
716
+ ) {
717
+ return true ;
718
+ }
719
+ return false ;
720
+ } ) ;
693
721
const selectAllNewFiles = filesData . filter ( ( f ) => f . status === 'New' || f . status === 'Ready to Reprocess' ) ;
694
722
const stringified = selectAllNewFiles . reduce ( ( accu , f ) => {
695
723
const key = f . id ;
696
724
// @ts -ignore
697
725
accu [ key ] = true ;
698
726
return accu ;
699
727
} , { } ) ;
728
+ console . log ( expiredFiles ) ;
700
729
setRowSelection ( stringified ) ;
701
730
if ( largefiles . length ) {
702
731
setshowConfirmationModal ( true ) ;
732
+ } else if ( expiredFiles . length && isGCSActive ) {
733
+ setshowExpirationModal ( true ) ;
703
734
} else {
704
735
handleGenerateGraph ( filesData . filter ( ( f ) => f . status === 'New' || f . status === 'Ready to Reprocess' ) ) ;
705
736
}
@@ -729,6 +760,19 @@ const Content: React.FC<ContentProps> = ({
729
760
> </ ConfirmationDialog >
730
761
</ Suspense >
731
762
) }
763
+ { showExpirationModal && filesForProcessing . length && (
764
+ < Suspense fallback = { < FallBackDialog /> } >
765
+ < ConfirmationDialog
766
+ open = { showExpirationModal }
767
+ largeFiles = { filesForProcessing }
768
+ extractHandler = { handleGenerateGraph }
769
+ onClose = { ( ) => setshowExpirationModal ( false ) }
770
+ loading = { extractLoading }
771
+ selectedRows = { childRef . current ?. getSelectedRows ( ) as CustomFile [ ] }
772
+ isLargeDocumentAlert = { false }
773
+ > </ ConfirmationDialog >
774
+ </ Suspense >
775
+ ) }
732
776
{ showDeletePopUp && (
733
777
< DeletePopUp
734
778
open = { showDeletePopUp }
0 commit comments