@ -9,7 +9,7 @@ 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 { Button , Modal } from 'antd' ;
import LeftPane from './leftpane' ;
import RightPane from './rightpane' ;
import { withRouter } from 'react-router' ;
@ -17,6 +17,7 @@ import { toStore } from 'educoder';
import UserInfo from '../components/userInfo' ;
// import RightPane from './rightpane/index';
import actions from '../../../redux/actions' ;
import { ModalConfirm } from '../../../common/components/ModalConfirm' ;
const NewOrEditTask = ( props ) => {
const {
@ -32,17 +33,18 @@ const NewOrEditTask = (props) => {
changePublishLoadingStatus ,
startProgramQuestion ,
getUserInfoForNew ,
handleCancelPublish ,
// updateTestAndValidate,
} = props ;
// 表单提交
const handleSubmitForm = ( ) => {
// 改变loading状态
changeSubmitLoadingStatus ( true ) ;
// 调用输入表单验证功能
if ( props . identifier ) {
props . handleUpdateOjForm ( props ) ;
} else {
// 改变loading状态
changeSubmitLoadingStatus ( true ) ;
props . handleFormSubmit ( props ) ; // 提交表单
}
} ;
@ -66,6 +68,9 @@ const NewOrEditTask = (props) => {
} , [ ] ) ;
// 模拟挑战
const imitationChallenge = ( ) => {
}
// 开始挑战
const startChallenge = ( ) => {
// 调用 start 接口, 成功后跳转到模拟页面
startProgramQuestion ( identifier , props ) ;
@ -84,9 +89,20 @@ const NewOrEditTask = (props) => {
// 发布
const handleClickPublish = ( ) => {
// console.log('public has click');
ModalConfirm ( '提示' , ( < p > 发布后即可应用到自己管理的课堂 < br / > 是否确认发布 ? < / p > ) , ( ) = > {
changePublishLoadingStatus ( true ) ;
handlePublish ( props , 'publish' ) ;
} ) ;
}
// 撤销发布
const handleClickCancelPublish = ( ) => {
ModalConfirm ( '提示' , ( < p > 是否确认撤销发布 ? < / p > ) , ( ) = > {
changePublishLoadingStatus ( true ) ;
handleCancelPublish ( props , identifier ) ;
} ) ;
}
// 取消保存/取消按钮
@ -107,11 +123,34 @@ const NewOrEditTask = (props) => {
}
// 发布/模拟挑战
const renderPubOrFight = ( ) => {
const pubButton = isPublish ? '' : ( < Button
const pubButton = isPublish
? ( < Button
type = "primary"
loading = { publishLoading }
onClick = { handleClickCancelPublish }
> 撤销发布 < / B u t t o n > )
: ( < Button
type = "primary"
loading = { publishLoading }
onClick = { handleClickPublish }
> 立即发布 < / B u t t o n > ) ;
// 未发布: 模拟挑战 已发布: 开始挑战
const challengeBtn = isPublish ? (
< Button type = "primary" onClick = { startChallenge } > 开始挑战 < / B u t t o n >
) : (
< Button type = "primary" onClick = { imitationChallenge } > 模拟挑战 < / B u t t o n >
) ;
// 更新
// const updateBtn = isPublish
// ? ''
// : (
// <Button
// type="primary"
// loading={submitLoading}
// onClick={handleSubmitForm}
// >更新</Button>
// );
return (
< React . Fragment >
< Button
@ -120,7 +159,7 @@ const NewOrEditTask = (props) => {
onClick = { handleSubmitForm }
> 更新 < / B u t t o n >
{ pubButton }
< Button type = "primary" onClick = { startChallenge } > 模拟挑战 < / B u t t o n >
{ challengeBtn }
< / R e a c t . F r a g m e n t >
)
}
@ -142,24 +181,9 @@ const NewOrEditTask = (props) => {
return (
< div className = { 'new_add_task_wrap' } >
< div className = { 'task_header' } >
{ / * < L i n k t o = " / p r o b l e m s " c l a s s N a m e = { ' h e a d e r _ b t n ' } >
< Icon type = "left" style = { { marginRight : '5px' } } / > 后退
< /Link> */ }
< UserInfo userInfo = { userInfo } / >
< p className = { 'header_title' } > { props . name || '' } < / p >
{ renderQuit ( ) }
{ / * < L i n k s t y l e = { {
position : 'absolute' ,
right : '30px' ,
top : 0 ,
color : '#5091FF'
} } to = "/problems" > 退出 < /Link> */ }
{ / * < B u t t o n
style = { { display : identifier ? 'none' : 'block' } }
loading = { publishLoading }
className = { ` header_btn ` }
type = "primary"
onClick = { handleClickPublish } > 立即发布 < /Button> */ }
< / d i v >
< div className = "split-pane-area" >
< SplitPane split = "vertical" minSize = { 350 } maxSize = { - 350 } defaultSize = "40%" >
@ -206,6 +230,8 @@ const mapDispatchToProps = (dispatch) => ({
handleFormSubmit : ( props ) => dispatch ( actions . validateOjForm ( props ) ) ,
// 发布表单
handlePublish : ( props , type ) => dispatch ( actions . validateOjForm ( props , type ) ) ,
// 撤销发布
handleCancelPublish : ( props , identifier ) => dispatch ( actions . handleClickCancelPublish ( props , identifier ) ) ,
// 更新OJForm
handleUpdateOjForm : ( props ) => dispatch ( actions . validateOjForm ( props ) ) ,
// 根据id号获取表单信息