From bb472749b5be165f25eab0006f3b1a41fe0e7004 Mon Sep 17 00:00:00 2001 From: "cyril.tsui" Date: Fri, 6 Dec 2024 17:55:16 +0800 Subject: [PATCH] update staff (allocation) list --- src/app/api/staff/index.ts | 1 + .../CreateProject/StaffAllocation.tsx | 3 +++ .../SearchResults/SearchResults.tsx | 6 +++++ src/components/StaffSearch/StaffSearch.tsx | 26 ++++++++++++++----- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/src/app/api/staff/index.ts b/src/app/api/staff/index.ts index 20fe03c..1d42d6a 100644 --- a/src/app/api/staff/index.ts +++ b/src/app/api/staff/index.ts @@ -80,6 +80,7 @@ export interface StaffResult { userId: number; companyId: number; data: data; + active: boolean; } export interface searchInput { staffId: string; diff --git a/src/components/CreateProject/StaffAllocation.tsx b/src/components/CreateProject/StaffAllocation.tsx index 864f000..6bec2a0 100644 --- a/src/components/CreateProject/StaffAllocation.tsx +++ b/src/components/CreateProject/StaffAllocation.tsx @@ -47,6 +47,7 @@ const staffComparator = (a: StaffResult, b: StaffResult, teamLeads: StaffResult[ return 1; } return ( + Number(b.active) - Number(a.active) || a.team?.localeCompare(b.team) || a.grade?.localeCompare(b.grade) || a.id - b.id @@ -113,6 +114,7 @@ const StaffAllocation: React.FC = ({ { label: t("Staff ID"), name: "staffId" }, { label: t("Staff Name"), name: "name" }, { label: t("Title"), name: "currentPosition" }, + { label: t("Active"), name: "active", type: "checkbox" }, ], [addStaff, t], ); @@ -130,6 +132,7 @@ const StaffAllocation: React.FC = ({ { label: t("Staff ID"), name: "staffId" }, { label: t("Staff Name"), name: "name" }, { label: t("Title"), name: "currentPosition" }, + { label: t("Active"), name: "active", type: "checkbox" }, ], [removeStaff, t], ); diff --git a/src/components/SearchResults/SearchResults.tsx b/src/components/SearchResults/SearchResults.tsx index 1a57060..05bdf1c 100644 --- a/src/components/SearchResults/SearchResults.tsx +++ b/src/components/SearchResults/SearchResults.tsx @@ -15,6 +15,8 @@ import IconButton, { IconButtonOwnProps, IconButtonPropsColorOverrides } from "@ import { t } from "i18next"; import { useTranslation } from "react-i18next"; import { convertDateArrayToString, moneyFormatter } from "@/app/utils/formatUtil"; +import DoneIcon from '@mui/icons-material/Done'; +import CloseIcon from '@mui/icons-material/Close'; export interface ResultWithId { id: string | number; @@ -120,6 +122,10 @@ function SearchResults({ ) : column?.type === "money" ? (
{moneyFormatter.format(item[columnName] as number)}
+ ) : + column?.type === "checkbox" ? ( + Boolean(item[columnName]) ? + : ) : ( <>{column?.needTranslation ? t(item[columnName] as string) : item[columnName]} diff --git a/src/components/StaffSearch/StaffSearch.tsx b/src/components/StaffSearch/StaffSearch.tsx index b38b005..a13f9d1 100644 --- a/src/components/StaffSearch/StaffSearch.tsx +++ b/src/components/StaffSearch/StaffSearch.tsx @@ -68,6 +68,12 @@ const StaffSearch: React.FC = ({ staff, teams, grades, positions, abiliti type: "select", options: positionCombo, }, + { + label: t("Active"), + paramName: "active", + type: "select", + options: ["true", "false"], + }, ], [t] ); @@ -121,14 +127,19 @@ const StaffSearch: React.FC = ({ staff, teams, grades, positions, abiliti { name: "staffId", label: t("Staff ID") }, { name: "grade", label: t("Grade") }, { name: "currentPosition", label: t("Current Position") }, - { - name: "action", - label: t("Actions"), - onClick: deleteClick, - buttonIcon: , - color: "error", - isHidden: !maintainStaff, + { + name: "active", + label: t("Active"), + type: "checkbox" }, + // { + // name: "action", + // label: t("Actions"), + // onClick: deleteClick, + // buttonIcon: , + // color: "error", + // isHidden: !maintainStaff, + // }, ], [t, onStaffClick, deleteClick] ); @@ -148,6 +159,7 @@ const StaffSearch: React.FC = ({ staff, teams, grades, positions, abiliti && (query.team === "All" || s.teamId === teams[teamCombo.findIndex(team => team === query.team)].id) && (query.grade === "All" || s.grade === query.grade) && (query.currentPosition === "All" || s.currentPosition === query.currentPosition) + && (query.active === "All" || s.active.toString() === query.active) ) ); }}