| @@ -80,6 +80,7 @@ export interface StaffResult { | |||||
| userId: number; | userId: number; | ||||
| companyId: number; | companyId: number; | ||||
| data: data; | data: data; | ||||
| active: boolean; | |||||
| } | } | ||||
| export interface searchInput { | export interface searchInput { | ||||
| staffId: string; | staffId: string; | ||||
| @@ -47,6 +47,7 @@ const staffComparator = (a: StaffResult, b: StaffResult, teamLeads: StaffResult[ | |||||
| return 1; | return 1; | ||||
| } | } | ||||
| return ( | return ( | ||||
| Number(b.active) - Number(a.active) || | |||||
| a.team?.localeCompare(b.team) || | a.team?.localeCompare(b.team) || | ||||
| a.grade?.localeCompare(b.grade) || | a.grade?.localeCompare(b.grade) || | ||||
| a.id - b.id | a.id - b.id | ||||
| @@ -113,6 +114,7 @@ const StaffAllocation: React.FC<Props> = ({ | |||||
| { label: t("Staff ID"), name: "staffId" }, | { label: t("Staff ID"), name: "staffId" }, | ||||
| { label: t("Staff Name"), name: "name" }, | { label: t("Staff Name"), name: "name" }, | ||||
| { label: t("Title"), name: "currentPosition" }, | { label: t("Title"), name: "currentPosition" }, | ||||
| { label: t("Active"), name: "active", type: "checkbox" }, | |||||
| ], | ], | ||||
| [addStaff, t], | [addStaff, t], | ||||
| ); | ); | ||||
| @@ -130,6 +132,7 @@ const StaffAllocation: React.FC<Props> = ({ | |||||
| { label: t("Staff ID"), name: "staffId" }, | { label: t("Staff ID"), name: "staffId" }, | ||||
| { label: t("Staff Name"), name: "name" }, | { label: t("Staff Name"), name: "name" }, | ||||
| { label: t("Title"), name: "currentPosition" }, | { label: t("Title"), name: "currentPosition" }, | ||||
| { label: t("Active"), name: "active", type: "checkbox" }, | |||||
| ], | ], | ||||
| [removeStaff, t], | [removeStaff, t], | ||||
| ); | ); | ||||
| @@ -15,6 +15,8 @@ import IconButton, { IconButtonOwnProps, IconButtonPropsColorOverrides } from "@ | |||||
| import { t } from "i18next"; | import { t } from "i18next"; | ||||
| import { useTranslation } from "react-i18next"; | import { useTranslation } from "react-i18next"; | ||||
| import { convertDateArrayToString, moneyFormatter } from "@/app/utils/formatUtil"; | import { convertDateArrayToString, moneyFormatter } from "@/app/utils/formatUtil"; | ||||
| import DoneIcon from '@mui/icons-material/Done'; | |||||
| import CloseIcon from '@mui/icons-material/Close'; | |||||
| export interface ResultWithId { | export interface ResultWithId { | ||||
| id: string | number; | id: string | number; | ||||
| @@ -120,6 +122,10 @@ function SearchResults<T extends ResultWithId>({ | |||||
| ) : | ) : | ||||
| column?.type === "money" ? ( | column?.type === "money" ? ( | ||||
| <div style={{display: "flex", justifyContent: "flex-end"}}>{moneyFormatter.format(item[columnName] as number)}</div> | <div style={{display: "flex", justifyContent: "flex-end"}}>{moneyFormatter.format(item[columnName] as number)}</div> | ||||
| ) : | |||||
| column?.type === "checkbox" ? ( | |||||
| Boolean(item[columnName]) ? | |||||
| <DoneIcon color="primary" /> : <CloseIcon color="error"/> | |||||
| ) : | ) : | ||||
| ( | ( | ||||
| <>{column?.needTranslation ? t(item[columnName] as string) : item[columnName]}</> | <>{column?.needTranslation ? t(item[columnName] as string) : item[columnName]}</> | ||||
| @@ -68,6 +68,12 @@ const StaffSearch: React.FC<Props> = ({ staff, teams, grades, positions, abiliti | |||||
| type: "select", | type: "select", | ||||
| options: positionCombo, | options: positionCombo, | ||||
| }, | }, | ||||
| { | |||||
| label: t("Active"), | |||||
| paramName: "active", | |||||
| type: "select", | |||||
| options: ["true", "false"], | |||||
| }, | |||||
| ], | ], | ||||
| [t] | [t] | ||||
| ); | ); | ||||
| @@ -121,14 +127,19 @@ const StaffSearch: React.FC<Props> = ({ staff, teams, grades, positions, abiliti | |||||
| { name: "staffId", label: t("Staff ID") }, | { name: "staffId", label: t("Staff ID") }, | ||||
| { name: "grade", label: t("Grade") }, | { name: "grade", label: t("Grade") }, | ||||
| { name: "currentPosition", label: t("Current Position") }, | { name: "currentPosition", label: t("Current Position") }, | ||||
| { | |||||
| name: "action", | |||||
| label: t("Actions"), | |||||
| onClick: deleteClick, | |||||
| buttonIcon: <DeleteIcon />, | |||||
| color: "error", | |||||
| isHidden: !maintainStaff, | |||||
| { | |||||
| name: "active", | |||||
| label: t("Active"), | |||||
| type: "checkbox" | |||||
| }, | }, | ||||
| // { | |||||
| // name: "action", | |||||
| // label: t("Actions"), | |||||
| // onClick: deleteClick, | |||||
| // buttonIcon: <DeleteIcon />, | |||||
| // color: "error", | |||||
| // isHidden: !maintainStaff, | |||||
| // }, | |||||
| ], | ], | ||||
| [t, onStaffClick, deleteClick] | [t, onStaffClick, deleteClick] | ||||
| ); | ); | ||||
| @@ -148,6 +159,7 @@ const StaffSearch: React.FC<Props> = ({ staff, teams, grades, positions, abiliti | |||||
| && (query.team === "All" || s.teamId === teams[teamCombo.findIndex(team => team === query.team)].id) | && (query.team === "All" || s.teamId === teams[teamCombo.findIndex(team => team === query.team)].id) | ||||
| && (query.grade === "All" || s.grade === query.grade) | && (query.grade === "All" || s.grade === query.grade) | ||||
| && (query.currentPosition === "All" || s.currentPosition === query.currentPosition) | && (query.currentPosition === "All" || s.currentPosition === query.currentPosition) | ||||
| && (query.active === "All" || s.active.toString() === query.active) | |||||
| ) | ) | ||||
| ); | ); | ||||
| }} | }} | ||||