Skip to content

Commit

Permalink
fix: subsections should show comment if not authenticated KER-361 (#1030
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mikkojamG committed May 13, 2024
1 parent 4e09859 commit b8db2c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/components/Hearing/Section/SectionContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ export class SectionContainerComponent extends React.Component {
</section>
)}

<SubSectionsList hearing={hearing} language={language} user={user} />
<SubSectionsList hearing={hearing} language={language} />

{this.renderCommentsSection()}
</Col>
Expand Down
29 changes: 10 additions & 19 deletions src/components/Hearing/Section/SubSectionsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,18 @@ import getAttr from '../../../utils/getAttr';
import Icon from '../../../utils/Icon';
import Link from '../../LinkWithLang';
import MouseOnlyLink from '../../MouseOnlyLink';
import { getSectionURL, isSectionCommentable, userCanComment, hasAnyQuestions } from '../../../utils/section';
import { getSectionURL, hasAnyQuestions } from '../../../utils/section';

const SubsectionList = ({ hearing, language, user, history, match }) => {
const SubsectionList = ({ hearing, language, history, match }) => {
const sectionsWithoutClosure = hearing.sections.filter((section) => section.type !== 'closure-info');
const subSections = sectionsWithoutClosure.filter((section) => section.type !== 'main');

const bgImage = (section) => (!isEmpty(section.images) ? `url("${section.images[0].url}")` : `url(${defaultImage})`);

const isCommentable = (section) => {
const hasPlugin = !!section.plugin_identifier;
return isSectionCommentable(hearing, section, user) && !hasPlugin;
};

if (!subSections.length) {
return null;
}

return (
<section className='hearing-section subsections-list'>
<h2>
Expand Down Expand Up @@ -74,21 +70,17 @@ const SubsectionList = ({ hearing, language, user, history, match }) => {
</div>
)}
<div className='section-card-buttons'>
<Link
to={{ path: getSectionURL(match.params.hearingSlug, section) }}
>
<Button size="small" className='kerrokantasi-btn black'>
<Link to={{ path: getSectionURL(match.params.hearingSlug, section) }}>
<Button size='small' className='kerrokantasi-btn black'>
<FormattedMessage id='showSubsectionBtn' />
</Button>
</Link>
{!hearing.closed && isCommentable(section) && userCanComment(user, section) && (
<Link
to={{ path: getSectionURL(hearing.slug, section), hash: '#comments-section' }}
>
<Button size="small" className="kerrokantasi-btn">
{!hearing.closed && (
<Link to={{ path: getSectionURL(hearing.slug, section), hash: '#comments-section' }}>
<Button size='small' className='kerrokantasi-btn'>
<FormattedMessage
id={hasAnyQuestions(section) ? 'commentAndVoteSubsectionBtn' : 'commentSubsectionBtn'}
/>
id={hasAnyQuestions(section) ? 'commentAndVoteSubsectionBtn' : 'commentSubsectionBtn'}
/>
</Button>
</Link>
)}
Expand All @@ -106,7 +98,6 @@ const SubsectionList = ({ hearing, language, user, history, match }) => {
SubsectionList.propTypes = {
hearing: PropTypes.object,
language: PropTypes.string,
user: PropTypes.object,
history: PropTypes.object,
match: PropTypes.object,
};
Expand Down

0 comments on commit b8db2c7

Please sign in to comment.