Skip to content

OBPIH-6108 add preference type section with inputs#4523

Merged
awalkowiak merged 8 commits intofeature/product-supplier-list-redesignfrom
OBPIH-6108-add-preference-type-section-with-inputs
Feb 28, 2024
Merged

OBPIH-6108 add preference type section with inputs#4523
awalkowiak merged 8 commits intofeature/product-supplier-list-redesignfrom
OBPIH-6108-add-preference-type-section-with-inputs

Conversation

@drodzewicz
Copy link
Collaborator

No description provided.

<PreferenceTypeVariations
<DefaultPreferenceType
control={control}
errors={errors}
Copy link
Collaborator

Choose a reason for hiding this comment

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

do you need the whole errors object? Maybe it is worth to pass the errors as it is done below, in the PreferenceTypeVariations

Comment on lines 32 to 45
render={({ field }) => (
<SelectField
{...field}
placeholder="Select"
title={{
id: 'react.productSupplier.form.defaultPreferenceType.title',
defaultMessage: 'Default Preference Type',
}}
tooltip={{
id: 'react.productSupplier.form.defaultPreferenceType.tooltip',
defaultMessage: 'Company-wide purchasing preference for this supplier established through a competitive bid',
}}
options={preferenceTypes}
errorMessage={errors.defaultPreferenceType?.message}
Copy link
Collaborator

Choose a reason for hiding this comment

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

One change related to the requested changes in my previous PR is missing. To display the error you need hasErrors={true} (only in select fields)

ratingTypeCode: values?.ratingTypeCode ? values.ratingTypeCode.id : null,
productSupplierPreferences: values?.productSupplierPreferences,
uom: values?.uom ? values.uom.id : null,
defaultPreferenceType: values?.defaultPreferenceType ? values.defaultPreferenceType.id : null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is values?.defaultPreferenceType?.id not enough? I think that when the values?.defaultPreferenceType will be empty, then id should be null / undefined

Comment on lines 33 to 35
useEffect(() => {
dispatch(fetchPreferenceTypes());
dispatch(fetchBuyers());
}, []);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is not a change request, but rather a loud thinking. Maybe we should create a separate hook, for fetching data, we can pass functions, as an argument, and within the hook, we will check if everything is fetched, and based on that show / hide the spinner.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd suggest thinking asap about the react-query that would handle such things for us (loading (spinner), caching, etc.)
cc @drodzewicz

@awalkowiak awalkowiak merged commit 313b7e9 into feature/product-supplier-list-redesign Feb 28, 2024
@awalkowiak awalkowiak deleted the OBPIH-6108-add-preference-type-section-with-inputs branch February 28, 2024 16:54
awalkowiak pushed a commit that referenced this pull request Mar 12, 2024
* OBPIH-6108 Added Default Preference Type section with validation schema and fields

* OBPIH-6108 use preference type options in default preference type select

* OBPIH-6108 Prevented prop drilling case for ratingTypeCodes and moved the access to this value to a subsection that uses this data

* OBPIH-6108 fix default preference type schema type

* OBPIH-6108 set defaultPreferenceType as optional value and send only id in the payload

* OBPIH-6108 use bootstrap grid to align default preference type inputs

* OBPIH-6108 Added placeholders to fields on Default Preference Type
- added styling for placeholder on DateField
- added ability to pass a translation label to placeholder on DateField

* OBPIH-6108 added hasErrors prop to Select and updated defaultPreferenceType validation schema
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.

4 participants