@@ -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 ) ;
@@ -660,7 +663,8 @@ const Content: React.FC<ContentProps> = ({
660
663
const onClickHandler = ( ) => {
661
664
const selectedRows = childRef . current ?. getSelectedRows ( ) ;
662
665
if ( selectedRows ?. length ) {
663
- let selectedLargeFiles : CustomFile [ ] = [ ] ;
666
+ const selectedLargeFiles : CustomFile [ ] = [ ] ;
667
+ const expiredFiles : CustomFile [ ] = [ ] ;
664
668
for ( let index = 0 ; index < selectedRows . length ; index ++ ) {
665
669
const parsedData : CustomFile = selectedRows [ index ] ;
666
670
if (
@@ -671,9 +675,18 @@ const Content: React.FC<ContentProps> = ({
671
675
) {
672
676
selectedLargeFiles . push ( parsedData ) ;
673
677
}
678
+ if (
679
+ parsedData . fileSource === 'local file' &&
680
+ ( parsedData . status === 'New' || parsedData . status == 'Ready to Reprocess' ) &&
681
+ isExpired ( parsedData ?. createdAt as Date )
682
+ ) {
683
+ expiredFiles . push ( parsedData ) ;
684
+ }
674
685
}
675
686
if ( selectedLargeFiles . length ) {
676
687
setshowConfirmationModal ( true ) ;
688
+ } else if ( expiredFiles . length && isGCSActive ) {
689
+ setshowExpirationModal ( true ) ;
677
690
} else {
678
691
handleGenerateGraph ( selectedRows . filter ( ( f ) => f . status === 'New' || f . status === 'Ready to Reprocess' ) ) ;
679
692
}
@@ -688,16 +701,34 @@ const Content: React.FC<ContentProps> = ({
688
701
}
689
702
return false ;
690
703
} ) ;
704
+ const expiredFiles = filesData . filter ( ( f ) => {
705
+ console . log (
706
+ f . fileSource === 'local file'
707
+ ? { isExpired : isExpired ( f ?. createdAt as Date ) , name : f . name , createdAt : f . createdAt }
708
+ : 'Not Local File'
709
+ ) ;
710
+ if (
711
+ f . fileSource === 'local file' &&
712
+ ( f . status === 'New' || f . status == 'Ready to Reprocess' ) &&
713
+ isExpired ( f ?. createdAt as Date )
714
+ ) {
715
+ return true ;
716
+ }
717
+ return false ;
718
+ } ) ;
691
719
const selectAllNewFiles = filesData . filter ( ( f ) => f . status === 'New' || f . status === 'Ready to Reprocess' ) ;
692
720
const stringified = selectAllNewFiles . reduce ( ( accu , f ) => {
693
721
const key = f . id ;
694
722
// @ts -ignore
695
723
accu [ key ] = true ;
696
724
return accu ;
697
725
} , { } ) ;
726
+ console . log ( expiredFiles ) ;
698
727
setRowSelection ( stringified ) ;
699
728
if ( largefiles . length ) {
700
729
setshowConfirmationModal ( true ) ;
730
+ } else if ( expiredFiles . length && isGCSActive ) {
731
+ setshowExpirationModal ( true ) ;
701
732
} else {
702
733
handleGenerateGraph ( filesData . filter ( ( f ) => f . status === 'New' || f . status === 'Ready to Reprocess' ) ) ;
703
734
}
@@ -746,6 +777,19 @@ const Content: React.FC<ContentProps> = ({
746
777
> </ ConfirmationDialog >
747
778
</ Suspense >
748
779
) }
780
+ { showExpirationModal && filesForProcessing . length && (
781
+ < Suspense fallback = { < FallBackDialog /> } >
782
+ < ConfirmationDialog
783
+ open = { showExpirationModal }
784
+ largeFiles = { filesForProcessing }
785
+ extractHandler = { handleGenerateGraph }
786
+ onClose = { ( ) => setshowExpirationModal ( false ) }
787
+ loading = { extractLoading }
788
+ selectedRows = { childRef . current ?. getSelectedRows ( ) as CustomFile [ ] }
789
+ isLargeDocumentAlert = { false }
790
+ > </ ConfirmationDialog >
791
+ </ Suspense >
792
+ ) }
749
793
{ showDeletePopUp && (
750
794
< DeletePopUp
751
795
open = { showDeletePopUp }
0 commit comments