refactor: redux migration new folder in collection

This commit is contained in:
Anoop M D
2022-03-18 19:45:20 +05:30
parent 7faff0339b
commit d90178240e
4 changed files with 42 additions and 28 deletions

View File

@@ -2,11 +2,11 @@ import React, { useRef, useEffect } from 'react';
import {useFormik} from 'formik';
import * as Yup from 'yup';
import Modal from 'components/Modal';
import actions from 'providers/Store/actions'
import { useStore } from 'providers/Store';
import { useDispatch } from 'react-redux';
import { newFolder } from 'providers/ReduxStore/slices/collections';
const NewFolder = ({collectionUid, handleCancel, handleClose}) => {
const [store, storeDispatch] = useStore();
const dispatch = useDispatch();
const inputRef = useRef();
const formik = useFormik({
enableReinitialize: true,
@@ -20,11 +20,7 @@ const NewFolder = ({collectionUid, handleCancel, handleClose}) => {
.required('name is required')
}),
onSubmit: (values) => {
storeDispatch({
type: actions.SIDEBAR_COLLECTION_NEW_FOLDER,
collectionUid: collectionUid,
folderName: values.folderName
});
dispatch(newFolder(values.folderName, collectionUid));
handleClose();
}
});