Plugin module for within Formik (or other forms) that provides API-based type ahead for Seed Lot IDs.
npm install tbc-common-lottypeaheadnpm install --save tbc-common-lottypeahead
import LotTypeAhead from "tbc-common-lottypeahead/dist/Component/LotTypeAhead";
configObject={configObject}
fieldValue={formProps.values.seedLotBusId}
onChange={callback => {
formProps.setFieldValue("seedLotBusId", callback);
}}
numberOfSuggestions={10}
/>
`
#### configObject
configObject is a static object that contains parental state items required for LotTypeAhead:
- token - authentication token:
- token_type
- access_token
- name
- seedApi - variable from urlConfig
- handleError - function from handleError
- setError - function to set any error message (typically from ErrorState)
#### fieldValue
The value in the LotTypeAhead input field (taken from Formik in example)
#### onChange
Function that sets the LotTypeAhead field value based on callback response
#### numberOfSuggestions
OPTIONAL: the number of responses returned by auto-suggest; defaults to 10
$3
npm install --save react-autosuggest formik react-oidc@0.1.0 oidc-client@1.5.4
$3
For any unit test file that deep renders ("mounts") this imported component, add the following:
jest.mock("tbc-common-lottypeahead/dist/Component/LotTypeAhead", () => "div");`