| Total Complexity | 3 |
| Complexity/F | 0 |
| Lines of Code | 85 |
| Function Count | 0 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 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 |