fix(web): request templates banners on the templates page

This commit is contained in:
CodingOnStar 2026-08-17 14:14:30 +08:00
parent 24b977da27
commit fab9d78c48
4 changed files with 23 additions and 4 deletions

View File

@ -272,7 +272,7 @@ const bannerListContract = base
.input(
type<{
query: {
page: 'plugins'
page: 'plugins' | 'templates'
language: string
}
}>(),

View File

@ -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',
},
})
})
})

View File

@ -136,10 +136,13 @@ const normalizePluginBanners = (response: unknown): PluginBanner[] => {
.sort((a, b) => a.sort - b.sort)
}
export const fetchPluginBanners = async (language: string): Promise<PluginBanner[]> => {
export const fetchPluginBanners = async (
language: string,
page: 'plugins' | 'templates' = 'plugins',
): Promise<PluginBanner[]> => {
const response = await marketplaceClient.banners.list({
query: {
page: 'plugins',
page,
language,
},
})

View File

@ -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' }),