fix: error on hydration and ErrorMessage
This commit is contained in:
@@ -6,6 +6,7 @@ import { notFound } from "next/navigation";
|
||||
import { withPageTiming } from "@/lib/hoc/withPageTiming";
|
||||
import { KomgaBookWithPages } from "@/types/komga";
|
||||
import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
|
||||
async function BookPage({ params }: { params: { bookId: string } }) {
|
||||
try {
|
||||
@@ -20,7 +21,7 @@ async function BookPage({ params }: { params: { bookId: string } }) {
|
||||
console.error("Erreur:", error);
|
||||
return (
|
||||
<div className="container py-8 space-y-8">
|
||||
<ErrorMessage error={error as Error} errorCode="BOOK_FETCH_ERROR" />
|
||||
<ErrorMessage errorCode={ERROR_CODES.SERIES.FETCH_ERROR} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||
import { LibraryResponse } from "@/types/library";
|
||||
import { KomgaSeries, KomgaLibrary } from "@/types/komga";
|
||||
import { UserPreferences } from "@/types/preferences";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
|
||||
interface PageProps {
|
||||
params: { libraryId: string };
|
||||
@@ -98,13 +99,13 @@ async function LibraryPage({ params, searchParams }: PageProps) {
|
||||
<h1 className="text-3xl font-bold">Séries</h1>
|
||||
<RefreshButton libraryId={params.libraryId} refreshLibrary={refreshLibrary} />
|
||||
</div>
|
||||
<ErrorMessage error={error as Error} errorCode="SERIES_FETCH_ERROR" />
|
||||
<ErrorMessage errorCode={ERROR_CODES.SERIES.FETCH_ERROR} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="container py-8 space-y-8">
|
||||
<ErrorMessage error={error as Error} errorCode="SERIES_FETCH_ERROR" />
|
||||
<ErrorMessage errorCode={ERROR_CODES.SERIES.FETCH_ERROR} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ async function refreshHome() {
|
||||
async function HomePage() {
|
||||
try {
|
||||
const data: HomeData = await HomeService.getHomeData();
|
||||
|
||||
return <HomeContent data={data} refreshHome={refreshHome} />;
|
||||
} catch (error) {
|
||||
// Si l'erreur indique une configuration manquante, rediriger vers les préférences
|
||||
@@ -34,7 +33,7 @@ async function HomePage() {
|
||||
|
||||
return (
|
||||
<main className="container mx-auto px-4 py-8">
|
||||
<ErrorMessage error={error as Error} errorCode="HOME_FETCH_ERROR" />
|
||||
<ErrorMessage errorCode={ERROR_CODES.KOMGA.SERVER_UNREACHABLE} />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import { ErrorMessage } from "@/components/ui/ErrorMessage";
|
||||
import { LibraryResponse } from "@/types/library";
|
||||
import { KomgaBook, KomgaSeries } from "@/types/komga";
|
||||
import { UserPreferences } from "@/types/preferences";
|
||||
import { ERROR_CODES } from "@/constants/errorCodes";
|
||||
|
||||
interface PageProps {
|
||||
params: { seriesId: string };
|
||||
@@ -78,7 +79,7 @@ async function SeriesPage({ params, searchParams }: PageProps) {
|
||||
return (
|
||||
<div className="container py-8 space-y-8">
|
||||
<h1 className="text-3xl font-bold">Série</h1>
|
||||
<ErrorMessage error={error as Error} errorCode="SERIES_FETCH_ERROR" />
|
||||
<ErrorMessage errorCode={ERROR_CODES.SERIES.FETCH_ERROR} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ export function LoginForm({ from }: LoginFormProps) {
|
||||
{t("login.form.remember")}
|
||||
</label>
|
||||
</div>
|
||||
{error && <ErrorMessage error={error as Error} errorCode={error.code} variant="form" />}
|
||||
{error && <ErrorMessage errorCode={error.code} variant="form" />}
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading}
|
||||
|
||||
@@ -100,7 +100,7 @@ export function RegisterForm({ from }: RegisterFormProps) {
|
||||
className="flex h-10 w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
|
||||
/>
|
||||
</div>
|
||||
{error && <ErrorMessage error={error as Error} errorCode={error.code} variant="form" />}
|
||||
{error && <ErrorMessage errorCode={error.code} variant="form" />}
|
||||
<button
|
||||
type="submit"
|
||||
disabled={isLoading}
|
||||
|
||||
Reference in New Issue
Block a user