Fix post modal rules not linking properly

This commit is contained in:
sonny 2020-07-22 22:56:00 +02:00
parent 296202b69f
commit 0f5e9e7fca

View file

@ -3,6 +3,7 @@ import { connect } from 'react-redux';
import Cookies from 'js-cookie';
import { unSelectPost, markPostRead } from '../actions/posts.js';
import { CATEGORY_TYPE, RULE_TYPE, FEED, SUBREDDIT } from '../constants.js';
import { formatDatetime } from '../../../utils.js';
class PostModal extends React.Component {
@ -43,6 +44,10 @@ class PostModal extends React.Component {
const post = this.props.post;
const publicationDate = formatDatetime(post.publicationDate);
const titleClassName = post.read ? 'post__title post__title--read' : 'post__title';
const ruleUrl =
this.props.rule.type === FEED
? `/collection/rules/${this.props.rule.id}/`
: `/collection/rules/subreddits/${this.props.rule.id}/`;
return (
<div className="modal post-modal">
@ -70,11 +75,7 @@ class PostModal extends React.Component {
</span>
)}
<span className="badge post__rule" title={this.props.rule.name}>
<a
href={`/collection/rules/${this.props.rule.id}/`}
target="_blank"
rel="noopener noreferrer"
>
<a href={ruleUrl} target="_blank" rel="noopener noreferrer">
{this.props.rule.name}
</a>
</span>