diff --git a/README.md b/README.md index 5ba3861..8de88c8 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,7 @@ [](https://github.com/Tatyana-js/frontend-project-12/actions) ### link to the site: -(https://github.com/Tatyana-js/frontend-project-12) \ No newline at end of file +(https://github.com/Tatyana-js/frontend-project-12) + +### demo +(https://frontend-chat-ru.hexlet.app/) \ No newline at end of file diff --git a/frontend/src/components/AddModal.jsx b/frontend/src/components/AddModal.jsx index b6a0405..109e047 100644 --- a/frontend/src/components/AddModal.jsx +++ b/frontend/src/components/AddModal.jsx @@ -1,8 +1,9 @@ import { useEffect, useRef } from 'react'; import { useFormik } from 'formik'; import { Modal, FormGroup, FormControl, Button, Form } from 'react-bootstrap'; -import { useSelector, useDispatch } from 'react-redux'; +import { useDispatch } from 'react-redux'; import { useTranslation } from 'react-i18next'; +import { channelSchema } from '../utils/validate.js'; import { useAddChannelMutation } from '../api/chatApi'; import { selectActiveTab } from '../slices/activeChannelSlice.js'; @@ -10,16 +11,17 @@ const AddChannel = ({ onHide }) => { const { t } = useTranslation(); const dispatch = useDispatch(); const [ addChannel ] = useAddChannelMutation(); - const modals = useSelector((state) => state.modals); const formControlEl = useRef(null); const formik = useFormik({ initialValues: { - channelName: '', + name: '', }, + validationSchema: channelSchema(t), + validateOnChange: false, onSubmit: async (values) => { try { - const response = await addChannel({name: values.channelName}); + const response = await addChannel({name: values.name}); dispatch(selectActiveTab(response.data)); onHide(); } catch (error) { @@ -29,10 +31,6 @@ const AddChannel = ({ onHide }) => { } }); - useEffect(() => { - formControlEl.current.focus(); - }, []); - return ( <>
@@ -45,14 +43,18 @@ return (