import { Badge } from 'react-bootstrap'
import moment from 'moment'

export const rowformatter = (data) =>{
    
    return [
        (rowIndex, fieldName)=>{
            const obj = data[rowIndex]
            const value = obj[fieldName]
            return <span className={`${obj.IsRead ? 'read' :'unread'}`}>{value}</span>
        },
        (rowIndex, fieldName)=>{
            const obj = data[rowIndex]            
            const value = obj[fieldName]
            const formattedDate = moment(value).format("DD MMM,YYYY hh:mm a")
            return (<span className={`${obj.IsRead ? 'read' :'unread'}`}>{formattedDate}</span>)
        },        
    ]
}

export const headers = [
    { name: "Description", field: "NotificationMessage", sortable: true },
    { name: "Date", field: "CreatedOn", sortable: true }
]

const utilityStatusToVariant = (status) => {
    if(0 == status.toLocaleLowerCase().localeCompare('severe') ){
        return 'danger'
    }else if(0 == status.toLocaleLowerCase().localeCompare('normal') ){
        return 'success'
        
    }else{
        return 'warning'
    }
}