/*
* @Description: 新建或编辑任务
* @Author: tangjiang
* @Date: 2019-11-15 16:38:34
* @Last Modified by: tangjiang
* @Last Modified time: 2019-11-19 23:23:41
*/
import './index.scss';
import React, { useEffect } from 'react';
import { connect } from 'react-redux';
import SplitPane from 'react-split-pane';// import { Form } from 'antd';
import { Button } from 'antd';
import LeftPane from './leftpane';
import RightPane from './rightpane';
import { withRouter } from 'react-router';
import { toStore } from 'educoder';
import UserInfo from '../components/userInfo';
// import RightPane from './rightpane/index';
import actions from '../../../redux/actions';
const NewOrEditTask = (props) => {
const {
publishLoading,
handlePublish,
// testCases = [],
// ojTestCaseValidate = [],
identifier,
isPublish,
userInfo,
submitLoading,
changeSubmitLoadingStatus,
changePublishLoadingStatus,
startProgramQuestion,
getUserInfoForNew,
// updateTestAndValidate,
} = props;
// 表单提交
const handleSubmitForm = () => {
// 调用输入表单验证功能
if (props.identifier) {
props.handleUpdateOjForm(props);
} else {
// 改变loading状态
changeSubmitLoadingStatus(true);
props.handleFormSubmit(props); // 提交表单
}
};
useEffect(() => {
// 获取用户信息
getUserInfoForNew();
// console.log('获取路由参数: ====', props.match.params);
const id = props.match.params.id;
// 保存OJForm的id号,指明是编辑还是新增
props.saveOJFormId(id);
if (id) { // id号即 identifier
// TODO id 存在时, 编辑, 获取 store 中的记录数
props.getOJFormById(id);
} else {
// 清空store中的测试用例集合
props.clearOJFormStore();
}
return () => {}
}, []);
// 模拟挑战
const startChallenge = () => {
// 调用 start 接口, 成功后跳转到模拟页面
startProgramQuestion(identifier, props);
}
// 取消
const handleClickCancel = () => {
// 清空当前输入值并跳转至列表页
props.clearOJFormStore();
// 清空描述信息
toStore('oj_description', '');
setInterval(function () {
props.history.push('/problems');
}, 500);
}
// 发布
const handleClickPublish = () => {
// console.log('public has click');
changePublishLoadingStatus(true);
handlePublish(props, 'publish');
}
// 取消保存/取消按钮
const renderSaveOrCancel = () => {
return (
{props.name || ''}
{ renderQuit() } {/* 退出 */} {/* */}