|
|
@ -61,15 +61,22 @@ function SearchablePicker({ |
|
|
|
formPlaceholder, |
|
|
|
searchPlaceholder, |
|
|
|
name, |
|
|
|
setSelected, |
|
|
|
nothingToShow = "Não encontramos nada com esse termo", |
|
|
|
marginRight = 2, |
|
|
|
marginLeft = 16, |
|
|
|
}) { |
|
|
|
const { values, setFieldValue, errors, touched } = useFormikContext(); |
|
|
|
const [value, setValue] = useState(values[name]); |
|
|
|
|
|
|
|
const { values, setFieldValue, errors, touched } = name ? useFormikContext() : [1,1,1,1]; |
|
|
|
|
|
|
|
|
|
|
|
const [value, setValue] = useState(name ? values[name] : ""); |
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
setFieldValue(name, value, true); |
|
|
|
if (name) |
|
|
|
setFieldValue(name, value, true); |
|
|
|
else |
|
|
|
setSelected(value) |
|
|
|
}, [value]); |
|
|
|
|
|
|
|
return ( |
|
|
@ -97,7 +104,7 @@ function SearchablePicker({ |
|
|
|
/> |
|
|
|
</Shadow> |
|
|
|
|
|
|
|
<ErrorMessage error={errors[name]} visible={touched[name]} /> |
|
|
|
{name && (<ErrorMessage error={errors[name]} visible={touched[name]} />)} |
|
|
|
</View> |
|
|
|
); |
|
|
|
} |
|
|
|