import moment from 'moment'
import { Badge } from 'react-bootstrap'
import {  LabTestStatusIndicator_Enum } from "../../../redux/helpers/action-enums"


export const LabReportUtilityStatusToVariant = (statusCode) => {
    if(LabTestStatusIndicator_Enum.Severe == parseInt(statusCode)){
        return 'danger'
    }else if(LabTestStatusIndicator_Enum.Normal == parseInt(statusCode) ){
        return 'success'
        
    }else{
        return 'warning'
    }
}

export const rowformatter = (labReports) => (
        [
            (rowIndex, fieldName)=>{
                const theLabReport = labReports[rowIndex]
                const value = theLabReport[fieldName]
                const formattedDate = moment(value).format("DD MMM,YYYY")
                return (<span>{formattedDate}</span>)
            },
            (rowIndex, fieldName)=>{
                const theLabReport = labReports[rowIndex]
                const value = theLabReport[fieldName]
                return (<span>{value}</span>)
            },
            (rowIndex, fieldName)=>{
                const theLabReport = labReports[rowIndex]
                const value = theLabReport[fieldName]
                return (<span>{value}</span>)
            
            },
            (rowIndex, fieldName)=>{
                const theLabReport = labReports[rowIndex]
                const value = theLabReport[fieldName]
                return (<Badge pill variant={`${LabReportUtilityStatusToVariant(value)}`}>&nbsp;</Badge>)
            
            },
            (rowIndex, fieldName)=>{
                const theLabReport = labReports[rowIndex]
                const value = theLabReport[fieldName]
                return (<span>{value}</span>)
            }
            
        ]
)

export const headers = 
    [
        { name: "Date of Test", field: "TestDate", sortable: false},
        { name: "Name of Test", field: "TestName", sortable: false},
        { name: "Value", field: "Value", sortable: true },
        { name: "Color Code", field: "LabTestStatusIndicator", sortable: true },
        { name: "Comments", field: "Comments", sortable: true },
    ]
