Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Mar 9, 2021. It is now read-only.

Commit 1e28c4f

Browse files
author
M-ZubairAhmed
committed
events page updated
1 parent 824651d commit 1e28c4f

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

components/row-events.js

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
import React from 'react';
2-
import { Card, Icon } from 'semantic-ui-react';
2+
import { Card, Icon, Image } from 'semantic-ui-react';
33

44
const convertTime = time => {
55
const date = new Date(time);
66
return date.toDateString();
77
};
88

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+
/<img.+src=(?:"|')(.+?)(?:"|')(?:.+?)>/,
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-z0-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+
};
2230

2331
export default RowEvent;

pages/events.js

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import React from 'react';
22
import { Card } from 'semantic-ui-react';
3+
import axios from 'axios';
34

45
import publicPage from '../hocs/public-page';
56
import pastEventsMeetupURL from '../common/urls';
@@ -13,17 +14,12 @@ export default publicPage(
1314

1415
async componentDidMount() {
1516
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+
});
2521
} catch (err) {
26-
console.log('error in fetch');
22+
console.log(err);
2723
}
2824
}
2925

0 commit comments

Comments
 (0)