Skip to content

OBPIH-6267 Do not select edited lines to receive automatically in par…#4900

Merged
awalkowiak merged 2 commits intodevelopfrom
OBPIH-6267
Oct 21, 2024
Merged

OBPIH-6267 Do not select edited lines to receive automatically in par…#4900
awalkowiak merged 2 commits intodevelopfrom
OBPIH-6267

Conversation

@kchelstowski
Copy link
Collaborator

…tial receiving workflow

✨ Description of Change

A concise summary of what is being changed. Please provide enough context for reviewers to be able to understand the change and why it is necessary. If the issue/ticket already provides enough information, you can put "See ticket" as the description.

Link to GitHub issue or Jira ticket:

Description:


📷 Screenshots & Recordings (optional)

If this PR contains a UI change, consider adding one or more screenshots here or link to a screen recording to help reviewers visualize the change. Otherwise, you can remove this section.

@kchelstowski kchelstowski self-assigned this Oct 17, 2024
@github-actions github-actions bot added the domain: frontend Changes or discussions relating to the frontend UI label Oct 17, 2024
@kchelstowski kchelstowski added the warn: do not merge Marks a pull request that is not yet ready to be merged label Oct 18, 2024
@kchelstowski kchelstowski removed the warn: do not merge Marks a pull request that is not yet ready to be merged label Oct 18, 2024
Copy link
Collaborator

@alannadolny alannadolny left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at those changes, I am getting more and more confident that this should be refactored asap, because each of our changes is rather fixing using duct tape, not in the way it should be done.

Comment on lines +741 to +758
const shipmentItemsGrouped = shipmentItems.reduce((acc, item, idx) => {
if (idx < rowIndex) {
return {
...acc,
itemsBeforeCurrentRow: [...acc.itemsBeforeCurrentRow, item],
};
}
if (idx === rowIndex) {
return {
...acc,
originalItem: item,
};
}
return {
...acc,
itemsAfterCurrentRow: [...acc.itemsAfterCurrentRow, item],
};
}, { itemsBeforeCurrentRow: [], originalItem: null, itemsAfterCurrentRow: [] });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can simplify that code using _.groupBy from lodash

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how I would be able to use the _.groupBy from lodash here - from what I can see in the docs, I don't find it useful in that specific case, where I base the "key" on whether the index is lower, equal or higher than x.
I believe that this .reduce is quite readable, isn't it?

Comment on lines +795 to +806
static mapContainers(containers, parentIndex, rowIndex, items) {
return containers.map((container, idx) => {
if (idx === parentIndex) {
const { shipmentItems } = container;
return {
...container,
shipmentItems: PartialReceivingPage.mapShipmentItems(shipmentItems, rowIndex, items),
};
}
return container;
});
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to move this function to some utils instead of creating a static function ... static functions in React feels odd to me

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason why it is static is that the eslint was shouting that I don't use this keyword in a class method, so the options were either to make it static or to move it out of the component. I decided to go with the static, as there are already a few of them in this component.
I think a util is unnecessary here, because those methods are specifically targeting this component, I don't find it reusable anywhere else.
What do you think?

@awalkowiak awalkowiak merged commit 4367bd1 into develop Oct 21, 2024
@awalkowiak awalkowiak deleted the OBPIH-6267 branch October 21, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: frontend Changes or discussions relating to the frontend UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants