import React ,{useEffect , useState} from 'react';
import { Button } from 'antd';
import Editors from './Editors';

function Sure({datas , name , saveFunc , sureSubmit , loading}){
  const [ value , setValue ] = useState(undefined);
  useEffect(()=>{
    if(datas && datas.content){
      setValue(datas.content)
    }
  },[datas]);

  function sure(){
    sureSubmit();
  }

  return(
    <div>
      <div style={{padding:"0px 15px 15px 15px"}}>
        流水线名称：{name}
      </div>
      <div className="editorBody" style={{marginTop:"0px"}}>
        <Editors value={value} theme={"vs-grey"} height={"600px"} visible/>
      </div>
      <div className="mt20">
        <Button type={"primary"} onClick={()=>saveFunc(undefined,undefined,undefined,undefined,"last")}>上一步</Button>
        { value && <Button type={"primary"} loading={loading} className="ml20" onClick={sure}>确定提交</Button> }
      </div>
    </div>
  )
}
export default Sure;