11import React , { useState , useEffect , useRef } from "react" ;
22
3- import { useDispatch , useSelector } from 'react-redux' ;
3+ import { useDispatch } from 'react-redux' ;
44import { Card , Spinner , Tooltip } from "@fluentui/react-components" ;
55import { useNavigate } from "react-router-dom" ;
66import ConfirmationDialog from "../commonComponents/ConfirmationDialog/confirmationDialogue" ;
@@ -21,7 +21,7 @@ interface BatchHistoryItem {
2121 status : string ;
2222}
2323const HistoryPanel : React . FC < HistoryPanelProps > = ( { isOpen, onClose } ) => {
24- const headers = { }
24+ const headers = { } ;
2525 const [ batchHistory , setBatchHistory ] = useState < BatchHistoryItem [ ] > ( [ ] ) ;
2626 const [ loading , setLoading ] = useState ( false ) ;
2727 const [ error , setError ] = useState < string | null > ( null ) ;
@@ -81,46 +81,6 @@ const HistoryPanel: React.FC<HistoryPanelProps> = ({ isOpen, onClose }) => {
8181 }
8282 } ;
8383
84- // Function to categorize batches
85- const categorizeBatches = ( ) => {
86- const now = new Date ( ) ;
87- const userTimeZone = Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone ;
88-
89- // Get start of "Today", "Past 7 days", and "Past 30 days" in LOCAL time
90- const todayStart = new Date ( now . getFullYear ( ) , now . getMonth ( ) , now . getDate ( ) ) ;
91- const past7DaysStart = new Date ( todayStart ) ;
92- const past30DaysStart = new Date ( todayStart ) ;
93-
94- past7DaysStart . setDate ( todayStart . getDate ( ) - 7 ) ;
95- past30DaysStart . setDate ( todayStart . getDate ( ) - 30 ) ;
96-
97- const todayBatches : BatchHistoryItem [ ] = [ ] ;
98- const past7DaysBatches : BatchHistoryItem [ ] = [ ] ;
99- const past30DaysBatches : BatchHistoryItem [ ] = [ ] ;
100-
101- batchHistory . forEach ( batch => {
102- // Convert UTC timestamp to user's local date
103- const updatedAtUTC = new Date ( batch . created_at ) ;
104- const updatedAtLocal = new Date ( updatedAtUTC . toLocaleString ( "en-US" , { timeZone : userTimeZone } ) ) ;
105-
106- // Extract only the local **date** part for comparison
107- const updatedDate = new Date ( updatedAtLocal . getFullYear ( ) , updatedAtLocal . getMonth ( ) , updatedAtLocal . getDate ( ) ) ;
108-
109- // Categorize based on **exact day comparison**
110- if ( updatedDate . getTime ( ) === todayStart . getTime ( ) ) {
111- todayBatches . push ( batch ) ;
112- } else if ( updatedDate . getTime ( ) >= past7DaysStart . getTime ( ) ) {
113- past7DaysBatches . push ( batch ) ;
114- } else if ( updatedDate . getTime ( ) >= past30DaysStart . getTime ( ) ) {
115- past30DaysBatches . push ( batch ) ;
116- }
117- } ) ;
118-
119- return { todayBatches, past7DaysBatches, past30DaysBatches } ;
120- } ;
121-
122- // const { todayBatches, past7DaysBatches, past30DaysBatches } = categorizeBatches();
123-
12484 const deleteBatchFromHistory = ( batchId : string ) => {
12585 // Get the current URL path
12686 const currentPath = window . location . pathname ;
0 commit comments