2021-09-03 09:26:43 +05:00
|
|
|
import { Empty } from 'antd';
|
|
|
|
import {Grid, GridItem} from '../../components/Grid'
|
|
|
|
|
|
|
|
export const View = ({columns, item}) => {
|
|
|
|
if (!item || !columns?.length)
|
|
|
|
return <Empty image={Empty.PRESENTED_IMAGE_SIMPLE}/>
|
|
|
|
|
|
|
|
const colsCount = 3
|
|
|
|
const viewItems = columns.map( (column, i) => {
|
|
|
|
const row = Math.floor(i / colsCount) + 1
|
|
|
|
const colb = i % colsCount
|
2021-10-04 18:06:42 +05:00
|
|
|
|
2021-09-03 09:26:43 +05:00
|
|
|
return <>
|
2021-10-04 18:06:42 +05:00
|
|
|
<GridItem
|
|
|
|
row={row}
|
|
|
|
col={colb*2 + 1}
|
2021-10-05 14:57:56 +05:00
|
|
|
style={{background:'#00000005',
|
|
|
|
border:'1px solid black'
|
|
|
|
}}
|
2021-10-04 18:06:42 +05:00
|
|
|
>
|
|
|
|
{column.title}
|
|
|
|
</GridItem>
|
|
|
|
<GridItem
|
|
|
|
row={row}
|
|
|
|
col={colb*2 + 2}
|
2021-10-05 14:57:56 +05:00
|
|
|
style={{background:'#00000005',
|
|
|
|
border:'1px solid black',
|
|
|
|
justifyContent:'right',
|
|
|
|
marginRight:'16px',
|
|
|
|
fontWeight:'bold',
|
|
|
|
textAlign:'right'}}
|
2021-09-03 09:26:43 +05:00
|
|
|
>
|
2021-10-04 18:06:42 +05:00
|
|
|
{column.render ? column.render(item[column.dataIndex]) : item[column.dataIndex]}
|
|
|
|
</GridItem>
|
2021-09-03 09:26:43 +05:00
|
|
|
</>
|
|
|
|
})
|
|
|
|
|
2021-10-04 18:06:42 +05:00
|
|
|
return <>
|
|
|
|
<Grid>
|
|
|
|
{viewItems}
|
|
|
|
</Grid>
|
|
|
|
</>
|
2021-09-03 09:26:43 +05:00
|
|
|
}
|