diff --git a/epictrack-web/src/components/myWorkplans/Card/CardFooter.tsx b/epictrack-web/src/components/myWorkplans/Card/CardFooter.tsx index aef56606e..16385c42a 100644 --- a/epictrack-web/src/components/myWorkplans/Card/CardFooter.tsx +++ b/epictrack-web/src/components/myWorkplans/Card/CardFooter.tsx @@ -1,15 +1,30 @@ -import { Avatar, AvatarGroup, Button, Grid } from "@mui/material"; +import { + Avatar, + AvatarGroup, + Box, + Button, + Grid, + ListItem, + avatarGroupClasses, +} from "@mui/material"; import { Palette } from "../../../styles/theme"; import { ETCaption1, ETCaption2, ETParagraph } from "../../shared"; import Icons from "../../icons"; import { IconProps } from "../../icons/type"; import { CardProps } from "./type"; import { useNavigate } from "react-router-dom"; +import React from "react"; +import UserMenu from "../../shared/userMenu/UserMenu"; +import RenderSurplus from "./RenderSurplus"; +import { Staff } from "../../../models/staff"; const EyeIcon: React.FC = Icons["EyeIcon"]; const CardFooter = ({ workplan }: CardProps) => { const navigate = useNavigate(); + const [staffHover, setStaffHover] = React.useState(null); + const [userMenuAnchorEl, setUserMenuAnchorEl] = + React.useState(null); const team_lead = workplan.staff_info.find((staff: any) => { if (staff.role.name === "Team Lead") { return staff.staff.full_name; @@ -17,6 +32,19 @@ const CardFooter = ({ workplan }: CardProps) => { return false; }); + const handleCloseUserMenu = (event: React.MouseEvent) => { + setUserMenuAnchorEl(null); + setStaffHover(null); + }; + + const handleOpenUserMenu = ( + event: React.MouseEvent, + staff: any + ) => { + setStaffHover(staff); + setUserMenuAnchorEl(event.currentTarget); + }; + return ( { borderTop: `1px solid var(--neutral-background-dark, #DBDCDC)`, padding: "16px 32px", alignItems: "center", - height: "80px", + // height: "80px", }} > @@ -68,23 +96,61 @@ const CardFooter = ({ workplan }: CardProps) => { STAFF - + ( + + )} + sx={{ + [`& .${avatarGroupClasses.avatar}`]: { + width: "24px", + height: "24px", + }, + }} + > {workplan.staff_info.map((staff: any) => { return ( - - {`${staff.staff.first_name[0]}${staff.staff.last_name[0]}`} - + <> + { + event.stopPropagation(); + event.preventDefault(); + handleOpenUserMenu(event, staff.staff); + }} + // onMouseLeave={handleCloseUserMenu} + > + {`${staff.staff.first_name[0]}${staff.staff.last_name[0]}`} + + + ); })} diff --git a/epictrack-web/src/components/myWorkplans/Card/RenderSurplus.tsx b/epictrack-web/src/components/myWorkplans/Card/RenderSurplus.tsx new file mode 100644 index 000000000..5ef7d1915 --- /dev/null +++ b/epictrack-web/src/components/myWorkplans/Card/RenderSurplus.tsx @@ -0,0 +1,99 @@ +import { + Avatar, + Grid, + Menu, + MenuItem, + PopoverOrigin, + Typography, +} from "@mui/material"; +import { Staff } from "../../../models/staff"; +import React from "react"; +import { ETCaption2 } from "../../shared"; +import { Palette } from "../../../styles/theme"; + +interface RenderSurplusProps { + renderSurplus: number; + staff: any[]; +} + +const RenderSurplus = ({ renderSurplus, staff }: RenderSurplusProps) => { + const [userListAnchor, setUserListAnchor] = + React.useState(null); + + const remainingStaff = staff.slice(renderSurplus - 1); + + const handleOpenUserMenu = (event: React.MouseEvent) => { + setUserListAnchor(event.currentTarget); + }; + + const handleCloseUserMenu = () => { + setUserListAnchor(null); + }; + + return ( + <> + { + event.stopPropagation(); + event.preventDefault(); + handleOpenUserMenu(event); + }} + > + ... + + + {remainingStaff.map((staffObject: any) => { + return ( + + + {`${staffObject?.staff?.first_name[0]}${staffObject?.staff?.last_name[0]}`} + + + + {staffObject?.staff?.full_name} + + + {staffObject?.staff?.position?.name} + + + + ); + })} + + + ); +}; + +export default RenderSurplus; diff --git a/epictrack-web/src/components/shared/userMenu/UserMenu.tsx b/epictrack-web/src/components/shared/userMenu/UserMenu.tsx index e76f7034e..99aff3d6e 100644 --- a/epictrack-web/src/components/shared/userMenu/UserMenu.tsx +++ b/epictrack-web/src/components/shared/userMenu/UserMenu.tsx @@ -38,6 +38,7 @@ const UserMenu = (props: UserMenuProps) => { phone, origin, id, + onMouseLeave, } = props; const menuOrigin = React.useMemo(() => { if (origin === undefined) @@ -60,6 +61,7 @@ const UserMenu = (props: UserMenuProps) => { transformOrigin={menuOrigin} open={Boolean(anchorEl)} onClose={onClose} + onMouseLeave={onMouseLeave} PaperProps={{ style: { pointerEvents: "none", diff --git a/epictrack-web/src/components/shared/userMenu/type.ts b/epictrack-web/src/components/shared/userMenu/type.ts index f15a17b52..ee09b08e3 100644 --- a/epictrack-web/src/components/shared/userMenu/type.ts +++ b/epictrack-web/src/components/shared/userMenu/type.ts @@ -12,4 +12,5 @@ export interface UserMenuProps { origin?: PopoverOrigin; sx?: SxProps; id?: string; + onMouseLeave?: (event: React.MouseEvent) => any; }