import { TraceWithLogsDto } from "@montelo/browser-client";
import { dayjs } from "~/utils/dayjs";

export const formatTraceDates = (traces: TraceWithLogsDto[], timezone: string | undefined): TraceWithLogsDto[] => {
  return traces.map((trace) => {
    const updatedLogs = trace.logs.map((log) => {
      return {
        ...log,
        createdAt: dayjs(log.createdAt).tz(timezone).format("h:mm:ssa - D/M/YY"),
        startTime: dayjs(log.startTime).tz(timezone).format("h:mm:ssa - D/M/YY"),
      };
    });
    return {
      ...trace,
      logs: updatedLogs,
      startTime: dayjs(trace.startTime).tz(timezone).format("h:mm:ssa - D/M/YY"),
    };
  });
};
