Skip to content

OBPIH-6020 Preference Type Modal#4441

Merged
kchelstowski merged 8 commits intofeature/product-supplier-list-redesignfrom
OBPIH-6020
Jan 4, 2024
Merged

OBPIH-6020 Preference Type Modal#4441
kchelstowski merged 8 commits intofeature/product-supplier-list-redesignfrom
OBPIH-6020

Conversation

@alannadolny
Copy link
Collaborator

No description provided.

<>
<span
className={label?.className}
onClick={onCellClick}
Copy link
Collaborator

Choose a reason for hiding this comment

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

here it doesn't matter, because the definition of your method is () => ..., but be aware that if you had an argument, it would be called with the e from span.
I mean that your current code evaluets to:

onClick={e => onCellClick(e)}

</span>
<PreferenceTypeModal
productSupplierId={productSupplierId}
isOpen={!!preferenceTypeModalData.length}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't mind this, but in general the double negations are difficult to read - how about doing it as:

isOpen={Boolean(preferenceTypeModalData.length)}

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 have any preference about that, so I can change it

<span className="preference-type-location">Default: </span>
<span>{name}</span>
</p>
),
Copy link
Collaborator

Choose a reason for hiding this comment

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

returning HTML like that feels weird to me - if it would not be difficult to change, how about just storing the name and destinationParty.name in the list and then mapping it in the JSX output (85th line)?
If it is more complicated than I think, then I guess you can skip it.

</div>
<div className="preference-type-modal-list-container">
<div>
{mapPreferenceTypes(modalData).default}
Copy link
Collaborator

Choose a reason for hiding this comment

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

let's assign the result of the mapPreferenceTypes(modalData) to a variable, because doing it this way, you run this method twice - for the first time here, and for the second time in the 85th line.

@kchelstowski
Copy link
Collaborator

Additionally I think it would be an interesting improvement if you somehow stored already visited product sources' preference type modal.
How I see is just adding maybe an additional useState that would store the calculated data by the mapPreferenceTypes and the key would be the product source id.
By doing it, we'd avoid the "complexed" calculations if you closed/opened the modal over and over again.
It's just a "loud thought", so if you find it interesting, proceed, if not, then we could skip it.

</div>
<div className="preference-type-modal-list">
{mappedPreferenceTypes?.preferenceTypes?.map((preferenceType) => (
<p>
Copy link
Collaborator

Choose a reason for hiding this comment

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

you forgot to add the key

@kchelstowski kchelstowski merged commit c5e392d into feature/product-supplier-list-redesign Jan 4, 2024
@kchelstowski kchelstowski deleted the OBPIH-6020 branch January 4, 2024 15:17
awalkowiak pushed a commit that referenced this pull request Mar 12, 2024
* OBPIH-6020 Add opening preference type modal and basic structure of it

* OBPIH-6020 Add mapping preference types

* OBPIH-6020 Pass id to the modal component for redirecting

* OBPIH-6020 Override global modal styles

* OBPIH-6020 Add url for editing

* OBPIH-6020 Add translation for modal header

* OBPIH-6020 Changes after review

* OBPIH-6020 Add key
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants