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

Improve error handling in the UI #105

Merged
merged 2 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"eslint-plugin-react-hooks": "^5.1.0-rc.0",
"eslint-plugin-react-refresh": "^0.4.11",
"globals": "^15.9.0",
"ky": "^1.7.1",
"lunr": "^2.3.9",
"openapi-typescript": "^5.4.2",
"postcss": "^8.4.41",
Expand Down
9 changes: 3 additions & 6 deletions frontend/src/q.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
import { queryOptions } from "@tanstack/react-query";
import lunr from "lunr";
import { api } from "./query";

export const getSearchIndexQuery = () =>
queryOptions({
queryKey: ["search-index"],
queryFn: async () => {
const response = await fetch(
`${import.meta.env.VITE_DATA_API_URL}/search.json`,
);
const data = await api(`search.json`).json();

const res = await response.json();

return lunr.Index.load(res);
return lunr.Index.load(data);
},
});
3 changes: 3 additions & 0 deletions frontend/src/query.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { QueryClient } from "@tanstack/react-query";
import ky from "ky";

export const queryClient = new QueryClient({
defaultOptions: {
Expand All @@ -7,3 +8,5 @@ export const queryClient = new QueryClient({
},
},
});

export const api = ky.create({ prefixUrl: import.meta.env.VITE_DATA_API_URL });
Loading
Loading