|
| 1 | +/* |
| 2 | + * |
| 3 | + * ContentsCountCell |
| 4 | + * |
| 5 | + */ |
| 6 | + |
| 7 | +import React from 'react' |
| 8 | +import PropTypes from 'prop-types' |
| 9 | + |
| 10 | +import { Wrapper, Content, Label, Count } from './styles' |
| 11 | + |
| 12 | +import { makeDebugger } from '../../utils' |
| 13 | + |
| 14 | +/* eslint-disable no-unused-vars */ |
| 15 | +const debug = makeDebugger('c:ContentsCountCell:index') |
| 16 | +/* eslint-enable no-unused-vars */ |
| 17 | + |
| 18 | +const ContentsCountCell = ({ |
| 19 | + data: { postsCount, jobsCount, videosCount, reposCount }, |
| 20 | +}) => { |
| 21 | + return ( |
| 22 | + <Wrapper> |
| 23 | + <Content empty={postsCount === 0}> |
| 24 | + <Label>帖子:</Label>{' '} |
| 25 | + <Count empty={postsCount === 0}>{postsCount}</Count> |
| 26 | + </Content> |
| 27 | + <Content empty={jobsCount === 0}> |
| 28 | + <Label>招聘:</Label> <Count empty={jobsCount === 0}>{jobsCount}</Count> |
| 29 | + </Content> |
| 30 | + <Content empty={videosCount === 0}> |
| 31 | + <Label>视频:</Label>{' '} |
| 32 | + <Count empty={videosCount === 0}>{videosCount}</Count> |
| 33 | + </Content> |
| 34 | + <Content empty={reposCount === 0}> |
| 35 | + <Label>项目:</Label>{' '} |
| 36 | + <Count empty={reposCount === 0}>{reposCount}</Count> |
| 37 | + </Content> |
| 38 | + </Wrapper> |
| 39 | + ) |
| 40 | +} |
| 41 | + |
| 42 | +ContentsCountCell.propTypes = { |
| 43 | + // https://www.npmjs.com/package/prop-types |
| 44 | + data: PropTypes.shape({ |
| 45 | + postsCount: PropTypes.number, |
| 46 | + jobsCount: PropTypes.number, |
| 47 | + videosCount: PropTypes.number, |
| 48 | + reposCount: PropTypes.number, |
| 49 | + }), |
| 50 | +} |
| 51 | + |
| 52 | +ContentsCountCell.defaultProps = { |
| 53 | + data: { |
| 54 | + postsCount: 0, |
| 55 | + jobsCount: 0, |
| 56 | + videosCount: 0, |
| 57 | + reposCount: 0, |
| 58 | + }, |
| 59 | +} |
| 60 | + |
| 61 | +export default React.memo(ContentsCountCell) |
0 commit comments