Passed
Push — master ( 6fca9e...82ba0d )
by Huu-Phat
02:25 queued 10s
created

cms/src/post/components/Post.js   A

Complexity

Total Complexity 3
Complexity/F 0

Size

Lines of Code 85
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 78
mnd 3
bc 3
fnc 0
dl 0
loc 85
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
ccs 6
cts 6
cp 1
rs 10
1
import React from 'react'
2
import PropTypes from 'prop-types'
3
import Typography from '@material-ui/core/Typography'
4
5
import PostEditor from 'core/async-components/PostEditor'
6
import Loading from 'core/components/Loading'
7
import Container from 'core/components/Container'
8
import Paper from 'core/components/Paper'
9
import Grid from 'post/components/base/Grid'
10
import PostButton from 'post/components/base/Button'
11
12
import Title from 'post/containers/Title'
13
import Slug from 'post/containers/Slug'
14
import Author from 'post/containers/Author'
15
import Time from 'post/containers/Time'
16
import Brief from 'post/containers/Brief'
17
import Tags from 'post/containers/Tags'
18
19 1
const Post = ({ loading, newPost, saveEditedContent, createPost }) => {
20 5
  if (loading) {
21 1
    return <Loading />
22
  }
23 4
  return (
24
    <Container>
25
      <Paper>
26
        <Grid container style={{ padding: '16px' }} spacing={3}>
27
          <Grid item sm={11}>
28
            {newPost ? (
29
              <Typography variant="h6">New Post</Typography>
30
            ) : (
31
              <Typography variant="h6">Editing Post</Typography>
32
            )}
33
          </Grid>
34
        </Grid>
35
        <Grid container>
36
          <Grid container item direction="column" xs={12} sm={8} spacing={3}>
37
            <Grid item>
38
              <Title />
39
            </Grid>
40
            <Grid item>
41
              <Brief />
42
            </Grid>
43
            <Grid item>
44
              <PostEditor />
45
            </Grid>
46
          </Grid>
47
          <Grid container item direction="column" xs={6} sm={4}>
48
            <Grid item>
49
              <Slug />
50
            </Grid>
51
            <Grid item>
52
              <Author />
53
            </Grid>
54
            <Grid item>
55
              <Time />
56
            </Grid>
57
            <Grid item>
58
              <Tags />
59
            </Grid>
60
            <Grid item>
61
              <PostButton
62
                variant="contained"
63
                size="large"
64
                color="primary"
65 2
                onClick={() => (newPost ? createPost() : saveEditedContent())}
66
              >
67
                Save
68
              </PostButton>
69
            </Grid>
70
          </Grid>
71
        </Grid>
72
      </Paper>
73
    </Container>
74
  )
75
}
76
77 1
Post.propTypes = {
78
  newPost: PropTypes.bool,
79
  loading: PropTypes.bool,
80
  saveEditedContent: PropTypes.func,
81
  createPost: PropTypes.func
82
}
83
84
export default Post
85