import React, { useCallback, useState } from "react"; import { Box, Card, CardContent, Grid, ToggleButton, ToggleButtonGroup, ToggleButtonProps, Tooltip, Typography, } from "@mui/material"; import { useTranslation } from "react-i18next"; import { manhourFormatter } from "@/app/utils/formatUtil"; import { AssignedProject } from "@/app/api/projects"; import { TableRows, ViewModule, TableChart } from "@mui/icons-material"; import ProjectTable from "./ProjectTable"; export interface Props { projects: AssignedProject[]; maintainNormalStaffWorkspaceAbility?: boolean; maintainManagementStaffWorkspaceAbility?: boolean; } const ProjectGrid: React.FC = ({ projects, maintainNormalStaffWorkspaceAbility, maintainManagementStaffWorkspaceAbility, }) => { const { t } = useTranslation("home"); const [view, setView] = useState<"grid" | "list" | "table">("grid"); const handleViewChange = useCallback< NonNullable >((e, value) => { if (value) { setView(value); } }, []); return ( {view === "table" ? ( ) : ( {projects.map((project, idx) => ( {project.code} {project.name} {/* Spacer */} {/* Hours Spent */} {(Boolean(maintainNormalStaffWorkspaceAbility) || Boolean(maintainManagementStaffWorkspaceAbility)) && ( <> {t("Hours Spent:")} {t("Normal")} {manhourFormatter.format( Boolean(maintainManagementStaffWorkspaceAbility) ? project.hoursSpent : project.currentStaffHoursSpent, )} {t("Others")} {`${manhourFormatter.format( Boolean(maintainManagementStaffWorkspaceAbility) ? project.hoursSpentOther : project.currentStaffHoursSpentOther, )}`} )} {/* Hours Allocated */} {Boolean(maintainManagementStaffWorkspaceAbility) && ( {t("Hours Allocated:")} {manhourFormatter.format(project.hoursAllocated)} )} ))} )} ); }; export default ProjectGrid;