-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added a window for adding a new channel.
- Loading branch information
Showing
10 changed files
with
98 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
* text=auto | ||
* text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Modal, Form, Button } from 'react-bootstrap'; | ||
import { useDispatch, useSelector } from 'react-redux'; | ||
import { useFormik } from 'formik'; | ||
import { | ||
useContext, useEffect, useRef, useState, | ||
} from 'react'; | ||
import cn from 'classnames'; | ||
import { modalClose } from '../../slices/modalSlice'; | ||
import { ApiContext } from '../../hoc/ApiProvider'; | ||
|
||
const ModalAddChannel = () => { | ||
const { isOpened } = useSelector((state) => state.modal); | ||
const { sendNewChannel } = useContext(ApiContext); | ||
const dispatch = useDispatch(); | ||
const inputRef = useRef(); | ||
const [inputInvalid] = useState(false); | ||
// setInputInvalid | ||
const handlerСlosure = () => dispatch(modalClose()); | ||
|
||
const formik = useFormik({ | ||
initialValues: { | ||
name: '', | ||
}, | ||
onSubmit: async (values) => { | ||
sendNewChannel(values.name); | ||
}, | ||
}); | ||
|
||
useEffect(() => { | ||
inputRef.current.select(); | ||
}, []); | ||
|
||
return ( | ||
<Modal dialogClassName="modal-dialog-centered" show={isOpened} onHide={handlerСlosure}> | ||
<Modal.Header closeButton> | ||
<Modal.Title>Добавить канал</Modal.Title> | ||
</Modal.Header> | ||
<Modal.Body> | ||
<Form onSubmit={formik.handleSubmit}> | ||
<Form.Group controlId="name"> | ||
<Form.Control | ||
ref={inputRef} | ||
className={cn({ | ||
'mb-2': true, | ||
'is-invalid': inputInvalid, | ||
})} | ||
name="name" | ||
value={formik.values.name} | ||
onChange={formik.handleChange} | ||
/> | ||
<Form.Label className="visually-hidden">Имя канала</Form.Label> | ||
<div className="d-flex justify-content-end"> | ||
<Button className="me-2" variant="secondary">Отменить</Button> | ||
<Button variant="primary" type="submit">Отправить</Button> | ||
</div> | ||
</Form.Group> | ||
</Form> | ||
</Modal.Body> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default ModalAddChannel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import AddChannel from './AddChannel.js'; | ||
// import RemoveChannel from './RemoveChannel.jsx'; | ||
// import RenameChannel from './RenameChannel.jsx'; | ||
|
||
const modals = { | ||
addChannel: <AddChannel />, | ||
// removeChannel: RemoveChannel, | ||
// renameChannel: RenameChannel, | ||
}; | ||
|
||
export default (modalType) => modals[modalType]; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters