Skip to content

Commit

Permalink
Console Log cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruskyy committed Nov 6, 2023
1 parent 0e0514c commit e79a4c7
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const CapacityGroupAddToExisting: React.FC<CapacityGroupAddToExistingProps> = ({
const handleLinkToCapacityGroup = () => {
if (selectedCapacityGroup?.value && checkedDemands && checkedDemands.length > 0) {
const demandIds = checkedDemands.map((demand) => {
console.log(demand.id , "ssssssssss");
return demand.id

});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
};
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
});

Expand Down Expand Up @@ -396,7 +404,7 @@ function CapacityGroupWizardModal({ show, onHide, checkedDemands, demands }: Cap
<br />
<strong>Material Number Customer:</strong> {demand ? demand.materialNumberCustomer : 'Not selected'}
<br />
<strong>Unit of Measure:</strong> <span>{getUnitMeasureDescription(demand.unitMeasureId?.id ?? demand.unitMeasureId)}</span>
<strong>Unit of Measure:</strong> <span>{getUnitMeasureDescription(demand.unitMeasureId?.id ?? demand.unitOfMeasure)}</span>
</p>
</div>
</div>
Expand Down Expand Up @@ -452,7 +460,7 @@ function CapacityGroupWizardModal({ show, onHide, checkedDemands, demands }: Cap
<br />
<strong>Material Number Customer:</strong> {demand ? demand.materialNumberCustomer : 'Not selected'}
<br />
<strong>Unit of Measure:</strong> {getUnitMeasureDescription(demand.unitMeasureId?.id ?? demand.unitMeasureId)}
<strong>Unit of Measure:</strong> {getUnitMeasureDescription(demand.unitMeasureId?.id ?? demand.unitOfMeasure)}
</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const EventsTable: React.FC<EventsTableProps> = ({ 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));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ const DemandContextProvider: React.FC<React.PropsWithChildren<{}>> = (props) =>

const updateDemand = async (updatedDemand: Demand) => {
try {
console.log(updatedDemand)
await api.put(`/demand/${updatedDemand.id}`, updatedDemand);
fetchDemandProps();
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ const EventsContextProvider: React.FC<React.PropsWithChildren<{}>> = (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);
Expand Down

0 comments on commit e79a4c7

Please sign in to comment.