moved it outside

This commit is contained in:
hagen-danswer
2024-11-22 14:59:58 -08:00
parent 3e58f9f8ab
commit e32809f7ca

View File

@@ -24,7 +24,14 @@ export const SlackTokensForm = ({
setPopup: (popup: { message: string; type: "error" | "success" }) => void; setPopup: (popup: { message: string; type: "error" | "success" }) => void;
router: any; router: any;
onValuesChange?: (values: any) => void; onValuesChange?: (values: any) => void;
}) => ( }) => {
useEffect(() => {
if (onValuesChange) {
onValuesChange(initialValues);
}
}, [initialValues]);
return (
<Formik <Formik
initialValues={initialValues} initialValues={initialValues}
validationSchema={Yup.object().shape({ validationSchema={Yup.object().shape({
@@ -68,12 +75,7 @@ export const SlackTokensForm = ({
}} }}
enableReinitialize={true} enableReinitialize={true}
> >
{({ isSubmitting, setFieldValue, values }) => { {({ isSubmitting, setFieldValue, values }) => (
useEffect(() => {
onValuesChange?.(values);
}, [values, onValuesChange]);
return (
<Form className="w-full"> <Form className="w-full">
{!isUpdate && ( {!isUpdate && (
<div className=""> <div className="">
@@ -126,7 +128,7 @@ export const SlackTokensForm = ({
</Button> </Button>
</div> </div>
</Form> </Form>
); )}
}}
</Formik> </Formik>
); );
};