diff --git a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsList.tsx b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsList.tsx index 63cfd324..a0a8cd9e 100644 --- a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsList.tsx +++ b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsList.tsx @@ -53,7 +53,7 @@ const CapacityGroupsList: React.FC = () => { const [sortOrder, setSortOrder] = useState('asc'); const [capacitygroupsPerPage, setcapacitygroupsPerPage] = useState(20); // Set the default value here const { addFavorite, fetchFavoritesByType, deleteFavorite } = useContext(FavoritesContext)!; - const { findCompanyByCompanyID } = useContext(CompanyContext)!; + const { findCompanyByCompanyID, findCompanyNameByBpn } = useContext(CompanyContext)!; const [favoriteCapacityGroups, setFavoriteCapacityGroups] = useState([]); const handleSort = (column: string) => { @@ -210,6 +210,7 @@ const CapacityGroupsList: React.FC = () => { {user?.role === 'CUSTOMER' && ( <> {capacitygroup.supplierBNPL} + {findCompanyNameByBpn(capacitygroup.supplierBNPL)} )} diff --git a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsTableHeaders.tsx b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsTableHeaders.tsx index 25b55540..7b0bad1a 100644 --- a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsTableHeaders.tsx +++ b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsTableHeaders.tsx @@ -73,6 +73,11 @@ const CapacityGroupsTable: React.FC = ({ sortColumn, s {sortColumn === 'supplierBNPL' && sortOrder === 'asc' && } {sortColumn === 'supplierBNPL' && sortOrder === 'desc' && } + handleSort('supplierName')}> + Supplier Name + {sortColumn === 'supplierName' && sortOrder === 'asc' && } + {sortColumn === 'supplierName' && sortOrder === 'desc' && } + )} handleSort('numberOfMaterials')}> diff --git a/demand-capacity-mgmt-frontend/src/components/demands/DemandList.tsx b/demand-capacity-mgmt-frontend/src/components/demands/DemandList.tsx index 8d5ea6ae..aa5f30d2 100644 --- a/demand-capacity-mgmt-frontend/src/components/demands/DemandList.tsx +++ b/demand-capacity-mgmt-frontend/src/components/demands/DemandList.tsx @@ -28,6 +28,7 @@ import CapacityGroupsProvider from '../../contexts/CapacityGroupsContextProvider import { DemandContext } from '../../contexts/DemandContextProvider'; import { FavoritesContext } from "../../contexts/FavoritesContextProvider"; import UnitsofMeasureContextContextProvider from '../../contexts/UnitsOfMeasureContextProvider'; +import { useUser } from '../../contexts/UserContext'; import { DemandProp, DemandSeries, DemandSeriesValue } from '../../interfaces/demand_interfaces'; import { EventType } from '../../interfaces/event_interfaces'; import { FavoriteType, MaterialDemandFavoriteResponse } from "../../interfaces/favorite_interfaces"; @@ -57,6 +58,8 @@ const DemandList: React.FC<{ eventTypes = [] }) => { + const { user } = useUser(); + const [showDetailsModal, setShowDetailsModal] = useState(false); const [showDeleteConfirmation, setShowDeleteConfirmation] = useState(false); const [deleteItemId, setDeleteItemId] = useState(null); @@ -296,7 +299,18 @@ const DemandList: React.FC<{ - {demand.customer.bpn} + {user?.role === 'SUPPLIER' ? ( + <> + {demand.customer.bpn} + {demand.customer.companyName} + + ) : null} + {user?.role === 'CUSTOMER' ? ( + <> + {demand.supplier.bpn} + {demand.supplier.companyName} + + ) : null} {demand.materialNumberCustomer} {demand.materialNumberSupplier} diff --git a/demand-capacity-mgmt-frontend/src/components/demands/DemandListTableHeaders.tsx b/demand-capacity-mgmt-frontend/src/components/demands/DemandListTableHeaders.tsx index f3d4136a..e4cc08ec 100644 --- a/demand-capacity-mgmt-frontend/src/components/demands/DemandListTableHeaders.tsx +++ b/demand-capacity-mgmt-frontend/src/components/demands/DemandListTableHeaders.tsx @@ -21,6 +21,7 @@ */ import { BiCaretDown, BiCaretUp } from 'react-icons/bi'; +import { useUser } from '../../contexts/UserContext'; type DemandsTableProps = { sortColumn: string | null; @@ -31,7 +32,7 @@ type DemandsTableProps = { }; const DemandListTable: React.FC = ({ sortColumn, sortOrder, handleSort, demandItems, hasfavorites }) => { - + const { user } = useUser(); return ( @@ -39,12 +40,41 @@ const DemandListTable: React.FC = ({ sortColumn, sortOrder, h {hasfavorites && } {hasfavorites && } - + + + {user?.role === 'SUPPLIER' ? ( + <> + + + + ) : null} + {user?.role === 'CUSTOMER' ? ( + <> + + + + ) : null} + + {user?.role === 'SUPPLIER' ? ( + <> + + + + ) : null} + {user?.role === 'CUSTOMER' ? ( + <> + + + + ) : null}
handleSort('customer.bpn')}> - Company Id{' '} - {sortColumn === 'customer.bpn' && sortOrder === 'asc' && } - {sortColumn === 'customer.bpn' && sortOrder === 'desc' && } - {!sortColumn && ...} - handleSort('customer.bpn')}> + Customer BPN{' '} + {sortColumn === 'customer.bpn' && sortOrder === 'asc' && } + {sortColumn === 'customer.bpn' && sortOrder === 'desc' && } + {!sortColumn && ...} + handleSort('customer.name')}> + Customer Name{' '} + {sortColumn === 'customer.name' && sortOrder === 'asc' && } + {sortColumn === 'customer.name' && sortOrder === 'desc' && } + {!sortColumn && ...} + handleSort('supplier.bpn')}> + Supplier BPN{' '} + {sortColumn === 'supplier.bpn' && sortOrder === 'asc' && } + {sortColumn === 'supplier.bpn' && sortOrder === 'desc' && } + {!sortColumn && ...} + handleSort('supplier.name')}> + Supplier Name{' '} + {sortColumn === 'supplier.name' && sortOrder === 'asc' && } + {sortColumn === 'supplier.name' && sortOrder === 'desc' && } + {!sortColumn && ...} + handleSort('materialNumberCustomer')}> Material No. Customer{' '} {sortColumn === 'materialNumberCustomer' && sortOrder === 'asc' && } diff --git a/demand-capacity-mgmt-frontend/src/components/demands/DemandManagement.tsx b/demand-capacity-mgmt-frontend/src/components/demands/DemandManagement.tsx index 1d72d7c0..27adf0d0 100644 --- a/demand-capacity-mgmt-frontend/src/components/demands/DemandManagement.tsx +++ b/demand-capacity-mgmt-frontend/src/components/demands/DemandManagement.tsx @@ -256,7 +256,18 @@ const DemandManagement: React.FC = () => { - {demand.customer.bpn}{demand.customer.bpn}{demand.customer.companyName}{demand.supplier.bpn}{demand.supplier.companyName}{demand.materialNumberCustomer} {demand.materialNumberSupplier} diff --git a/demand-capacity-mgmt-frontend/src/components/demands/DemandManagementTableHeaders.tsx b/demand-capacity-mgmt-frontend/src/components/demands/DemandManagementTableHeaders.tsx index d251bfc3..826d50a4 100644 --- a/demand-capacity-mgmt-frontend/src/components/demands/DemandManagementTableHeaders.tsx +++ b/demand-capacity-mgmt-frontend/src/components/demands/DemandManagementTableHeaders.tsx @@ -21,6 +21,7 @@ */ import { BiCaretDown, BiCaretUp } from 'react-icons/bi'; +import { useUser } from '../../contexts/UserContext'; type DemandsTableProps = { sortColumn: string | null; @@ -31,18 +32,46 @@ type DemandsTableProps = { const DemandManagementTable: React.FC = ({ sortColumn, sortOrder, handleSort, demandItems }) => { + const { user } = useUser(); + return ( - + {user?.role === 'SUPPLIER' ? ( + <> + + + + ) : null} + {user?.role === 'CUSTOMER' ? ( + <> + + + + ) : null}
handleSort('customer.bpn')}> - Company Id{' '} - {sortColumn === 'customer.bpn' && sortOrder === 'asc' && } - {sortColumn === 'customer.bpn' && sortOrder === 'desc' && } - {!sortColumn && ...} - handleSort('customer.bpn')}> + Customer BPN{' '} + {sortColumn === 'customer.bpn' && sortOrder === 'asc' && } + {sortColumn === 'customer.bpn' && sortOrder === 'desc' && } + {!sortColumn && ...} + handleSort('customer.name')}> + Customer Name{' '} + {sortColumn === 'customer.name' && sortOrder === 'asc' && } + {sortColumn === 'customer.name' && sortOrder === 'desc' && } + {!sortColumn && ...} + handleSort('supplier.bpn')}> + Supplier BPN{' '} + {sortColumn === 'supplier.bpn' && sortOrder === 'asc' && } + {sortColumn === 'supplier.bpn' && sortOrder === 'desc' && } + {!sortColumn && ...} + handleSort('supplier.name')}> + Supplier Name{' '} + {sortColumn === 'supplier.name' && sortOrder === 'asc' && } + {sortColumn === 'supplier.name' && sortOrder === 'desc' && } + {!sortColumn && ...} + handleSort('materialNumberCustomer')}> Material No. Customer{' '} {sortColumn === 'materialNumberCustomer' && sortOrder === 'asc' && } diff --git a/demand-capacity-mgmt-frontend/src/contexts/CompanyContextProvider.tsx b/demand-capacity-mgmt-frontend/src/contexts/CompanyContextProvider.tsx index 08cc2883..4cff78f4 100644 --- a/demand-capacity-mgmt-frontend/src/contexts/CompanyContextProvider.tsx +++ b/demand-capacity-mgmt-frontend/src/contexts/CompanyContextProvider.tsx @@ -40,6 +40,7 @@ interface CompanyContextData { companies: Company[]; topCompanies: Company[]; findCompanyByCompanyID: (companyID: string) => Company | undefined; + findCompanyNameByBpn: (bpn: string) => string | undefined; } export const CompanyContext = createContext(undefined); @@ -84,9 +85,13 @@ const CompanyContextProvider: React.FC> = (props) => return companies.find(company => company.id === companyID); }; + const findCompanyNameByBpn = (bpn: string | undefined): string => { + const companyName = companies.find(company => company.bpn === bpn)?.companyName; + return companyName || 'N/A'; + }; return ( - + {props.children} );