File tree 3 files changed +9
-11
lines changed
3 files changed +9
-11
lines changed Original file line number Diff line number Diff line change 12
12
$ : pageIndex = parseInt ($page .url .searchParams .get (" p" ) ?? " 0" );
13
13
$ : pageIndexes = getPageIndexes (pageIndex , numTotalPages );
14
14
15
- function getHref(pageIdx : number ) {
16
- const newUrl = new URL ($page . url );
15
+ function getHref(url : URL | string , pageIdx : number ) {
16
+ const newUrl = new URL (url );
17
17
newUrl .searchParams .set (" p" , pageIdx .toString ());
18
18
return newUrl .toString ();
19
19
}
66
66
>
67
67
<li >
68
68
<PaginationArrow
69
- href ={getHref (pageIndex - 1 )}
69
+ href ={getHref ($page . url , pageIndex - 1 )}
70
70
direction =" previous"
71
71
isDisabled ={pageIndex - 1 < 0 }
72
72
/>
81
81
: ''}
82
82
"
83
83
class:pointer-events-none ={pageIdx === ELLIPSIS_IDX || pageIndex === pageIdx }
84
- href ={getHref (pageIdx )}
84
+ href ={getHref ($page . url , pageIdx )}
85
85
>
86
86
{pageIdx === ELLIPSIS_IDX ? " ..." : pageIdx + 1 }
87
87
</a >
88
88
</li >
89
89
{/each }
90
90
<li >
91
91
<PaginationArrow
92
- href ={getHref (pageIndex + 1 )}
92
+ href ={getHref ($page . url , pageIndex + 1 )}
93
93
direction =" next"
94
94
isDisabled ={pageIndex + 1 >= numTotalPages }
95
95
/>
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export const load = async ({ url }) => {
32
32
33
33
return {
34
34
assistants : JSON . parse ( JSON . stringify ( assistants ) ) as Array < Assistant > ,
35
+ selectedModel : modelId ?? "" ,
35
36
numTotalItems,
36
37
numItemsPerPage : NUM_PER_PAGE ,
37
38
} ;
Original file line number Diff line number Diff line change 14
14
15
15
export let data: PageData ;
16
16
17
- let selectedModel = $page .url .searchParams .get (" modelId" ) ?? " " ;
18
-
19
17
const onModelChange = (e : Event ) => {
20
18
const newUrl = new URL ($page .url );
21
- if ((e .target as HTMLSelectElement ).value === " " ) {
22
- newUrl .searchParams .delete (" modelId" );
23
- } else {
19
+ newUrl .search = " " ; // clear searchParams (such as "p" for pagination)
20
+ if ((e .target as HTMLSelectElement ).value ) {
24
21
newUrl .searchParams .set (" modelId" , (e .target as HTMLSelectElement ).value );
25
22
}
26
23
goto (newUrl );
66
63
<div class =" mt-6 flex justify-between gap-2 max-sm:flex-col sm:items-center" >
67
64
<select
68
65
class =" mt-1 h-[34px] rounded-lg border border-gray-300 bg-gray-50 px-2 text-sm text-gray-900 focus:border-blue-700 focus:ring-blue-700 dark:border-gray-600 dark:bg-gray-700 dark:text-white dark:placeholder-gray-400"
69
- bind:value ={selectedModel }
66
+ bind:value ={data . selectedModel }
70
67
on:change ={onModelChange }
71
68
>
72
69
<option value =" " >All models</option >
You can’t perform that action at this time.
0 commit comments