From 4b89d24bef47b85f54de7a0d1384de1006964cc3 Mon Sep 17 00:00:00 2001 From: Alex <140799985+todti@users.noreply.github.com> Date: Fri, 17 Jan 2025 13:26:51 +0100 Subject: [PATCH] fix: fix footer created report time (#68) --- .../src/components/Footer/FooterVersion.tsx | 16 +++++++++++----- .../src/components/ReportHeader/index.tsx | 2 +- packages/web-commons/src/data.ts | 4 ++-- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/packages/web-awesome/src/components/Footer/FooterVersion.tsx b/packages/web-awesome/src/components/Footer/FooterVersion.tsx index cedd0f33..52fea242 100644 --- a/packages/web-awesome/src/components/Footer/FooterVersion.tsx +++ b/packages/web-awesome/src/components/Footer/FooterVersion.tsx @@ -1,15 +1,21 @@ import { getReportOptions } from "@allurereport/web-commons"; import { Text } from "@allurereport/web-components"; +import { useEffect, useState } from "preact/hooks"; import type { AllureAwesomeReportOptions } from "types"; -import { currentLocale } from "@/stores"; +import { currentLocaleIso } from "@/stores"; import * as styles from "./styles.scss"; export const FooterVersion = () => { - const currentLang = currentLocale.value; - const { createdAt } = getReportOptions() ?? {}; - const locale = currentLang === "en" ? "en-US" : "ru-RU"; + const [createdAt, setCreatedAt] = useState(null); - const formattedCreatedAt = new Date(createdAt as number).toLocaleDateString(locale, { + useEffect(() => { + const reportOptions = getReportOptions(); + if (reportOptions?.createdAt) { + setCreatedAt(Number(reportOptions.createdAt)); + } + }, []); + + const formattedCreatedAt = new Date(createdAt as number).toLocaleDateString(currentLocaleIso.value as string, { month: "numeric", day: "numeric", year: "numeric", diff --git a/packages/web-awesome/src/components/ReportHeader/index.tsx b/packages/web-awesome/src/components/ReportHeader/index.tsx index fb8103e5..5a5333f4 100644 --- a/packages/web-awesome/src/components/ReportHeader/index.tsx +++ b/packages/web-awesome/src/components/ReportHeader/index.tsx @@ -8,7 +8,7 @@ import * as styles from "./styles.scss"; export const ReportHeader = () => { const { reportName, createdAt } = getReportOptions() ?? {}; - const formattedCreatedAt = new Date(createdAt).toLocaleDateString(currentLocaleIso.value as string, { + const formattedCreatedAt = new Date(createdAt as number).toLocaleDateString(currentLocaleIso.value as string, { month: "long", day: "numeric", year: "numeric", diff --git a/packages/web-commons/src/data.ts b/packages/web-commons/src/data.ts index 95c8fecb..ba78f24c 100644 --- a/packages/web-commons/src/data.ts +++ b/packages/web-commons/src/data.ts @@ -23,11 +23,11 @@ export const createReportDataScript = (