Add event id to Card links

This commit is contained in:
Aarni Halinen
2018-11-17 15:20:53 +02:00
parent fe50ab9685
commit e5157c17b3
2 changed files with 5 additions and 3 deletions
+3 -2
View File
@@ -3,6 +3,7 @@ import { Link } from "react-router-dom";
import "./Card.scss";
export interface CardProps {
event_id: number;
title: string;
start_time: string;
text: string;
@@ -12,7 +13,7 @@ export interface CardState {}
class Card extends React.Component<CardProps, CardState> {
render() {
const { title, text, image } = this.props;
const { title, text, image, event_id } = this.props;
let options = {
day: "numeric",
month: "numeric",
@@ -22,7 +23,7 @@ class Card extends React.Component<CardProps, CardState> {
};
const datetime = new Date(this.props.start_time).toLocaleString("fi-FI", options);
return (
<Link to="/events/1" className="card">
<Link to={"/events/" + event_id} className="card">
<div className="card__datetime">{datetime}</div>
<div className="card__title">{title}</div>
<img src={image} className="card__image" />
+2 -1
View File
@@ -82,10 +82,11 @@ class FrontPage extends React.Component<FrontPageProps, FrontPageState> {
<PageSection backgroundColor={PageSectionColor.White}>
{events.map(event => (
<Card
key={event.id}
event_id={event.id}
title={event.title}
start_time={event.start_time}
text={event.description}
key={event.id}
image={BeerImage}
/>
))}