import React, { useEffect } from 'react'; import { useFormik } from 'formik'; import { useDispatch } from 'react-redux'; import StyledWrapper from './StyledWrapper'; import toast from 'react-hot-toast'; import { updateBrunoConfig } from 'providers/ReduxStore/slices/collections/actions'; import cloneDeep from 'lodash/cloneDeep'; const PresetsSettings = ({ collection }) => { const dispatch = useDispatch(); const { brunoConfig: { presets: presets = {} } } = collection; const formik = useFormik({ enableReinitialize: true, initialValues: { requestType: presets.requestType || 'http', requestUrl: presets.requestUrl || '' }, onSubmit: (newPresets) => { const brunoConfig = cloneDeep(collection.brunoConfig); brunoConfig.presets = newPresets; dispatch(updateBrunoConfig(brunoConfig, collection.uid)); toast.success('Collection presets updated'); } }); return (
These presets will be used as the default values for new requests in this collection.
); }; export default PresetsSettings;