Skip to content

Commit 2cddb0d

Browse files
authored
Filter in insights->staff list fix (#2320)
* Extension date logic, push confirmation dialog not needed * more extension related fixes * actualdate max range change on extension fixed * total days of ended works in myworkplan * duplication in insight staff filter * insights -> worklisting -> filter fix
1 parent 58b13db commit 2cddb0d

File tree

1 file changed

+15
-15
lines changed
  • epictrack-web/src/components/insights/Work/Tabs/Staff/Charts

1 file changed

+15
-15
lines changed

epictrack-web/src/components/insights/Work/Tabs/Staff/Charts/workListing.tsx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,29 +54,28 @@ const WorkList = () => {
5454
}, [workStaffs, works]);
5555

5656
const workLeads = useMemo(() => {
57-
return (
58-
workStaffs
59-
?.map((workStaff) => workStaff.work_lead.full_name)
60-
.filter((lead) => lead)
61-
.sort() || []
57+
return Array.from(
58+
new Set(
59+
workStaffs?.map((workStaff) => workStaff.work_lead.full_name).sort() ||
60+
[]
61+
)
6262
);
6363
}, [workStaffs]);
6464

6565
const teams = useMemo(() => {
66-
return (
67-
workStaffs
68-
?.map((workStaff) => workStaff.eao_team.name)
69-
.filter((team) => team)
70-
.sort() || []
66+
return Array.from(
67+
new Set(
68+
workStaffs?.map((workStaff) => workStaff.eao_team.name).sort() || []
69+
)
7170
);
7271
}, [workStaffs]);
7372

7473
const filteredStaffByPosition = useCallback(
75-
(position: WorkStaffRole) => {
74+
(roleId: number) => {
7675
if (!workStaffs) return [];
7776
const staff = workStaffs.flatMap((row: any) =>
7877
row.staff
79-
? row.staff.filter((p: { role: Role }) => p.role.id === position)
78+
? row.staff.filter((p: { role: Role }) => p.role.id === roleId)
8079
: []
8180
);
8281
const staffSorted = sort(staff, "full_name");
@@ -118,12 +117,13 @@ const WorkList = () => {
118117
return names.some((name) => filterValue.includes(name));
119118
};
120119

121-
const getRolfilterOptions = (role: WorkStaffRole) => {
120+
const getRolefilterOptions = (role: WorkStaffRole) => {
122121
return role === WorkStaffRole.OFFICER_ANALYST
123122
? officerAnalystOptions
124123
: coLeadOptions;
125124
};
126-
125+
console.log("OFFICER ANALYST ", officerAnalystOptions);
126+
console.log("CO-LEAD ", coLeadOptions);
127127
const tableColumns = React.useMemo(() => {
128128
const cols: Array<MRT_ColumnDef<WorkStaffWithWork>> = [];
129129
if (workStaffs && workStaffs.length > 0) {
@@ -133,7 +133,7 @@ const WorkList = () => {
133133
cols.push({
134134
header: roleName,
135135
id: `${WorkStaffRoleNames[role]}`,
136-
filterSelectOptions: getRolfilterOptions(role),
136+
filterSelectOptions: getRolefilterOptions(role),
137137
accessorFn: (row: any) => {
138138
if (!row.staff) {
139139
return "";

0 commit comments

Comments
 (0)