1 import PropTypes from 'prop-types';
2 import React from 'react';
3 import { Button } from 'react-bootstrap';
4 import { useTranslation } from 'react-i18next';
5 import { Link, useSearchParams } from 'react-router-dom';
7 import { useOpenSeadragon } from './OpenSeadragon';
8 import Icon from '../common/Icon';
9 import Rulesets from '../techniques/Rulesets';
16 } from '../../helpers/Technique';
17 import i18n from '../../i18n';
19 const Item = ({ pin }) => {
20 const { viewer } = useOpenSeadragon();
21 const [, setSearchParams] = useSearchParams();
22 const { t } = useTranslation();
24 const goToLocation = React.useCallback(pin => {
25 setSearchParams({ x: pin.x, y: pin.y, z: 4 });
26 if (viewer && viewer.element) {
27 viewer.element.scrollIntoView();
31 return <li className="d-flex align-items-start justify-content-between">
32 <div className="flex-grow-1">
33 {pin.technique.type === 'location' ? <>
34 <h2>{getTranslation(pin.technique, 'title', i18n.language)}</h2>
35 <p>{getTranslation(pin.technique, 'short', i18n.language)}</p>
36 {hasRelations(pin.technique, 'related') ?
37 sorted(getRelations(pin.technique, 'related')).map(r =>
39 className="d-flex align-items-start justify-content-between"
42 <div className="me-auto">
44 <Link to={getLink(r)}>
45 {getTranslation(r, 'title', i18n.language)}
48 <p>{getTranslation(r, 'short', i18n.language)}</p>
51 <Rulesets technique={r} />
56 </> : <div className="d-flex align-items-start justify-content-between">
57 <div className="flex-grow-1">
59 <Link to={getLink(pin.technique)}>
60 {getTranslation(pin.technique, 'title', i18n.language)}
63 <p>{getTranslation(pin.technique, 'short', i18n.language)}</p>
65 {pin.technique.rulesets ?
66 <Rulesets technique={pin.technique} />
72 onClick={() => goToLocation(pin)}
73 title={t('map.goToLocation')}
74 variant="outline-secondary"
76 <Icon.CROSSHAIRS title="" />
82 pin: PropTypes.shape({
83 technique: PropTypes.shape({
84 rulesets: PropTypes.shape({
86 type: PropTypes.string,