next-enterprise/package/components/organisms/Header.tsx

82 lines
2.4 KiB
TypeScript
Raw Normal View History

import MoreVertIcon from "@mui/icons-material/MoreVert";
import PersonIcon from "@mui/icons-material/Person";
import { Card, CardContent, IconButton, Typography } from "@mui/material";
import Grid from "@mui/material/Grid2";
import React, { useEffect, useState } from "react";
import { useTranslation } from "react-i18next";
2024-09-19 19:22:43 -05:00
interface HeaderProps {
sx?: object;
onToggleButtonPanel: () => void;
2024-09-19 19:22:43 -05:00
}
const Header: React.FC<HeaderProps> = ({ sx, onToggleButtonPanel }) => {
const { t } = useTranslation();
const [currentDateTime, setCurrentDateTime] = useState(new Date());
useEffect(() => {
const interval = setInterval(() => {
setCurrentDateTime(new Date());
}, 60000);
return () => clearInterval(interval);
}, []);
const formattedDate = currentDateTime.toLocaleDateString(undefined, {
weekday: "short",
day: "numeric",
month: "short",
});
const formattedTime = currentDateTime.toLocaleTimeString(undefined, {
hour: "2-digit",
minute: "2-digit",
});
2024-09-19 19:22:43 -05:00
return (
<Card sx={{ ...sx, p: 0 }}>
<CardContent sx={{ padding: "1px 8px" }}>
2024-09-19 19:22:43 -05:00
<Grid container alignItems="center" justifyContent="space-between">
<Grid>
<Typography variant="body2" color="text.primary" sx={{ fontWeight: "bold" }}>
Generic user
2024-09-19 19:22:43 -05:00
</Typography>
<Typography variant="body2" color="text.secondary">
Add Member
2024-09-19 19:22:43 -05:00
</Typography>
</Grid>
2024-09-19 19:22:43 -05:00
<Grid>
<Typography variant="body2" color="text.secondary">
{formattedDate} - {formattedTime}
2024-09-19 19:22:43 -05:00
</Typography>
</Grid>
2024-09-19 19:22:43 -05:00
<Grid>
<Typography variant="body2" color="text.secondary">
{t("lbl_Store")}: <strong>8004</strong> | {t("lbl_register")}: <strong>317</strong>
2024-09-19 19:22:43 -05:00
</Typography>
</Grid>
<Grid>
<Grid container alignItems="center">
<PersonIcon sx={{ color: "text.secondary", fontSize: "18px", mr: 0.5 }} />
<Typography variant="body2" color="text.secondary">
{t("lbl_associate")} <strong>2</strong>
</Typography>
</Grid>
2024-09-19 19:22:43 -05:00
</Grid>
2024-09-19 19:22:43 -05:00
<Grid>
<IconButton size="small" onClick={onToggleButtonPanel}>
2024-09-19 19:22:43 -05:00
<MoreVertIcon color="action" sx={{ fontSize: "18px" }} />
</IconButton>
</Grid>
</Grid>
</CardContent>
</Card>
);
};
2024-09-19 19:22:43 -05:00
export default Header;