/*! * Copyright (c) 2024 PLANKA Software GmbH * Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md */ import React, { useMemo } from 'react'; import PropTypes from 'prop-types'; import classNames from 'classnames'; import { useSelector } from 'react-redux'; import { useTranslation } from 'react-i18next'; import { Item as GalleryItem } from 'react-photoswipe-gallery'; import selectors from '../../../selectors'; import Encodings from '../../../constants/Encodings'; import { AttachmentTypes } from '../../../constants/Enums'; import ItemContent from './ItemContent'; import ContentViewer from './ContentViewer'; import styles from './Item.module.scss'; const Item = React.memo(({ id, isVisible }) => { const selectAttachmentById = useMemo(() => selectors.makeSelectAttachmentById(), []); const attachment = useSelector((state) => selectAttachmentById(state, id)); const [t] = useTranslation(); if (!attachment.isPersisted) { return ; } let galleryItemProps; if (attachment.type === AttachmentTypes.FILE) { if (attachment.data.image) { galleryItemProps = attachment.data.image; } else { let content; switch (attachment.data.mimeType) { case 'application/pdf': content = ( // eslint-disable-next-line jsx-a11y/alt-text ); break; case 'audio/mpeg': case 'audio/wav': case 'audio/ogg': case 'audio/opus': case 'audio/mp4': case 'audio/x-aac': content = ( // eslint-disable-next-line jsx-a11y/media-has-caption