import React from 'react';
import { formatStr } from '../../_utils/setFormatter';
import s from '../input/index.less';
import {DateProps} from '../detailInterface';

export default function Detail(props:DateProps) {
    const { value, formatter, componentAttr } = props;
    const formatValue = formatter ? formatter(value) : value;
    if (!formatValue) return null;

    const { format = formatStr } = componentAttr || {};

    let valueStr = '';
    if (typeof formatValue === 'string') {
        valueStr = formatValue;
    } else {
        valueStr = formatValue.format ? formatValue.format(format) : formatValue;
    }
    return <div className={s.text}>{valueStr}</div>;
}
