11// tslint:disable:no-magic-numbers
2- import { Avatar , Button , Container , Grid , Paper } from '@material-ui/core' ;
2+ import { Button , Container , Grid , Paper } from '@material-ui/core' ;
33import _isNil from 'ramda/src/isNil' ;
44import React , { memo , useEffect } from 'react' ;
55import { useDispatch , useSelector } from 'react-redux' ;
66import { RouteComponentProps } from 'react-router' ;
7- import { Redirect } from 'react-router-dom' ;
8- import { ROOT } from '../../constants/routes' ;
7+ import CourseMetaInfo from '../../atoms/CourseMetaInfo' ;
98import courseImagePlaceholder from '../../images/course_400x180.png' ;
109import { getCourseDetailsRequested } from '../../redux/courseDetails/actionCreators' ;
1110import { State } from '../../redux/rootReducer' ;
@@ -19,17 +18,14 @@ export interface Params {
1918const CourseView = ( { match } : RouteComponentProps < Params > ) => {
2019 const classes = useStyles ( ) ;
2120
22- if ( match . params . courseSlug . trim ( ) === '' ) {
23- return < Redirect to = { ROOT } /> ;
24- }
2521 const { course, getCourseDetailsLoading } = useSelector (
2622 ( state : State ) => state . courseDetails
2723 ) ;
2824
2925 const dispatch = useDispatch ( ) ;
3026
3127 useEffect ( ( ) => {
32- if ( course === undefined || course . slug !== match . params . courseSlug ) {
28+ if ( course === undefined || course . slug !== match . params . courseSlug ) {
3329 dispatch ( getCourseDetailsRequested ( match . params . courseSlug ) ) ;
3430 }
3531 } , [ match . params . courseSlug ] ) ;
@@ -45,37 +41,39 @@ const CourseView = ({ match }: RouteComponentProps<Params>) => {
4541
4642 return (
4743 < div className = { classes . root } >
48- < Container component = "main" maxWidth = "lg" >
44+ < Container component = "div" className = { classes . metaInfo } maxWidth = { false } >
45+ < Container component = "div" maxWidth = "lg" >
46+ < Grid container spacing = { 4 } >
47+ < Grid item xs = { 12 } sm = { 9 } >
48+ < CourseMetaInfo course = { course } />
49+ </ Grid >
50+ < Grid item xs = { 12 } sm = { 3 } className = { classes . metaInfoSidebar } >
51+ < Paper className = { [ classes . sidebarCard , classes . paper ] . join ( ' ' ) } >
52+ < img src = { imageUrl } style = { { width : '100%' } } />
53+ < h4 > { `£${ coursePrice } ` } </ h4 >
54+ < Button variant = "contained" fullWidth color = "primary" >
55+ Add to cart
56+ </ Button >
57+ < Button variant = "contained" fullWidth color = "secondary" >
58+ Buy now
59+ </ Button >
60+ </ Paper >
61+ </ Grid >
62+ </ Grid >
63+ </ Container >
64+ </ Container >
65+ < Container >
4966 < Grid container spacing = { 3 } >
5067 < Grid item xs = { 12 } sm = { 9 } >
5168 < Paper className = { classes . paper } >
52- < h3 > { course . title } </ h3 >
53- < h4 >
54- < Avatar className = { classes . avatar } >
55- { `${ ( course . user . firstName as string ) . substr ( 0 , 1 ) } ${ ( course
56- . user . lastName as string ) . substr ( 0 , 1 ) } `}
57- </ Avatar >
58- { course . user . firstName } { course . user . lastName }
59- </ h4 >
6069 < div
6170 dangerouslySetInnerHTML = { {
6271 __html : course . description as string ,
6372 } }
6473 />
6574 </ Paper >
6675 </ Grid >
67- < Grid item xs = { 12 } sm = { 3 } >
68- < Paper className = { classes . paper } >
69- < img src = { imageUrl } style = { { width : '100%' } } />
70- < h4 > { `£${ coursePrice } ` } </ h4 >
71- < Button variant = "contained" fullWidth color = "primary" >
72- Add to cart
73- </ Button >
74- < Button variant = "contained" fullWidth color = "secondary" >
75- Buy now
76- </ Button >
77- </ Paper >
78- </ Grid >
76+ < Grid item xs = { 12 } sm = { 3 } > </ Grid >
7977 </ Grid >
8078 </ Container >
8179 </ div >
0 commit comments