Skip to content

Commit

Permalink
fix: fix footer created report time (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
todti authored Jan 17, 2025
1 parent a048f77 commit 4b89d24
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
16 changes: 11 additions & 5 deletions packages/web-awesome/src/components/Footer/FooterVersion.tsx
Original file line number Diff line number Diff line change
@@ -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<AllureAwesomeReportOptions>() ?? {};
const locale = currentLang === "en" ? "en-US" : "ru-RU";
const [createdAt, setCreatedAt] = useState<number | null>(null);

const formattedCreatedAt = new Date(createdAt as number).toLocaleDateString(locale, {
useEffect(() => {
const reportOptions = getReportOptions<AllureAwesomeReportOptions>();
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",
Expand Down
2 changes: 1 addition & 1 deletion packages/web-awesome/src/components/ReportHeader/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as styles from "./styles.scss";

export const ReportHeader = () => {
const { reportName, createdAt } = getReportOptions<AllureAwesomeReportOptions>() ?? {};
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",
Expand Down
4 changes: 2 additions & 2 deletions packages/web-commons/src/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ export const createReportDataScript = (
<script async>
window.allureReportDataReady = false;
window.allureReportData = window.allureReportData || {};
function d(name, value){
return new Promise(function (resolve) {
window.allureReportData[name] = value;
return resolve(true);
});
}
Expand Down

0 comments on commit 4b89d24

Please sign in to comment.