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.

Events page updated #11

Merged
merged 17 commits into from
Oct 17, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
events page updated
  • Loading branch information
M-ZubairAhmed committed Oct 6, 2017
commit 1e28c4f22fe373ba6bd972f2ad4271a889e787a1
36 changes: 22 additions & 14 deletions components/row-events.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,31 @@
import React from 'react';
import { Card, Icon } from 'semantic-ui-react';
import { Card, Icon, Image } from 'semantic-ui-react';

const convertTime = time => {
const date = new Date(time);
return date.toDateString();
};

const RowEvent = props => (
<Card fluid>
<Card.Content>
<Card.Header>{props.name}</Card.Header>
<Card.Meta>{convertTime(props.time)}</Card.Meta>
{/* <Card.Description as="string">{props.description}</Card.Description> */}
</Card.Content>
<Card.Content extra>
<Icon circular name="users" />
{`${props.yesCount} attended`}
</Card.Content>
</Card>
);
const RowEvent = props => {
const matchForImage = props.description.match(
/<img.+src=(?:"|')(.+?)(?:"|')(?:.+?)>/,
);
return (
<Card fluid>
<Card.Content>
<Image src={matchForImage === null ? '' : matchForImage[1]} />
<Card.Header>{props.name}</Card.Header>
<Card.Meta>{convertTime(props.time)}</Card.Meta>
<Card.Description as="string">
{props.description.replace(/<\/?[a-z][a-z0-9]*[^<>]*>/gi, '')}
</Card.Description>
</Card.Content>
<Card.Content extra>
<Icon circular name="users" />
{`${props.yesCount} attended`}
</Card.Content>
</Card>
);
};

export default RowEvent;
16 changes: 6 additions & 10 deletions pages/events.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { Card } from 'semantic-ui-react';
import axios from 'axios';

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

async componentDidMount() {
try {
const request = await fetch(pastEventsMeetupURL);
if (request.ok) {
const response = await request.json();
this.setState({
pastEvents: response,
});
} else {
console.log('server responded with ', request.status);
}
const request = await axios.get(pastEventsMeetupURL);
this.setState({
pastEvents: request.data,
});
} catch (err) {
console.log('error in fetch');
console.log(err);
}
}

Expand Down