import React from 'react';
import * as Shared from 'placeholder-shared'
import * as Common from './common'
import * as Antd from 'antd'
import { connect} from 'react-redux'
import { Label, Segment } from 'semantic-ui-react'
var classnames  = require('classnames')
import './RunResult.scss'
import { Icon } from '@ant-design/compatible';

import {
  CheckCircleTwoTone,
  ExclamationCircleTwoTone
} from '@ant-design/icons';

export class ResultsIndicator extends React.Component<{
    runResult:any; 
    className?:string;
},{}> {
    constructor(props) {
        super(props)
    }
    render() {
        let ret = null;
        if (!this.props.runResult) {
            return null;
        }
        if (this.props.runResult.editResult && this.props.runResult.editResult.success == false){
            ret = <ExclamationCircleTwoTone className="Status"  twoToneColor="#eb2f96" />
        }
        else if (this.props.runResult.status == 'running'){
            ret = <Common.DivWithClassName style={{ position: 'relative', left: '3px' }}>
                <Antd.Spin />
            </Common.DivWithClassName> 
        }
        else if (this.props.runResult.status == 'changed' ||
        !this.props.runResult.createResult ||
            (this.props.runResult[1] && !('success' in this.props.runResult[1]))
        ) {
            ret = null
        }
        else if (this.props.runResult.status == 'queued') {
            console.log("is queued", this.props.runResult.status)
            ret = null
        }
        else if ((this.props.runResult.previewResult && this.props.runResult.previewResult.success == false) ||
            (this.props.runResult.createResult && this.props.runResult.createResult.success == false)) {
            ret = <ExclamationCircleTwoTone  className="Status"  twoToneColor="#eb2f96" />
        }
        else {
            ret = <CheckCircleTwoTone className="Status"  twoToneColor="#52c41a"/>
        }
        return <Common.DivWithClassName className='ResultDiv'>
            {ret}
        </Common.DivWithClassName>
    }
}
