-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add controlled component state to AddressForm for regions #537
Comments
Is this issue still open ? |
@ayobamiseun Good to hear from you! It looks like this one is a stale issue that's been resolved. for documentation purposes (before I close out this issue): <Controller
control={control}
name={`generator.${addressType}.state`}
render={({ field }) => {
return (
<Select
id={`generator${addressType}State`}
{...field}
options={StateCode}
getOptionLabel={(option) => option.name ?? 'error'}
getOptionValue={(option) => option.code}
openMenuOnFocus={false}
isDisabled={readOnly}
onChange={(option) => {
field.onChange(option);
if (option && addressType === 'siteAddress') {
setGeneratorStateCode(option.code);
}
}}
classNames={{
control: () =>
`form-control p-0 rounded-2 ${addressErrors?.state && 'border-danger'} `,
}}
/>
);
}}
/> |
@dpgraham4401 that's nice. if you have any issues regarding frontend i will like to hop on it. |
@ayobamiseun you might be interested in #622? |
@dpgraham4401 Yes I will. |
@ayobamiseun Great! Please ask to be assigned in the comments on #622 (I can't assign someone outside the org until they at least comment on the issue). |
@dpgraham4401 here comes my biggest issues I have been finding it hard to set up the project on my local machine. I have already downloaded Docker. I would appreciate it if you could guide me on this. i do not mean to disturb you 🫣 |
@ayobamiseun What problems are you having when you go through the local dev detup guide? https://usepa.github.io/haztrak/development/local-development.html#docker-compose |
🐛 Bug Report
We should add component controlled state (
useState
hooks) for the state and country fields in theAddressForm
.Currently we use the react-select library for these pieces of the manifest like so.
And the country select is very similar.
There is no
value
prop, oronChange
handler at the moment.A PR that resolves this issue will add both props, with types.
The react idiomatic way of doing this, I believe, will be to have the state controlled by the parent component. In this case, that will be
HandlerForm
. I don't believe we use theAddressForm
in another location at the moment.For a working example, see the
SiteSelect
component. https://github.com/USEPA/haztrak/tree/main/client/src/components/Manifest/SiteSelectThe text was updated successfully, but these errors were encountered: