Procházet zdrojové kódy

Merge branch 'main' of https://git.2fi-solutions.com/wayne.lee/tsms

tags/Baseline_30082024_FRONTEND_UAT
MSI\2Fi před 1 rokem
rodič
revize
47f7e38125
2 změnil soubory, kde provedl 69 přidání a 26 odebrání
  1. +37
    -26
      src/components/Breadcrumb/Breadcrumb.tsx
  2. +32
    -0
      src/components/Breadcrumb/Clock.tsx

+ 37
- 26
src/components/Breadcrumb/Breadcrumb.tsx Zobrazit soubor

@@ -6,6 +6,9 @@ import Link from "next/link";
import MUILink from "@mui/material/Link";
import { usePathname } from "next/navigation";
import { useTranslation } from "react-i18next";
import Clock from "./Clock";
import { Grid } from "@mui/material";
import { I18nProvider } from "@/i18n";

const pathToLabelMap: { [path: string]: string } = {
"": "Overview",
@@ -43,34 +46,42 @@ const Breadcrumb = () => {

// const { t } = useTranslation("customer");


return (
<Breadcrumbs>
{segments.map((segment, index) => {
const href = segments.slice(0, index + 1).join("/");
const label = pathToLabelMap[href] || segment;
<Grid container>
<Grid item xs={6}>
<Breadcrumbs>
{segments.map((segment, index) => {
const href = segments.slice(0, index + 1).join("/");
const label = pathToLabelMap[href] || segment;

if (index === segments.length - 1) {
return (
<Typography key={index} color="text.primary">
{label}
{/* {t(label)} */}
</Typography>
);
} else {
return (
<MUILink
underline="hover"
color="inherit"
key={index}
component={Link}
href={href || "/"}
>
{label}
</MUILink>
);
}
})}
</Breadcrumbs>
if (index === segments.length - 1) {
return (
<Typography key={index} color="text.primary">
{label}
{/* {t(label)} */}
</Typography>
);
} else {
return (
<MUILink
underline="hover"
color="inherit"
key={index}
component={Link}
href={href || "/"}
>
{label}
</MUILink>
);
}
})}
</Breadcrumbs>
</Grid>
<Grid item xs={6} sx={{ display: 'flex', justifyContent: 'flex-end' }}>
<Clock />
</Grid>
</Grid>
);
};



+ 32
- 0
src/components/Breadcrumb/Clock.tsx Zobrazit soubor

@@ -0,0 +1,32 @@
"use client"
import { useState, useEffect, useLayoutEffect } from 'react';
import Typography from "@mui/material/Typography";
import { useTranslation } from 'react-i18next';

const Clock = () => {
const {
i18n: { language },
} = useTranslation();
const [currentDateTime, setCurrentDateTime] = useState(new Date());

useLayoutEffect(() => {
const timer = setInterval(() => {
setCurrentDateTime(new Date());
}, 1000);

return () => {
clearInterval(timer);
};
}, []);

const options: Intl.DateTimeFormatOptions = { year: 'numeric', month: 'long', day: 'numeric', weekday: 'long', hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: true };
const formattedDateTime = new Intl.DateTimeFormat(language, options).format(currentDateTime)

return (
<Typography color="text.primary" suppressHydrationWarning>
{formattedDateTime}
</Typography>
);
};

export default Clock;

Načítá se…
Zrušit
Uložit