import React, { Component } from 'react'
import * as Icon from '@ant-design/icons'

export default class AntIcon extends Component {
    render() {
        const type = (this.props.type || '').toUpperCase()

        if (type) {
            if (
                type.indexOf('OUTLINED') >= 0 ||
                type.indexOf('FILLED') >= 0 ||
                type.indexOf('TWOTONE') >= 0
            ) {
                const I = Icon[this.props.type]
                return I ? <I {...this.props} /> : false
            } else {
                const t =
                    type
                        .split('-')
                        .map(p => {
                            return p[0] + p.slice(1).toLowerCase()
                        })
                        .join('') + 'Outlined'
                const I = Icon[t]
                return I ? <I {...this.props} /> : false
            }
        }
        return <></>
    }
}
