diff --git a/apps/remix/app/routes/_authenticated+/t.$teamUrl+/templates._index.tsx b/apps/remix/app/routes/_authenticated+/t.$teamUrl+/templates._index.tsx index 236b5c5f6..8e978b930 100644 --- a/apps/remix/app/routes/_authenticated+/t.$teamUrl+/templates._index.tsx +++ b/apps/remix/app/routes/_authenticated+/t.$teamUrl+/templates._index.tsx @@ -41,6 +41,8 @@ export default function TemplatesPage() { const [findTemplateSearchParams] = useQueryStates(templatesSearchParams, { history: 'push', }); + const page = findTemplateSearchParams.page || undefined; + const perPage = findTemplateSearchParams.perPage || undefined; const isOrgView = findTemplateSearchParams.view === 'organisation'; const showOrgFilter = organisation.type !== OrganisationType.PERSONAL; @@ -62,8 +64,8 @@ export default function TemplatesPage() { const teamTemplatesQuery = trpc.template.findTemplates.useQuery( { - page: findTemplateSearchParams.page ?? undefined, - perPage: findTemplateSearchParams.perPage ?? undefined, + page, + perPage, folderId, }, { @@ -73,8 +75,8 @@ export default function TemplatesPage() { const orgTemplatesQuery = trpc.template.findOrganisationTemplates.useQuery( { - page: findTemplateSearchParams.page ?? undefined, - perPage: findTemplateSearchParams.perPage ?? undefined, + page, + perPage, }, { enabled: isOrgView, diff --git a/packages/app-tests/e2e/templates/organisation-templates.spec.ts b/packages/app-tests/e2e/templates/organisation-templates.spec.ts index dc846a067..77d9a6004 100644 --- a/packages/app-tests/e2e/templates/organisation-templates.spec.ts +++ b/packages/app-tests/e2e/templates/organisation-templates.spec.ts @@ -149,6 +149,18 @@ test.describe('Organisation Templates - Listing', () => { await expect(page.getByText(orgTemplate.title)).toBeVisible(); }); + test('should use default pagination when URL values are zero', async ({ page }) => { + const { memberB, teamB, orgTemplate } = await seedOrgTemplateScenario(); + + await apiSignin({ + page, + email: memberB.email, + redirectPath: `/t/${teamB.url}/templates?view=organisation&page=0&perPage=0`, + }); + + await expect(page.getByText(orgTemplate.title)).toBeVisible(); + }); + test('should not show private templates from other teams under the organisation view', async ({ page }) => { const { ownerA, teamA, memberB, teamB } = await seedOrgTemplateScenario();