You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

113 line
3.8 KiB

  1. import React from "react";
  2. import { ProjectHours } from "./UserWorkspaceWrapper";
  3. import { Box, Card, CardContent, Chip, Grid, Typography } from "@mui/material";
  4. import { useTranslation } from "react-i18next";
  5. import { manhourFormatter } from "@/app/utils/formatUtil";
  6. interface Props {
  7. projects: ProjectHours[];
  8. }
  9. const ProjectGrid: React.FC<Props> = ({ projects }) => {
  10. const { t } = useTranslation("home");
  11. return (
  12. <Box>
  13. <Grid container columns={{ xs: 4, sm: 8, md: 12, lg: 16 }} spacing={2}>
  14. {projects.map((project, idx) => (
  15. <Grid key={`${project.code}${idx}`} item xs={4}>
  16. <Card>
  17. <CardContent>
  18. <Box
  19. sx={{
  20. display: "flex",
  21. justifyContent: "flex-end",
  22. marginBlockEnd: 1,
  23. }}
  24. >
  25. <Chip
  26. size="small"
  27. label={project.projectStatus}
  28. color={
  29. project.projectStatus === "On Track"
  30. ? "success"
  31. : "warning"
  32. }
  33. />
  34. </Box>
  35. <Typography variant="overline">{project.code}</Typography>
  36. <Typography
  37. variant="h6"
  38. sx={{
  39. overflow: "hidden",
  40. textOverflow: "ellipsis",
  41. whiteSpace: "nowrap",
  42. marginBlockEnd: 3,
  43. }}
  44. >
  45. {project.name}
  46. </Typography>
  47. {/* Hours Spent */}
  48. <Typography variant="subtitle2">{t("Hours Spent:")}</Typography>
  49. <Box
  50. sx={{
  51. display: "flex",
  52. justifyContent: "space-between",
  53. alignItems: "baseline",
  54. }}
  55. >
  56. <Typography variant="caption">{t("Normal")}</Typography>
  57. <Typography>
  58. {manhourFormatter.format(project.hoursSpent)}
  59. </Typography>
  60. </Box>
  61. <Box
  62. sx={{
  63. display: "flex",
  64. justifyContent: "space-between",
  65. alignItems: "baseline",
  66. }}
  67. >
  68. <Typography variant="caption">{t("(Others)")}</Typography>
  69. <Typography>{`(${manhourFormatter.format(
  70. project.hoursSpentOther,
  71. )})`}</Typography>
  72. </Box>
  73. {/* Hours Allocated */}
  74. <Typography variant="subtitle2" sx={{ marginBlockStart: 2 }}>
  75. {t("Hours Allocated:")}
  76. </Typography>
  77. <Box
  78. sx={{
  79. display: "flex",
  80. justifyContent: "space-between",
  81. alignItems: "baseline",
  82. }}
  83. >
  84. <Typography variant="caption">{t("Normal")}</Typography>
  85. <Typography>
  86. {manhourFormatter.format(project.hoursAllocated)}
  87. </Typography>
  88. </Box>
  89. <Box
  90. sx={{
  91. display: "flex",
  92. justifyContent: "space-between",
  93. alignItems: "baseline",
  94. }}
  95. >
  96. <Typography variant="caption">{t("(Others)")}</Typography>
  97. <Typography>{`(${manhourFormatter.format(
  98. project.hoursAllocatedOther,
  99. )})`}</Typography>
  100. </Box>
  101. </CardContent>
  102. </Card>
  103. </Grid>
  104. ))}
  105. </Grid>
  106. </Box>
  107. );
  108. };
  109. export default ProjectGrid;