This repository was archived by the owner on Mar 9, 2021. It is now read-only.
File tree 2 files changed +28
-24
lines changed 2 files changed +28
-24
lines changed Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
- import { Card , Icon } from 'semantic-ui-react' ;
2
+ import { Card , Icon , Image } from 'semantic-ui-react' ;
3
3
4
4
const convertTime = time => {
5
5
const date = new Date ( time ) ;
6
6
return date . toDateString ( ) ;
7
7
} ;
8
8
9
- const RowEvent = props => (
10
- < Card fluid >
11
- < Card . Content >
12
- < Card . Header > { props . name } </ Card . Header >
13
- < Card . Meta > { convertTime ( props . time ) } </ Card . Meta >
14
- { /* <Card.Description as="string">{props.description}</Card.Description> */ }
15
- </ Card . Content >
16
- < Card . Content extra >
17
- < Icon circular name = "users" />
18
- { `${ props . yesCount } attended` }
19
- </ Card . Content >
20
- </ Card >
21
- ) ;
9
+ const RowEvent = props => {
10
+ const matchForImage = props . description . match (
11
+ / < i m g .+ s r c = (?: " | ' ) ( .+ ?) (?: " | ' ) (?: .+ ?) > / ,
12
+ ) ;
13
+ return (
14
+ < Card fluid >
15
+ < Card . Content >
16
+ < Image src = { matchForImage === null ? '' : matchForImage [ 1 ] } />
17
+ < Card . Header > { props . name } </ Card . Header >
18
+ < Card . Meta > { convertTime ( props . time ) } </ Card . Meta >
19
+ < Card . Description as = "string" >
20
+ { props . description . replace ( / < \/ ? [ a - z ] [ a - z 0 - 9 ] * [ ^ < > ] * > / gi, '' ) }
21
+ </ Card . Description >
22
+ </ Card . Content >
23
+ < Card . Content extra >
24
+ < Icon circular name = "users" />
25
+ { `${ props . yesCount } attended` }
26
+ </ Card . Content >
27
+ </ Card >
28
+ ) ;
29
+ } ;
22
30
23
31
export default RowEvent ;
Original file line number Diff line number Diff line change 1
1
import React from 'react' ;
2
2
import { Card } from 'semantic-ui-react' ;
3
+ import axios from 'axios' ;
3
4
4
5
import publicPage from '../hocs/public-page' ;
5
6
import pastEventsMeetupURL from '../common/urls' ;
@@ -13,17 +14,12 @@ export default publicPage(
13
14
14
15
async componentDidMount ( ) {
15
16
try {
16
- const request = await fetch ( pastEventsMeetupURL ) ;
17
- if ( request . ok ) {
18
- const response = await request . json ( ) ;
19
- this . setState ( {
20
- pastEvents : response ,
21
- } ) ;
22
- } else {
23
- console . log ( 'server responded with ' , request . status ) ;
24
- }
17
+ const request = await axios . get ( pastEventsMeetupURL ) ;
18
+ this . setState ( {
19
+ pastEvents : request . data ,
20
+ } ) ;
25
21
} catch ( err ) {
26
- console . log ( 'error in fetch' ) ;
22
+ console . log ( err ) ;
27
23
}
28
24
}
29
25
You can’t perform that action at this time.
0 commit comments