@@ -31,13 +31,16 @@ import {
3131import ErrorBoundary from '@/ui/error'
3232import HelpTooltip from '@/ui/help-tooltip'
3333import { SIDEBAR_TRANSITION_CLASSNAMES } from '@/ui/primitives/sidebar'
34+ import {
35+ TEMPLATES_DEFAULT_SORT_BASE ,
36+ TEMPLATES_DEFAULT_SORT_DESC ,
37+ TEMPLATES_PAGE_SIZE ,
38+ } from './constants'
3439import TemplatesHeader from './header'
3540import { useTemplateTableStore } from './stores/table-store'
3641import { TemplatesTableBody as TableBody } from './table-body'
3742import { fallbackData , templatesTableConfig , useColumns } from './table-config'
3843
39- const PAGE_SIZE = 50
40-
4144const COLUMN_TO_SORT_BASE : Record < string , string > = {
4245 name : 'name' ,
4346 cpuCount : 'cpu_count' ,
@@ -59,9 +62,12 @@ export default function TemplatesTable() {
5962 // Derive the single server sort token from the active sort column + direction.
6063 const sortColumn = sorting [ 0 ]
6164 const sortBase =
62- ( sortColumn && COLUMN_TO_SORT_BASE [ sortColumn . id ] ) ?? 'created_at'
63- const sort =
64- `${ sortBase } _${ sortColumn ?. desc === false ? 'asc' : 'desc' } ` as TemplatesSort
65+ ( sortColumn && COLUMN_TO_SORT_BASE [ sortColumn . id ] ) ??
66+ TEMPLATES_DEFAULT_SORT_BASE
67+ const isDesc = sortColumn
68+ ? sortColumn . desc !== false
69+ : TEMPLATES_DEFAULT_SORT_DESC
70+ const sort = `${ sortBase } _${ isDesc ? 'desc' : 'asc' } ` as TemplatesSort
6571
6672 const {
6773 data,
@@ -74,7 +80,7 @@ export default function TemplatesTable() {
7480 trpc . templates . getTemplates . infiniteQueryOptions (
7581 {
7682 teamSlug,
77- limit : PAGE_SIZE ,
83+ limit : TEMPLATES_PAGE_SIZE ,
7884 cpuCount,
7985 memoryMB,
8086 public : isPublic ,
0 commit comments