Update ModalHistory.tsx

This commit is contained in:
nguyentrungthat 2025-11-28 15:57:12 +07:00
parent 2ba35743fd
commit 78f9ca1aa1
1 changed files with 53 additions and 38 deletions

View File

@ -91,6 +91,13 @@ function ModalHistory({
} }
}, [opened]); }, [opened]);
// Change station or filter will reset scroll
useEffect(() => {
if (scrollViewportRef?.current) {
scrollViewportRef.current.scrollTop = 0;
}
}, [activeStation, activeTimePeriod]);
// Utility function to format timestamp (can be used later if needed) // Utility function to format timestamp (can be used later if needed)
// const formatTimestamp = (timestamp: number) => { // const formatTimestamp = (timestamp: number) => {
// const date = new Date(timestamp); // const date = new Date(timestamp);
@ -373,7 +380,13 @@ function ModalHistory({
</Box> </Box>
{/* Các items trong nhóm */} {/* Các items trong nhóm */}
{items.map((item, itemIndex) => ( {items
?.filter((el, i) =>
activeTimePeriod === "current"
? i === 0
: true
)
.map((item, itemIndex) => (
<Box <Box
key={`${item.stationId}-${item.number}-${item.timestamp}-${itemIndex}`} key={`${item.stationId}-${item.number}-${item.timestamp}-${itemIndex}`}
style={{ style={{
@ -383,7 +396,9 @@ function ModalHistory({
? "1px solid #f1f3f5" ? "1px solid #f1f3f5"
: "none", : "none",
backgroundColor: backgroundColor:
itemIndex % 2 === 0 ? "white" : "#f8f9fa", itemIndex % 2 === 0
? "white"
: "#f8f9fa",
}} }}
> >
<Text <Text