import {Display} from '../../components/Display'
import RigMnemo from '../../components/RigMnemo'

const params = [
  {label:'Рот., об/мин', accessorName:'rotorSpeed', isArrowVisible:true},
  {label:'Долото, м', accessorName:'bitDepth', isArrowVisible:true, format:2},
  {label:'Забой, м', accessorName:'wellDepth', isArrowVisible:true, format:2},
  {label:'Расход, м³/ч', accessorName:'flow', isArrowVisible:true},
  {label:'Расход х.х., м³/ч', accessorName:'flowIdle', isArrowVisible:true},
  {label: 'Время', accessorName: 'date', format:'HH:mm:ss'},
]

export const CustomColumn = ({data}) => {
  const dataLast = data[data.length -1]
  
  if(dataLast)
    params.forEach(param => param.value = dataLast[param.accessorName])
  else
    params.forEach(param => param.value = '-' )

    return (<>
      {params.map(param => <Display className='border_small display_flex_container'
        key={param.label}
        label={param.label} 
        value={param.value} 
        suffix={param.units}
        isArrowVisible = {param.isArrowVisible}        
        format = {param.format}
        />)}
      <RigMnemo
        blockPosition={dataLast?.blockPosition??0}
        bitPosition={dataLast?.bitDepth??3200}/>
    </>)
}