diff --git a/apps/admin-x-settings/src/components/settings/site/recommendations/IncomingRecommendationList.tsx b/apps/admin-x-settings/src/components/settings/site/recommendations/IncomingRecommendationList.tsx index f6dc5f9931..2f98a0aae8 100644 --- a/apps/admin-x-settings/src/components/settings/site/recommendations/IncomingRecommendationList.tsx +++ b/apps/admin-x-settings/src/components/settings/site/recommendations/IncomingRecommendationList.tsx @@ -1,5 +1,6 @@ import NoValueLabel from '../../../../admin-x-ds/global/NoValueLabel'; import React from 'react'; +import RecommendationIcon from './RecommendationIcon'; import Table from '../../../../admin-x-ds/global/Table'; import TableCell from '../../../../admin-x-ds/global/TableCell'; import TableRow from '../../../../admin-x-ds/global/TableRow'; @@ -23,7 +24,7 @@ const IncomingRecommendationItem: React.FC<{mention: Mention}> = ({mention}) =>
- {mention.source_favicon && {mention.source_title} + {mention.source_title || mention.source_site_title || cleanedSource}
{mention.source_excerpt || cleanedSource} diff --git a/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationIcon.tsx b/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationIcon.tsx new file mode 100644 index 0000000000..5359a3bcc4 --- /dev/null +++ b/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationIcon.tsx @@ -0,0 +1,24 @@ +/* eslint-disable camelcase */ +import React, {useState} from 'react'; + +interface Props { + title: string, + favicon?: string | null, + featured_image?: string | null +} + +const RecommendationIcon: React.FC = ({title, favicon, featured_image}) => { + const [icon, setIcon] = useState(favicon || featured_image || null); + + const clearIcon = () => { + setIcon(null); + }; + + if (!icon) { + return null; + } + + return ({title}); +}; + +export default RecommendationIcon; diff --git a/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationList.tsx b/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationList.tsx index 36ba720ba5..b377d1bf93 100644 --- a/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationList.tsx +++ b/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationList.tsx @@ -3,6 +3,7 @@ import ConfirmationModal from '../../../../admin-x-ds/global/modal/ConfirmationM import NiceModal from '@ebay/nice-modal-react'; import NoValueLabel from '../../../../admin-x-ds/global/NoValueLabel'; import React from 'react'; +import RecommendationIcon from './RecommendationIcon'; import Table from '../../../../admin-x-ds/global/Table'; import TableCell from '../../../../admin-x-ds/global/TableCell'; import TableRow from '../../../../admin-x-ds/global/TableRow'; @@ -43,7 +44,7 @@ const RecommendationItem: React.FC<{recommendation: Recommendation}> = ({recomme
- {recommendation.favicon && {recommendation.title}} + {recommendation.title}
{recommendation.reason || 'No reason added'} diff --git a/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationReasonForm.tsx b/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationReasonForm.tsx index 449237b2f2..c1cc33d99c 100644 --- a/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationReasonForm.tsx +++ b/apps/admin-x-settings/src/components/settings/site/recommendations/RecommendationReasonForm.tsx @@ -1,6 +1,7 @@ import Form from '../../../../admin-x-ds/global/form/Form'; import Heading from '../../../../admin-x-ds/global/Heading'; import React from 'react'; +import RecommendationIcon from './RecommendationIcon'; import TextArea from '../../../../admin-x-ds/global/form/TextArea'; import TextField from '../../../../admin-x-ds/global/form/TextField'; import {EditOrAddRecommendation, Recommendation} from '../../../../api/recommendations'; @@ -21,7 +22,7 @@ const RecommendationReasonForm: React.FCPreview
- {(formState.favicon || formState.featured_image) && {formState.title}} + {formState.title}
{formState.url} diff --git a/apps/portal/src/components/pages/RecommendationsPage.js b/apps/portal/src/components/pages/RecommendationsPage.js index 7e73379015..cdfc4a8233 100644 --- a/apps/portal/src/components/pages/RecommendationsPage.js +++ b/apps/portal/src/components/pages/RecommendationsPage.js @@ -49,15 +49,29 @@ const shuffleRecommendations = (array) => { return array; }; +const RecommendationIcon = ({title, favicon, featuredImage}) => { + const [icon, setIcon] = useState(favicon || featuredImage); + + const hideIcon = () => { + setIcon(null); + }; + + if (!icon) { + return null; + } + + return ({title}); +}; + const RecommendationItem = (recommendation) => { const {t} = useContext(AppContext); - const {title, url, reason, favicon, one_click_subscribe: oneClickSubscribe} = recommendation; + const {title, url, reason, favicon, one_click_subscribe: oneClickSubscribe, featured_image: featuredImage} = recommendation; return (
- {favicon && {title}/} +

{title}

{reason &&

{reason}

}