Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions src/features/questions/create-question/CreateQuestionPage.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useState, useCallback, useEffect, useRef } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Link, Redirect } from 'react-router-dom';
import { Link, Redirect, useHistory } from 'react-router-dom';
import styled from 'styled-components';
import { Editor } from '@toast-ui/react-editor';
import { PlusOutlined } from '@ant-design/icons';
import { Button, Tag, Input, Alert, Typography } from 'antd';
import { Button, Tag, Input, Alert, Typography, notification } from 'antd';
import { Title } from 'app/Title/Title';
import { Paper } from 'components/layout/Paper';
import { addQuestion } from 'features/questions/questionsSlice';
Expand Down Expand Up @@ -93,6 +93,7 @@ CancelLinkLabel.propTypes = {

const CreateQuestion = () => {
const dispatch = useDispatch();
const history = useHistory();
const editorRef = useRef();

const profile = useSelector(selectProfile);
Expand Down Expand Up @@ -141,10 +142,17 @@ const CreateQuestion = () => {
tags,
userId: profile._id,
})
);
setQuestion('');
setFullDescription('');
editorRef.current.getInstance().reset();
)
.unwrap()
.then(() => {
notification.success({
message: 'Вопрос успешно опубликован',
});
history.push('/');
setQuestion('');
setFullDescription('');
editorRef.current.getInstance().reset();
});
};

const handleChange = () => {
Expand Down