Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: list bals by updated_at #957

Merged
merged 2 commits into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading