Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create add proponent field #1664

Merged
merged 3 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions epictrack-web/src/components/project/ProjectList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ import { useAppSelector } from "../../hooks";
const ProjectList = () => {
const [envRegions, setEnvRegions] = React.useState<string[]>([]);
const [subTypes, setSubTypes] = React.useState<string[]>([]);
const [proponents, setProponents] = React.useState<string[]>([]);
const [types, setTypes] = React.useState<string[]>([]);
const [projectId, setProjectId] = React.useState<number>();
const ctx = React.useContext(MasterContext);

const { roles } = useAppSelector((state) => state.user.userDetail);
const canEdit = hasPermission({ roles, allowed: [ROLES.EDIT] });

Expand Down Expand Up @@ -60,6 +60,10 @@ const ProjectList = () => {
const envRegions = projects
.map((p) => p.region_env?.name)
.filter((ele, index, arr) => arr.findIndex((t) => t === ele) === index);
const projectProponents = projects
.map((p) => p.proponent.name)
.filter((ele, index, arr) => arr.findIndex((t) => t === ele) === index);
setProponents(projectProponents);
setTypes(types);
setSubTypes(subTypes);
setEnvRegions(envRegions);
Expand Down Expand Up @@ -159,6 +163,35 @@ const ProjectList = () => {
return filterValue.includes(value);
},
},
{
accessorKey: "proponent.name",
header: "Proponents",
filterSelectOptions: proponents,
filterVariant: "multi-select",
Filter: ({ header, column }) => {
return (
<TableFilter
isMulti
header={header}
column={column}
variant="inline"
name="rolesFilter"
/>
);
},
filterFn: (row, id, filterValue) => {
if (
!filterValue.length ||
filterValue.length > proponents.length // select all is selected
) {
return true;
}

const value: string = row.getValue(id) || "";

return filterValue.includes(value);
},
},
{
accessorKey: "region_env.name",
header: "ENV Region",
Expand Down Expand Up @@ -231,7 +264,7 @@ const ProjectList = () => {
),
},
],
[types, subTypes, envRegions]
[types, subTypes, envRegions, proponents]
);
return (
<>
Expand Down
2 changes: 2 additions & 0 deletions epictrack-web/src/models/project.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Type } from "./type";
import { SubType } from "./subtype";
import { Region } from "./region";
import { Proponent } from "./proponent";

export interface Project {
id: number;
Expand All @@ -14,6 +15,7 @@ export interface Project {
region_id_env: number;
region_id_flnro: number;
proponent_id: number;
proponent: Proponent;
ea_certificate: string;
abbreviation: string;
epic_guid: string;
Expand Down
Loading