From fab9d78c4828f74caef77dc28d22dc1ecc266fb4 Mon Sep 17 00:00:00 2001 From: CodingOnStar Date: Mon, 17 Aug 2026 14:14:30 +0800 Subject: [PATCH] fix(web): request templates banners on the templates page --- packages/contracts/marketplace.ts | 2 +- .../plugins/marketplace/home/banners.spec.ts | 16 ++++++++++++++++ .../plugins/marketplace/home/banners.ts | 7 +++++-- .../plugins/marketplace/templates/index.tsx | 2 +- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/packages/contracts/marketplace.ts b/packages/contracts/marketplace.ts index acd017b3ba7..0e2f86b0729 100644 --- a/packages/contracts/marketplace.ts +++ b/packages/contracts/marketplace.ts @@ -272,7 +272,7 @@ const bannerListContract = base .input( type<{ query: { - page: 'plugins' + page: 'plugins' | 'templates' language: string } }>(), diff --git a/web/app/components/plugins/marketplace/home/banners.spec.ts b/web/app/components/plugins/marketplace/home/banners.spec.ts index 65dfc1f4581..801ec7ada41 100644 --- a/web/app/components/plugins/marketplace/home/banners.spec.ts +++ b/web/app/components/plugins/marketplace/home/banners.spec.ts @@ -197,4 +197,20 @@ describe('fetchPluginBanners', () => { await expect(fetchPluginBanners('en-US')).resolves.toEqual([]) await expect(fetchPluginBanners('en-US')).resolves.toEqual([]) }) + + it('requests templates banners when fetching for the templates page', async () => { + mockedListBanners.mockResolvedValue({ + data: { + banners: [], + }, + }) + + await expect(fetchPluginBanners('en-US', 'templates')).resolves.toEqual([]) + expect(mockedListBanners).toHaveBeenCalledWith({ + query: { + page: 'templates', + language: 'en-US', + }, + }) + }) }) diff --git a/web/app/components/plugins/marketplace/home/banners.ts b/web/app/components/plugins/marketplace/home/banners.ts index dd04fda278d..05730f5cea9 100644 --- a/web/app/components/plugins/marketplace/home/banners.ts +++ b/web/app/components/plugins/marketplace/home/banners.ts @@ -136,10 +136,13 @@ const normalizePluginBanners = (response: unknown): PluginBanner[] => { .sort((a, b) => a.sort - b.sort) } -export const fetchPluginBanners = async (language: string): Promise => { +export const fetchPluginBanners = async ( + language: string, + page: 'plugins' | 'templates' = 'plugins', +): Promise => { const response = await marketplaceClient.banners.list({ query: { - page: 'plugins', + page, language, }, }) diff --git a/web/app/components/plugins/marketplace/templates/index.tsx b/web/app/components/plugins/marketplace/templates/index.tsx index eb0909b9325..588d966fb3d 100644 --- a/web/app/components/plugins/marketplace/templates/index.tsx +++ b/web/app/components/plugins/marketplace/templates/index.tsx @@ -118,7 +118,7 @@ export async function EmbeddedTemplatesMarketplace({ sortBy, sortOrder, }), - fetchPluginBanners(locale).catch(() => []), + fetchPluginBanners(locale, 'templates').catch(() => []), ]) const categoryLabels = { all: tPlugin(($) => $['category.all'], { ns: 'plugin' }),