fix Time column in History of Action tab

This commit is contained in:
Yinyin Liu 2025-02-19 10:52:34 +01:00
parent ac54fc6e2e
commit 57b5eb7e95
1 changed files with 16 additions and 7 deletions

View File

@ -25,10 +25,15 @@ import Button from '@mui/material/Button';
import { DateTimePicker, LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
import EditIcon from '@mui/icons-material/Edit';
import DeleteIcon from '@mui/icons-material/Delete';
import { UserContext } from '../../../contexts/userContext';
dayjs.extend(utc);
dayjs.extend(timezone);
interface HistoryProps {
errorLoadingS3Data: boolean;
id: number;
@ -411,14 +416,18 @@ function HistoryOfActions(props: HistoryProps) {
<Divider />
<div style={{ maxHeight: '600px', overflowY: 'auto' }}>
{history.map((action, index) => {
// Parse the timestamp string to a Date object
const date = new Date(action.timestamp);
// // Parse the timestamp string to a Date object
// const date = new Date(action.timestamp);
//
// // Extract the date part (e.g., "2023-05-31")
// const datePart = date.toLocaleDateString();
//
// // Extract the time part (e.g., "12:34:56")
// const timePart = date.toLocaleTimeString();
const dateCET = dayjs.utc(action.timestamp).tz("Europe/Paris");
const datePart = dateCET.format("YYYY-MM-DD");
const timePart = dateCET.format("HH:mm:ss");
// Extract the date part (e.g., "2023-05-31")
const datePart = date.toLocaleDateString();
// Extract the time part (e.g., "12:34:56")
const timePart = date.toLocaleTimeString();
const iconStyle =
action.userName === currentUser.name
? {}