/*! * 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 { Icon } from 'semantic-ui-react'; import selectors from '../../../selectors'; import markdownToText from '../../../utils/markdown-to-text'; import { BoardViews } from '../../../constants/Enums'; import LabelChip from '../../labels/LabelChip'; import CustomFieldValueChip from '../../custom-field-values/CustomFieldValueChip'; import styles from './StoryContent.module.scss'; const StoryContent = React.memo(({ cardId }) => { const selectCardById = useMemo(() => selectors.makeSelectCardById(), []); const selectListById = useMemo(() => selectors.makeSelectListById(), []); const selectLabelIdsByCardId = useMemo(() => selectors.makeSelectLabelIdsByCardId(), []); const selectAttachmentsTotalByCardId = useMemo( () => selectors.makeSelectAttachmentsTotalByCardId(), [], ); const selectShownOnFrontOfCardCustomFieldValueIdsByCardId = useMemo( () => selectors.makeSelectShownOnFrontOfCardCustomFieldValueIdsByCardId(), [], ); const selectNotificationsTotalByCardId = useMemo( () => selectors.makeSelectNotificationsTotalByCardId(), [], ); const selectAttachmentById = useMemo(() => selectors.makeSelectAttachmentById(), []); const card = useSelector((state) => selectCardById(state, cardId)); const list = useSelector((state) => selectListById(state, card.listId)); const labelIds = useSelector((state) => selectLabelIdsByCardId(state, cardId)); const attachmentsTotal = useSelector((state) => selectAttachmentsTotalByCardId(state, cardId)); const customFieldValueIds = useSelector((state) => selectShownOnFrontOfCardCustomFieldValueIdsByCardId(state, cardId), ); const notificationsTotal = useSelector((state) => selectNotificationsTotalByCardId(state, cardId), ); const listName = useSelector((state) => { if (!list.name) { return null; } const { view } = selectors.selectCurrentBoard(state); if (view === BoardViews.KANBAN) { return null; } return list.name; }); const coverUrl = useSelector((state) => { const attachment = selectAttachmentById(state, card.coverAttachmentId); return attachment && attachment.data.thumbnailUrls.outside360; }); const descriptionText = useMemo( () => card.description && markdownToText(card.description), [card.description], ); return ( <> {coverUrl && (