1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { Alert, Button, Container } from 'react-bootstrap';
4 import { useTranslation } from 'react-i18next';
6 import List from './List';
7 import Outline from './Outline';
8 import Requirements from './Requirements';
9 import Rulesets from './Rulesets';
10 import Icon from '../common/Icon';
11 import RawHTML from '../common/RawHTML';
12 import nl2br from '../../helpers/nl2br';
18 } from '../../helpers/Technique';
19 import i18n from '../../i18n';
21 const Detail = ({ actions, technique }) => {
22 const { t } = useTranslation();
24 return <Container as="article">
25 <div className="d-flex align-items-center justify-content-between">
27 {getTranslation(technique, 'title', i18n.language)}
28 {actions.editContent ?
31 onClick={() => actions.editContent(technique)}
33 title={t('button.edit')}
34 variant="outline-secondary"
36 <Icon.EDIT title="" />
40 {technique && technique.rulesets ?
41 <Rulesets technique={technique} />
44 <Outline technique={technique} />
45 <Requirements technique={technique} />
46 <RawHTML html={getTranslation(technique, 'description', i18n.language)} />
47 {technique.chapters ? technique.chapters.map(chapter =>
48 <section id={`c${chapter.id}`} key={`c${chapter.id}`}>
49 {chapter.pivot.level ?
51 `h${chapter.pivot.level}`,
53 getTranslation(chapter, 'title', i18n.language),
57 onClick={() => actions.editContent(chapter)}
59 title={t('button.edit')}
60 variant="outline-secondary"
62 <Icon.EDIT title="" />
67 <RawHTML html={getTranslation(chapter, 'description', i18n.language)} />
70 {hasRelations(technique, 'related') ? <>
71 <h2 className="mt-5">{i18n.t('techniques.seeAlso')}</h2>
72 <List techniques={sorted(getRelations(technique, 'related'))} />
74 {getTranslation(technique, 'attribution', i18n.language) ?
75 <Alert variant="dark">
76 {nl2br(getTranslation(technique, 'attribution', i18n.language))}
83 actions: PropTypes.shape({
84 editContent: PropTypes.func,
86 technique: PropTypes.shape({
87 chapters: PropTypes.arrayOf(PropTypes.shape({
89 description: PropTypes.string,
90 rulesets: PropTypes.shape({
92 title: PropTypes.string,
96 export default Detail;