Skip to content

Commit

Permalink
fix: list bals by updated_at
Browse files Browse the repository at this point in the history
  • Loading branch information
fufeck committed Sep 30, 2024
1 parent 42c901f commit 00cacbb
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions components/user-bases-locales.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Pane, Spinner, Button, PlusIcon } from "evergreen-ui";
import LocalStorageContext from "@/contexts/local-storage";
import HiddenBal from "@/components/hidden-bal";
import BasesLocalesList from "@/components/bases-locales-list";
import { BasesLocalesService } from "@/lib/openapi";
import { BaseLocale, BasesLocalesService } from "@/lib/openapi";

function UserBasesLocales() {
const { balAccess, hiddenBal, getHiddenBal } =
Expand All @@ -21,7 +21,7 @@ function UserBasesLocales() {
Object.keys(balAccess),
(id) => !getHiddenBal(id)
);
const basesLocales = await Promise.all(
const basesLocales: BaseLocale[] = await Promise.all(
map(balsToLoad, async (id) => {
const token = balAccess[id];
try {
Expand All @@ -40,7 +40,13 @@ function UserBasesLocales() {
})
);

const findedBasesLocales = basesLocales.filter((bal) => Boolean(bal));
const findedBasesLocales = basesLocales
.filter((bal) => Boolean(bal))
.sort((balA, balB) => {
const dateA = new Date(balA?.updatedAt);
const dateB = new Date(balB?.updatedAt);
return dateB.getTime() - dateA.getTime();
});
setBasesLocales(findedBasesLocales);
}

Expand Down

0 comments on commit 00cacbb

Please sign in to comment.