From e79a4c70f8865a4dd898090f9278c1ff59859f8e Mon Sep 17 00:00:00 2001
From: Sergio Figueiredo
Date: Mon, 6 Nov 2023 23:33:46 +0000
Subject: [PATCH] Console Log cleanup
---
.../CapacityGroupAddToExisting.tsx | 1 -
.../CapacityGroupWizardModal.tsx | 20 +++++++++++++------
.../capacitygroup/CapacityGroupsList.tsx | 1 -
.../src/components/demands/DemandList.tsx | 1 -
.../components/demands/DemandManagement.tsx | 1 -
.../src/components/events/EventsTable.tsx | 1 -
.../src/contexts/DemandContextProvider.tsx | 1 -
.../src/contexts/EventsContextProvider.tsx | 1 -
8 files changed, 14 insertions(+), 13 deletions(-)
diff --git a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupAddToExisting.tsx b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupAddToExisting.tsx
index a0d41ef8..d1978dea 100644
--- a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupAddToExisting.tsx
+++ b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupAddToExisting.tsx
@@ -51,7 +51,6 @@ const CapacityGroupAddToExisting: React.FC = ({
const handleLinkToCapacityGroup = () => {
if (selectedCapacityGroup?.value && checkedDemands && checkedDemands.length > 0) {
const demandIds = checkedDemands.map((demand) => {
- console.log(demand.id , "ssssssssss");
return demand.id
});
diff --git a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupWizardModal.tsx b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupWizardModal.tsx
index 4505ea07..0204f2fc 100644
--- a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupWizardModal.tsx
+++ b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupWizardModal.tsx
@@ -64,6 +64,7 @@ function CapacityGroupWizardModal({ show, onHide, checkedDemands, demands }: Cap
// Function to get the unit measure description based on id
const getUnitMeasureDescription = (unitMeasureId: string) => {
+ console.log(unitMeasureId)
const unitMeasure = unitsofmeasureContext?.unitsofmeasure.find(unit => unit.id === unitMeasureId);
return unitMeasure ? `${unitMeasure.dimension} - ${unitMeasure.description} (${unitMeasure.unSymbol})` : 'N/A';
};
@@ -130,16 +131,19 @@ function CapacityGroupWizardModal({ show, onHide, checkedDemands, demands }: Cap
return { earliestDate, latestDate };
};
+
function areUnitMeasureIdsEqual(demands: DemandProp[]): boolean {
if (demands.length <= 1) {
return true; // If there's only one or zero demands, they are equal.
}
- const firstUnitMeasureId = demands[0].unitMeasureId;
- return demands.every((demand) => demand.unitMeasureId.id === firstUnitMeasureId.id);
+ const firstUnitMeasureId = demands[0].unitMeasureId?.id ?? demands[0].unitMeasureId;
+ return demands.every((demand) => {
+ const demandId = demand.unitMeasureId?.id ?? demand.unitMeasureId;
+ return demandId === firstUnitMeasureId;
+ });
}
-
const handleSubmit = async () => {
setIsLoading(true);
@@ -235,7 +239,11 @@ function CapacityGroupWizardModal({ show, onHide, checkedDemands, demands }: Cap
if (favoriteIdsSet.has(md.id)) {
return false;
}
- // Include demand if its ID is not in favorites
+ // Exclude demand if its linkStatus is neither 'TODO' nor 'UNLINKED'
+ if (md.linkStatus !== 'TODO' && md.linkStatus !== 'UNLINKED') {
+ return false;
+ }
+ // else
return true;
});
@@ -396,7 +404,7 @@ function CapacityGroupWizardModal({ show, onHide, checkedDemands, demands }: Cap
Material Number Customer: {demand ? demand.materialNumberCustomer : 'Not selected'}
- Unit of Measure: {getUnitMeasureDescription(demand.unitMeasureId?.id ?? demand.unitMeasureId)}
+ Unit of Measure: {getUnitMeasureDescription(demand.unitMeasureId?.id ?? demand.unitOfMeasure)}
@@ -452,7 +460,7 @@ function CapacityGroupWizardModal({ show, onHide, checkedDemands, demands }: Cap
Material Number Customer: {demand ? demand.materialNumberCustomer : 'Not selected'}
- Unit of Measure: {getUnitMeasureDescription(demand.unitMeasureId?.id ?? demand.unitMeasureId)}
+ Unit of Measure: {getUnitMeasureDescription(demand.unitMeasureId?.id ?? demand.unitOfMeasure)}
diff --git a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsList.tsx b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsList.tsx
index d27e73d5..8bd25f72 100644
--- a/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsList.tsx
+++ b/demand-capacity-mgmt-frontend/src/components/capacitygroup/CapacityGroupsList.tsx
@@ -67,7 +67,6 @@ const CapacityGroupsList: React.FC = () => {
const fetchFavorites = async () => {
try {
const favorites = await fetchFavoritesByType(FavoriteType.CAPACITY_GROUP);
- console.log(favorites)
if (favorites && favorites.capacityGroups) {
setFavoriteCapacityGroups(favorites.capacityGroups.map((fav: SingleCapacityGroupFavoriteResponse) => fav.id));
}
diff --git a/demand-capacity-mgmt-frontend/src/components/demands/DemandList.tsx b/demand-capacity-mgmt-frontend/src/components/demands/DemandList.tsx
index def97c2a..9a434395 100644
--- a/demand-capacity-mgmt-frontend/src/components/demands/DemandList.tsx
+++ b/demand-capacity-mgmt-frontend/src/components/demands/DemandList.tsx
@@ -82,7 +82,6 @@ const DemandList: React.FC<{
const fetchFavorites = async () => {
try {
const favorites = await fetchFavoritesByType(FavoriteType.MATERIAL_DEMAND);
- console.log(favorites)
if (favorites && favorites.materialDemands) {
setFavoriteDemands(favorites.materialDemands.map((fav: MaterialDemandFavoriteResponse) => fav.id));
}
diff --git a/demand-capacity-mgmt-frontend/src/components/demands/DemandManagement.tsx b/demand-capacity-mgmt-frontend/src/components/demands/DemandManagement.tsx
index 67021c3e..998537de 100644
--- a/demand-capacity-mgmt-frontend/src/components/demands/DemandManagement.tsx
+++ b/demand-capacity-mgmt-frontend/src/components/demands/DemandManagement.tsx
@@ -76,7 +76,6 @@ const DemandManagement: React.FC = () => {
const fetchFavorites = async () => {
try {
const favorites = await fetchFavoritesByType(FavoriteType.MATERIAL_DEMAND);
- console.log(favorites)
if (favorites && favorites.materialDemands) {
setFavoriteDemands(favorites.materialDemands.map((fav: MaterialDemandFavoriteResponse) => fav.id));
}
diff --git a/demand-capacity-mgmt-frontend/src/components/events/EventsTable.tsx b/demand-capacity-mgmt-frontend/src/components/events/EventsTable.tsx
index 3e0078db..c8ca3cb5 100644
--- a/demand-capacity-mgmt-frontend/src/components/events/EventsTable.tsx
+++ b/demand-capacity-mgmt-frontend/src/components/events/EventsTable.tsx
@@ -62,7 +62,6 @@ const EventsTable: React.FC = ({ events, isArchive }) => {
const fetchFavorites = async () => {
try {
const favorites = await fetchFavoritesByType(FavoriteType.EVENT);
- console.log(favorites)
if (favorites && favorites.events) {
setFavoriteEvents(favorites.events.map((fav: EventFavoriteResponse) => fav.logID));
}
diff --git a/demand-capacity-mgmt-frontend/src/contexts/DemandContextProvider.tsx b/demand-capacity-mgmt-frontend/src/contexts/DemandContextProvider.tsx
index f568967e..46a6bb15 100644
--- a/demand-capacity-mgmt-frontend/src/contexts/DemandContextProvider.tsx
+++ b/demand-capacity-mgmt-frontend/src/contexts/DemandContextProvider.tsx
@@ -108,7 +108,6 @@ const DemandContextProvider: React.FC> = (props) =>
const updateDemand = async (updatedDemand: Demand) => {
try {
- console.log(updatedDemand)
await api.put(`/demand/${updatedDemand.id}`, updatedDemand);
fetchDemandProps();
} catch (error) {
diff --git a/demand-capacity-mgmt-frontend/src/contexts/EventsContextProvider.tsx b/demand-capacity-mgmt-frontend/src/contexts/EventsContextProvider.tsx
index fc2981a6..ae6018a2 100644
--- a/demand-capacity-mgmt-frontend/src/contexts/EventsContextProvider.tsx
+++ b/demand-capacity-mgmt-frontend/src/contexts/EventsContextProvider.tsx
@@ -113,7 +113,6 @@ const EventsContextProvider: React.FC> = (props) =>
const archiveLog = async (event: EventProp) => {
try {
const api = createAPIInstance(access_token);
- console.log(event)
await api.post('/loggingHistory/archivedLog', event);
} catch (error) {
console.error('Error archiving event:', error);