OBPIH-6108 add preference type section with inputs#4523
Conversation
… the access to this value to a subsection that uses this data
…id in the payload
- added styling for placeholder on DateField - added ability to pass a translation label to placeholder on DateField
| <PreferenceTypeVariations | ||
| <DefaultPreferenceType | ||
| control={control} | ||
| errors={errors} |
There was a problem hiding this comment.
do you need the whole errors object? Maybe it is worth to pass the errors as it is done below, in the PreferenceTypeVariations
| 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} |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
Is values?.defaultPreferenceType?.id not enough? I think that when the values?.defaultPreferenceType will be empty, then id should be null / undefined
| useEffect(() => { | ||
| dispatch(fetchPreferenceTypes()); | ||
| dispatch(fetchBuyers()); | ||
| }, []); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
I'd suggest thinking asap about the react-query that would handle such things for us (loading (spinner), caching, etc.)
cc @drodzewicz
…ceType validation schema
* 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
No description provided.