From 4776b16cd941b850eb2b7f0a031c3955b1cf7e3c Mon Sep 17 00:00:00 2001 From: Kechicode <186776112+Kechicode@users.noreply.github.com> Date: Wed, 11 Dec 2024 14:40:22 +0800 Subject: [PATCH] fix(ArticleDetail): Add announcement flag to campaign detail routing --- src/common/utils/route.ts | 3 ++- src/views/ArticleDetail/Header/gql.ts | 3 +++ src/views/ArticleDetail/Header/index.tsx | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common/utils/route.ts b/src/common/utils/route.ts index e55ae0d234..d815ab0930 100644 --- a/src/common/utils/route.ts +++ b/src/common/utils/route.ts @@ -94,6 +94,7 @@ type ToPathArgs = campaign: CampaignArgs stage?: CampaignStageArgs featured?: boolean + announcement?: boolean } | { page: 'userProfile' | 'userCollections' @@ -247,7 +248,7 @@ export const toPath = ( href = `${href}?type=${args.stage.id}` } else if (args.featured) { href = `${href}?type=featured` - } else { + } else if (args.announcement) { href = `${href}?type=announcement` } break diff --git a/src/views/ArticleDetail/Header/gql.ts b/src/views/ArticleDetail/Header/gql.ts index 1bbed3ca0c..ab30f43887 100644 --- a/src/views/ArticleDetail/Header/gql.ts +++ b/src/views/ArticleDetail/Header/gql.ts @@ -13,6 +13,9 @@ export const fragments = { nameZhHant: name(input: { language: zh_hant }) nameZhHans: name(input: { language: zh_hans }) nameEn: name(input: { language: en }) + announcements { + id + } } } stage { diff --git a/src/views/ArticleDetail/Header/index.tsx b/src/views/ArticleDetail/Header/index.tsx index 47d1077a00..fec515b8b7 100644 --- a/src/views/ArticleDetail/Header/index.tsx +++ b/src/views/ArticleDetail/Header/index.tsx @@ -22,6 +22,9 @@ const Header = ({ article }: HeaderProps) => { const campaign = article.campaigns[0]?.campaign const campaignStage = article.campaigns[0]?.stage const { lang } = useContext(LanguageContext) + const isAnnouncement = article.campaigns[0]?.campaign?.announcements?.some( + (announcement: { id: string }) => announcement.id === article.id + ) return (
@@ -36,6 +39,7 @@ const Header = ({ article }: HeaderProps) => { page: 'campaignDetail', campaign, stage: campaignStage || undefined, + announcement: isAnnouncement, }).href } onClick={() => {