Skip to content

Commit

Permalink
fix(campaign): correct article label for non-announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
gitwoz committed Dec 11, 2024
1 parent be87318 commit 8b80d28
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/views/CampaignDetail/ArticleFeeds/MainFeed/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const CAMPAIGN_ARTICLES_PUBLIC = gql`
edges {
cursor
featured
announcement
node {
id
campaigns {
Expand Down
22 changes: 14 additions & 8 deletions src/views/CampaignDetail/ArticleFeeds/MainFeed/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,21 @@ const getArticleStage = (article: CampaignArticlesPublicQueryArticle) => {
return stage
}

const getArticleStageName = (
const getLabel = (
article: CampaignArticlesPublicQueryArticle,
lang: string
lang: string,
announcement: boolean
) => {
const stage = getArticleStage(article)

// announcement if nullish
if (!stage) {
if (announcement) {
return <FormattedMessage defaultMessage="Announcement" id="Sj+TN8" />
}

if (!stage) {
return ''
}

return stage[
`name${lang === 'en' ? 'En' : lang === 'zh-Hans' ? 'ZhHans' : 'ZhHant'}`
]
Expand Down Expand Up @@ -218,20 +222,22 @@ const MainFeed = ({ feedType, camapign }: MainFeedProps) => {
return (
<InfiniteScroll hasNextPage={pageInfo.hasNextPage} loadMore={loadMore} eof>
<List>
{edges.map(({ node, featured }, i) => (
{edges.map(({ node, featured, announcement }, i) => (
<List.Item key={`${feedType}:${i}`}>
<ArticleDigestFeed
article={node}
label={
<>
{(isAll || isFeatured) && (
{(isAll ||
isFeatured ||
getLabel(node, lang, announcement)) && (
<span
className={[
styles.articleLabel,
getArticleStage(node)?.id ? '' : styles.announcement,
announcement ? styles.announcement : '',
].join(' ')}
>
{getArticleStageName(node, lang)}
{getLabel(node, lang, announcement)}
</span>
)}
{!isFeatured && featured && <FeaturedLabel />}
Expand Down

0 comments on commit 8b80d28

Please sign in to comment.