Skip to content

Commit

Permalink
fix(ArticleDetail): Add announcement flag to campaign detail routing
Browse files Browse the repository at this point in the history
  • Loading branch information
Kechicode committed Dec 11, 2024
1 parent b1684b3 commit 4776b16
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/common/utils/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ type ToPathArgs =
campaign: CampaignArgs
stage?: CampaignStageArgs
featured?: boolean
announcement?: boolean
}
| {
page: 'userProfile' | 'userCollections'
Expand Down Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions src/views/ArticleDetail/Header/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 4 additions & 0 deletions src/views/ArticleDetail/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<section className={styles.header}>
Expand All @@ -36,6 +39,7 @@ const Header = ({ article }: HeaderProps) => {
page: 'campaignDetail',
campaign,
stage: campaignStage || undefined,
announcement: isAnnouncement,
}).href
}
onClick={() => {
Expand Down

0 comments on commit 4776b16

Please sign in to comment.