Skip to content

Commit 84334ad

Browse files
committed
Sort JetStream accounts by ID (closes #3)
1 parent 074385e commit 84334ad

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/components/dashboard/jetstream/AccountTabs.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { mergeProps, For, Show } from 'solid-js';
1+
import { mergeProps, createMemo, For, Show } from 'solid-js';
22

33
import type { AccountDetail } from '~/types';
44

@@ -14,6 +14,11 @@ interface Props {
1414
export default function AccountTabs(props: Props) {
1515
props = mergeProps({ numStreams: true } satisfies Partial<Props>, props);
1616

17+
const accounts = createMemo(() =>
18+
// Sort alphabetically by the account ID.
19+
props.accounts.sort((a, b) => a.id.localeCompare(b.id))
20+
);
21+
1722
return (
1823
<div>
1924
<div class="sm:hidden p-4 border-b border-gray-200 dark:border-white/10">
@@ -29,7 +34,7 @@ export default function AccountTabs(props: Props) {
2934
class="block w-full rounded-md border-gray-300 mt-2 py-2 pl-3 pr-10 text-base focus:border-sky-500 focus:outline-none focus:ring-sky-500 sm:text-sm dark:bg-white/5 dark:text-white dark:border-none dark:ring-1 dark:ring-inset dark:ring-white/10 dark:focus:ring-2 [&_*]:text-black"
3035
onChange={(e) => props.onChange(e.target.value)}
3136
>
32-
<For each={props.accounts}>
37+
<For each={accounts()}>
3338
{(acc) => (
3439
<option selected={props.active === acc.id} value={acc.id}>
3540
{acc.name}
@@ -48,7 +53,7 @@ export default function AccountTabs(props: Props) {
4853
<span class="text-gray-900 dark:text-white flex whitespace-nowrap py-6 px-1 text-sm font-medium">
4954
Account
5055
</span>
51-
<For each={props.accounts}>
56+
<For each={accounts()}>
5257
{(acc) => (
5358
<a
5459
href="#"

0 commit comments

Comments
 (0)