forked from ddrilling/asb_cloud_front
Add components for simple view users and companies.
Add Grid.jsx for css grid.
This commit is contained in:
parent
22c242cd5e
commit
33146c59d8
25
src/components/CompanyView.jsx
Normal file
25
src/components/CompanyView.jsx
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
import {Tooltip} from 'antd'
|
||||||
|
import {BankOutlined} from '@ant-design/icons'
|
||||||
|
import {Grid, GridItem} from './Grid'
|
||||||
|
|
||||||
|
export const CompanyView = ({company}) => {
|
||||||
|
if(!company)
|
||||||
|
return <Tooltip title='нет данных'>-</Tooltip>
|
||||||
|
|
||||||
|
const displayName = company?.caption
|
||||||
|
|
||||||
|
const tooltipInfo = <Grid columnGap='8px'>
|
||||||
|
<GridItem row={1} col={1}>
|
||||||
|
тип:
|
||||||
|
</GridItem>
|
||||||
|
<GridItem row={1} col={2}>
|
||||||
|
{company?.companyTypeCaption}
|
||||||
|
</GridItem>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
return <Tooltip title={tooltipInfo}>
|
||||||
|
<BankOutlined style={{marginRight:8}}/>
|
||||||
|
{displayName}
|
||||||
|
</Tooltip>
|
||||||
|
|
||||||
|
}
|
30
src/components/Grid.jsx
Normal file
30
src/components/Grid.jsx
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
export const Grid = ({children, ...other}) => {
|
||||||
|
const gridContainerStyle = {
|
||||||
|
display: 'grid',
|
||||||
|
columnGap: '4px',
|
||||||
|
rowGap: '4px',
|
||||||
|
...other,
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div style={gridContainerStyle}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
export const GridItem = ({children, row, col, rowSpan, colSpan, ...other}) => {
|
||||||
|
const localRow = +row
|
||||||
|
const localCol = +col
|
||||||
|
const localColSpan = colSpan ? colSpan - 1 : 0
|
||||||
|
const localRowSpan = rowSpan ? rowSpan - 1 : 0
|
||||||
|
const gridItemStyle = {
|
||||||
|
gridColumnStart: localCol,
|
||||||
|
gridColumnEnd: localCol + localColSpan,
|
||||||
|
gridRowStart: localRow,
|
||||||
|
gridRowEnd: localRow + localRowSpan,
|
||||||
|
...other,
|
||||||
|
}
|
||||||
|
|
||||||
|
return <div style={gridItemStyle}>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
import {Tooltip} from 'antd'
|
import {Tooltip} from 'antd'
|
||||||
import { UserOutlined } from '@ant-design/icons'
|
import {UserOutlined} from '@ant-design/icons'
|
||||||
import '../styles/grid.css'
|
import {Grid, GridItem} from './Grid'
|
||||||
|
|
||||||
export const UserView = ({user}) => {
|
export const UserView = ({user}) => {
|
||||||
if(!user)
|
if(!user)
|
||||||
@ -8,29 +8,35 @@ export const UserView = ({user}) => {
|
|||||||
|
|
||||||
const displayName = user?.login
|
const displayName = user?.login
|
||||||
|
|
||||||
const tooltipInfo = <div className='grid_container'>
|
const tooltipInfo = <Grid columnGap='8px'>
|
||||||
<div className='c1 r1'>
|
<GridItem row={1} col={1}>
|
||||||
Имя
|
Имя:
|
||||||
</div>
|
</GridItem>
|
||||||
<div className='c2 r1'>
|
<GridItem row={1} col={2}>
|
||||||
{user?.name}
|
{user?.name}
|
||||||
</div>
|
</GridItem>
|
||||||
<div className='c1 r2'>
|
<GridItem row={2} col={1}>
|
||||||
Фамилия
|
Фамилия:
|
||||||
</div>
|
</GridItem>
|
||||||
<div className='c2 r2'>
|
<GridItem row={3} col={2}>
|
||||||
{user?.surname}
|
{user?.surname}
|
||||||
</div>
|
</GridItem>
|
||||||
<div className='c1 r3'>
|
<GridItem row={3} col={1}>
|
||||||
Отчество
|
Отчество:
|
||||||
</div>
|
</GridItem>
|
||||||
<div className='c2 r3'>
|
<GridItem row={3} col={2}>
|
||||||
{user?.patronymic}
|
{user?.patronymic}
|
||||||
</div>
|
</GridItem>
|
||||||
</div>
|
<GridItem row={4} col={1}>
|
||||||
|
Компания:
|
||||||
|
</GridItem>
|
||||||
|
<GridItem row={4} col={2}>
|
||||||
|
{user?.company?.caption}
|
||||||
|
</GridItem>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
return <Tooltip title={tooltipInfo}>
|
return <Tooltip title={tooltipInfo}>
|
||||||
<UserOutlined/>
|
<UserOutlined style={{marginRight:8}}/>
|
||||||
{displayName}
|
{displayName}
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user