Skip to content

Commit

Permalink
chore: update PWA minor dependencies (#479)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentchalamon authored Nov 9, 2024
1 parent 1ec7484 commit 971036c
Show file tree
Hide file tree
Showing 44 changed files with 1,311 additions and 1,457 deletions.
2 changes: 1 addition & 1 deletion pwa/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "next/core-web-vitals"
"extends": ["next/core-web-vitals"]
}
10 changes: 7 additions & 3 deletions pwa/app/auth.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { type TokenSet } from "@auth/core/types";
import NextAuth, { type Session as DefaultSession, type User } from "next-auth";
import {type TokenSet} from "@auth/core/types";
import NextAuth, {type Session as DefaultSession, type User} from "next-auth";
import KeycloakProvider from "next-auth/providers/keycloak";

import { NEXT_PUBLIC_OIDC_CLIENT_ID, NEXT_PUBLIC_OIDC_SERVER_URL, NEXT_PUBLIC_OIDC_SERVER_URL_INTERNAL } from "../config/keycloak";
import {
NEXT_PUBLIC_OIDC_CLIENT_ID,
NEXT_PUBLIC_OIDC_SERVER_URL,
NEXT_PUBLIC_OIDC_SERVER_URL_INTERNAL
} from "../config/keycloak";

export interface Session extends DefaultSession {
error?: "RefreshAccessTokenError"
Expand Down
18 changes: 9 additions & 9 deletions pwa/app/bookmarks/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { type Metadata } from "next";
import { redirect } from "next/navigation";
import {type Metadata} from "next";
import {redirect} from "next/navigation";

import { List, type Props as ListProps } from "../../components/bookmark/List";
import { type Bookmark } from "../../types/Bookmark";
import { type PagedCollection } from "../../types/collection";
import { type FetchResponse, fetchApi } from "../../utils/dataAccess";
import { type Session, auth } from "../auth";
import {List, type Props as ListProps} from "../../components/bookmark/List";
import {type Bookmark} from "../../types/Bookmark";
import {type PagedCollection} from "../../types/collection";
import {fetchApi, type FetchResponse} from "../../utils/dataAccess";
import {auth, type Session} from "../auth";

interface Query extends URLSearchParams {
page?: number|string|null;
Expand All @@ -32,7 +32,7 @@ async function getServerSideProps({ page = 1 }: Query, session: Session): Promis
return { data: null, hubURL: null, page: Number(page) };
}

export default async function Page({ searchParams }: { searchParams: Query }) {
export default async function Page({ searchParams }: { searchParams: Promise<Query> }) {
// @ts-ignore
const session: Session|null = await auth();
if (!session || session?.error === "RefreshAccessTokenError") {
Expand All @@ -41,7 +41,7 @@ export default async function Page({ searchParams }: { searchParams: Query }) {
redirect("/api/auth/signin?callbackUrl=/bookmarks");
}

const props = await getServerSideProps(searchParams, session);
const props = await getServerSideProps(await searchParams, session);

return <List {...props}/>;
}
18 changes: 9 additions & 9 deletions pwa/app/books/[id]/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { type Metadata } from "next";
import { notFound } from "next/navigation";
import {type Metadata} from "next";
import {notFound} from "next/navigation";

import { Show, type Props as ShowProps } from "../../../../components/book/Show";
import { Book } from "../../../../types/Book";
import { type FetchResponse, fetchApi } from "../../../../utils/dataAccess";
import { type Session, auth } from "../../../auth";
import {type Props as ShowProps, Show} from "../../../../components/book/Show";
import {Book} from "../../../../types/Book";
import {fetchApi, type FetchResponse} from "../../../../utils/dataAccess";
import {auth, type Session} from "../../../auth";

interface Props {
params: { id: string };
params: Promise<{ id: string }>;
}

export async function generateMetadata({ params }: Props): Promise<Metadata|undefined> {
const id = params.id;
const id = (await params).id;
try {
const response: FetchResponse<Book> | undefined = await fetchApi(`/books/${id}`, {
// next: { revalidate: 3600 },
Expand Down Expand Up @@ -56,7 +56,7 @@ async function getServerSideProps(id: string, session: Session|null): Promise<Sh
export default async function Page({ params }: Props) {
// @ts-ignore
const session: Session|null = await auth();
const props = await getServerSideProps(params.id, session);
const props = await getServerSideProps((await params).id, session);
if (!props) {
notFound();
}
Expand Down
16 changes: 8 additions & 8 deletions pwa/app/books/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { type Metadata } from "next";
import {type Metadata} from "next";

import {auth, type Session} from "../auth";
import { List, type Props as ListProps } from "../../components/book/List";
import { type Book } from "../../types/Book";
import { type PagedCollection } from "../../types/collection";
import { type FetchResponse, fetchApi } from "../../utils/dataAccess";
import { type FiltersProps, buildUriFromFilters } from "../../utils/book";
import {List, type Props as ListProps} from "../../components/book/List";
import {type Book} from "../../types/Book";
import {type PagedCollection} from "../../types/collection";
import {fetchApi, type FetchResponse} from "../../utils/dataAccess";
import {buildUriFromFilters, type FiltersProps} from "../../utils/book";

interface Query extends URLSearchParams {
page?: number|string|undefined;
Expand All @@ -17,7 +17,7 @@ interface Query extends URLSearchParams {
}

interface Props {
searchParams: Query;
searchParams: Promise<Query>;
}

async function getServerSideProps(query: Query, session: Session|null): Promise<ListProps> {
Expand Down Expand Up @@ -66,7 +66,7 @@ export const metadata: Metadata = {
export default async function Page({ searchParams }: Props) {
// @ts-ignore
const session: Session|null = await auth();
const props = await getServerSideProps(searchParams, session);
const props = await getServerSideProps(await searchParams, session);

return <List {...props}/>;
}
12 changes: 6 additions & 6 deletions pwa/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import type { Metadata } from "next";
import { type ReactNode } from "react";
import { SessionProvider } from "next-auth/react";
import type {Metadata} from "next";
import {type ReactNode} from "react";
import {SessionProvider} from "next-auth/react";
import "@fontsource/poppins";
import "@fontsource/poppins/600.css";
import "@fontsource/poppins/700.css";

import { Layout } from "../components/common/Layout";
import {Layout} from "../components/common/Layout";
import "../styles/globals.css";
import { Providers } from "./providers";
import { auth } from "./auth";
import {Providers} from "./providers";
import {auth} from "./auth";

export const metadata: Metadata = {
title: 'Welcome to API Platform!',
Expand Down
8 changes: 4 additions & 4 deletions pwa/app/providers.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use client";

import { type ReactNode, useState } from "react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { ReactQueryStreamedHydration } from "@tanstack/react-query-next-experimental";
import {type ReactNode, useState} from "react";
import {QueryClient, QueryClientProvider} from "@tanstack/react-query";
import {ReactQueryDevtools} from "@tanstack/react-query-devtools";
import {ReactQueryStreamedHydration} from "@tanstack/react-query-next-experimental";

export function Providers(props: { children: ReactNode }) {
const [queryClient] = useState(
Expand Down
22 changes: 8 additions & 14 deletions pwa/components/admin/Admin.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
"use client";

import Head from "next/head";
import { useContext, useRef, useState } from "react";
import { type DataProvider, localStorageStore } from "react-admin";
import { signIn, useSession } from "next-auth/react";
import {useContext, useRef, useState} from "react";
import {type DataProvider, localStorageStore} from "react-admin";
import {signIn, useSession} from "next-auth/react";
import SyncLoader from "react-spinners/SyncLoader";
import {
fetchHydra,
HydraAdmin,
hydraDataProvider,
OpenApiAdmin,
ResourceGuesser,
} from "@api-platform/admin";
import { parseHydraDocumentation } from "@api-platform/api-doc-parser";

import { type Session } from "../../app/auth";
import {fetchHydra, HydraAdmin, hydraDataProvider, OpenApiAdmin, ResourceGuesser,} from "@api-platform/admin";
import {parseHydraDocumentation} from "@api-platform/api-doc-parser";

import {type Session} from "../../app/auth";
import DocContext from "../../components/admin/DocContext";
import authProvider from "../../components/admin/authProvider";
import Layout from "./layout/Layout";
import { ENTRYPOINT } from "../../config/entrypoint";
import {ENTRYPOINT} from "../../config/entrypoint";
import bookResourceProps from "./book";
import reviewResourceProps from "./review";
import i18nProvider from "./i18nProvider";
Expand Down
2 changes: 1 addition & 1 deletion pwa/components/admin/DocContext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createContext } from "react";
import {createContext} from "react";

const DocContext = createContext({
docType: "hydra",
Expand Down
6 changes: 3 additions & 3 deletions pwa/components/admin/authProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { AuthProvider } from "react-admin";
import { getSession, signIn, signOut } from "next-auth/react";
import {AuthProvider} from "react-admin";
import {getSession, signIn, signOut} from "next-auth/react";

import { NEXT_PUBLIC_OIDC_SERVER_URL } from "../../config/keycloak";
import {NEXT_PUBLIC_OIDC_SERVER_URL} from "../../config/keycloak";

const authProvider: AuthProvider = {
// Nothing to do here, this function will never be called
Expand Down
6 changes: 3 additions & 3 deletions pwa/components/admin/book/BookForm.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { required } from "react-admin";
import {required} from "react-admin";

import { ConditionInput } from "./ConditionInput";
import { BookInput } from "./BookInput";
import {ConditionInput} from "./ConditionInput";
import {BookInput} from "./BookInput";

export const BookForm = () => (
<>
Expand Down
18 changes: 9 additions & 9 deletions pwa/components/admin/book/BookInput.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { SyntheticEvent, useMemo, useRef, useState } from "react";
import {SyntheticEvent, useMemo, useRef, useState} from "react";
import Autocomplete from "@mui/material/Autocomplete";
import { debounce } from "@mui/material";
import { TextInput, type TextInputProps, useInput } from "react-admin";
import { useQuery } from "@tanstack/react-query";
import { useWatch } from "react-hook-form";
import {debounce} from "@mui/material";
import {TextInput, type TextInputProps, useInput} from "react-admin";
import {useQuery} from "@tanstack/react-query";
import {useWatch} from "react-hook-form";

import { Search as OpenLibrarySearch } from "../../../types/OpenLibrary/Search";
import { SearchDoc as OpenLibrarySearchDoc } from "../../../types/OpenLibrary/SearchDoc";
import { Search as GutendexSearch } from "../../../types/Gutendex/Search";
import { SearchDoc as GutendexSearchDoc } from "../../../types/Gutendex/SearchDoc";
import {Search as OpenLibrarySearch} from "../../../types/OpenLibrary/Search";
import {SearchDoc as OpenLibrarySearchDoc} from "../../../types/OpenLibrary/SearchDoc";
import {Search as GutendexSearch} from "../../../types/Gutendex/Search";
import {SearchDoc as GutendexSearchDoc} from "../../../types/Gutendex/SearchDoc";

interface Result {
title: string;
Expand Down
4 changes: 2 additions & 2 deletions pwa/components/admin/book/BooksCreate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CreateGuesser, type CreateGuesserProps } from "@api-platform/admin";
import {CreateGuesser, type CreateGuesserProps} from "@api-platform/admin";

import { BookForm } from "./BookForm";
import {BookForm} from "./BookForm";

export const BooksCreate = (props: CreateGuesserProps) => (
<CreateGuesser {...props} title="Create book">
Expand Down
8 changes: 4 additions & 4 deletions pwa/components/admin/book/BooksEdit.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { EditGuesser, type EditGuesserProps } from "@api-platform/admin";
import { TopToolbar } from "react-admin";
import {EditGuesser} from "@api-platform/admin";
import {TopToolbar} from "react-admin";

import { BookForm } from "./BookForm";
import { ShowButton } from "./ShowButton";
import {BookForm} from "./BookForm";
import {ShowButton} from "./ShowButton";

// @ts-ignore
const Actions = () => (
Expand Down
17 changes: 5 additions & 12 deletions pwa/components/admin/book/BooksList.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import { FieldGuesser } from "@api-platform/admin";
import {
TextInput,
Datagrid,
useRecordContext,
List,
EditButton,
WrapperField,
} from "react-admin";
import {FieldGuesser} from "@api-platform/admin";
import {Datagrid, EditButton, List, TextInput, useRecordContext, WrapperField,} from "react-admin";

import { ShowButton } from "./ShowButton";
import { RatingField } from "../review/RatingField";
import { ConditionInput } from "./ConditionInput";
import {ShowButton} from "./ShowButton";
import {RatingField} from "../review/RatingField";
import {ConditionInput} from "./ConditionInput";

const ConditionField = () => {
const record = useRecordContext();
Expand Down
2 changes: 1 addition & 1 deletion pwa/components/admin/book/ConditionInput.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SelectInput, SelectInputProps } from "react-admin";
import {SelectInput, SelectInputProps} from "react-admin";

export const ConditionInput = (props: SelectInputProps) => (
<SelectInput
Expand Down
4 changes: 2 additions & 2 deletions pwa/components/admin/book/ShowButton.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Button, ShowButtonProps, useRecordContext } from "react-admin";
import {Button, useRecordContext} from "react-admin";
import slugify from "slugify";
import VisibilityIcon from "@mui/icons-material/Visibility";

import { getItemPath } from "../../../utils/dataAccess";
import {getItemPath} from "../../../utils/dataAccess";

export const ShowButton = () => {
const record = useRecordContext();
Expand Down
8 changes: 4 additions & 4 deletions pwa/components/admin/book/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BooksList } from "./BooksList";
import { BooksCreate } from "./BooksCreate";
import { BooksEdit } from "./BooksEdit";
import { type Book } from "../../../types/Book";
import {BooksList} from "./BooksList";
import {BooksCreate} from "./BooksCreate";
import {BooksEdit} from "./BooksEdit";
import {type Book} from "../../../types/Book";

const bookResourceProps = {
list: BooksList,
Expand Down
2 changes: 1 addition & 1 deletion pwa/components/admin/i18nProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { resolveBrowserLocale } from "react-admin";
import {resolveBrowserLocale} from "react-admin";
import polyglotI18nProvider from "ra-i18n-polyglot";
import englishMessages from "ra-language-english";
import frenchMessages from "ra-language-french";
Expand Down
2 changes: 1 addition & 1 deletion pwa/components/admin/layout/AppBar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AppBar, UserMenu, TitlePortal } from "react-admin";
import {AppBar, TitlePortal, UserMenu} from "react-admin";

import Logo from "../Logo";
import Logout from "./Logout";
Expand Down
6 changes: 3 additions & 3 deletions pwa/components/admin/layout/DocTypeMenuButton.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useContext, useState } from "react";
import { useStore } from "react-admin";
import { Button, Menu, MenuItem } from "@mui/material";
import {useContext, useState} from "react";
import {useStore} from "react-admin";
import {Button, Menu, MenuItem} from "@mui/material";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";

import DocContext from "../DocContext";
Expand Down
2 changes: 1 addition & 1 deletion pwa/components/admin/layout/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Layout, type LayoutProps } from "react-admin";
import {Layout, type LayoutProps} from "react-admin";
import AppBar from "./AppBar";
import Menu from "./Menu";

Expand Down
10 changes: 5 additions & 5 deletions pwa/components/admin/layout/Logout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { ForwardedRef, forwardRef } from "react";
import { LogoutClasses, useTranslate } from "react-admin";
import {ForwardedRef, forwardRef} from "react";
import {LogoutClasses, useTranslate} from "react-admin";

import { ListItemIcon, ListItemText, MenuItem } from "@mui/material";
import {ListItemIcon, ListItemText, MenuItem} from "@mui/material";
import ExitIcon from "@mui/icons-material/PowerSettingsNew";
import { signOut, useSession } from "next-auth/react";
import {signOut, useSession} from "next-auth/react";

import { NEXT_PUBLIC_OIDC_SERVER_URL } from "../../../config/keycloak";
import {NEXT_PUBLIC_OIDC_SERVER_URL} from "../../../config/keycloak";

const Logout = forwardRef((props, ref: ForwardedRef<any>) => {
const { data: session } = useSession();
Expand Down
2 changes: 1 addition & 1 deletion pwa/components/admin/layout/Menu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Menu } from "react-admin";
import {Menu} from "react-admin";
import MenuBookIcon from "@mui/icons-material/MenuBook";
import CommentIcon from "@mui/icons-material/Comment";

Expand Down
4 changes: 2 additions & 2 deletions pwa/components/admin/review/BookField.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useRecordContext, type UseRecordContextParams } from "react-admin";
import {useRecordContext, type UseRecordContextParams} from "react-admin";
import Link from "next/link";
import slugify from "slugify";

import { getItemPath } from "../../../utils/dataAccess";
import {getItemPath} from "../../../utils/dataAccess";

export const BookField = (props: UseRecordContextParams) => {
const record = useRecordContext(props);
Expand Down
2 changes: 1 addition & 1 deletion pwa/components/admin/review/RatingField.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useRecordContext } from "react-admin";
import {useRecordContext} from "react-admin";
import Rating from "@mui/material/Rating";

export const RatingField = () => {
Expand Down
Loading

0 comments on commit 971036c

Please sign in to comment.