mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-10 04:22:27 +10:00
fix lint issues
This commit is contained in:
@ -1,64 +1,61 @@
|
||||
// External libraries
|
||||
import { Trans, t } from "@lingui/macro";
|
||||
import { Link, useRouteError } from "react-router";
|
||||
import { t } from "@lingui/macro";
|
||||
import { Button } from "@reactive-resume/ui";
|
||||
import { Link, useRouteError } from "react-router";
|
||||
|
||||
import { LocaleProvider } from "@/client/providers/locale";
|
||||
|
||||
type RouterError = {
|
||||
status: number;
|
||||
statusText?: string;
|
||||
data: string;
|
||||
message?: string;
|
||||
statusText?: string;
|
||||
message?: string;
|
||||
status: number;
|
||||
data: string;
|
||||
} & Error;
|
||||
|
||||
const getErrorMessage = (status: number) => {
|
||||
switch (status) {
|
||||
case 404:
|
||||
return "The page you're looking for doesn't exist.";
|
||||
case 403:
|
||||
return "You don't have permission to access this page.";
|
||||
case 500:
|
||||
return "An internal server error occurred.";
|
||||
case 401:
|
||||
return "You are not authorized to access this page.";
|
||||
case 400:
|
||||
return "The request was invalid.";
|
||||
default:
|
||||
return "An unexpected error occurred.";
|
||||
switch (status) {
|
||||
case 404: {
|
||||
return t`The page you're looking for doesn't exist.`;
|
||||
}
|
||||
case 403: {
|
||||
return t`You don't have permission to access this page.`;
|
||||
}
|
||||
case 500: {
|
||||
return t`An internal server error occurred.`;
|
||||
}
|
||||
case 401: {
|
||||
return t`You are not authorized to access this page.`;
|
||||
}
|
||||
case 400: {
|
||||
return t`The request was invalid.`;
|
||||
}
|
||||
default: {
|
||||
return t`An unexpected error occurred.`;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export const ErrorPage = () => {
|
||||
const error = useRouteError() as RouterError;
|
||||
const error = useRouteError() as RouterError;
|
||||
const statusCode = error.status;
|
||||
|
||||
return (
|
||||
<LocaleProvider>
|
||||
<main className="flex items-center justify-center min-h-screen p-4">
|
||||
<div className="w-full max-w-sm space-y-6">
|
||||
<h4 className="flex flex-col text-4xl font-bold text-white">
|
||||
<span>
|
||||
{t`Error ${error.status}`}
|
||||
</span>
|
||||
{error.statusText && <span className="text-base font-normal">{`${error.statusText}`}</span>}
|
||||
</h4>
|
||||
return (
|
||||
<LocaleProvider>
|
||||
<main className="flex min-h-screen items-center justify-center p-4">
|
||||
<div className="w-full max-w-sm space-y-6">
|
||||
<h4 className="flex flex-col text-4xl font-bold text-white">
|
||||
<span>{t`Error ${statusCode}`}</span>
|
||||
{error.statusText && <span className="text-base font-normal">{error.statusText}</span>}
|
||||
</h4>
|
||||
|
||||
<p className="text-sm text-gray-500 break-words">
|
||||
{/* {error.data || error.message} */}
|
||||
<Trans>{error.data || error.message || getErrorMessage(error.status)}</Trans>
|
||||
</p>
|
||||
<p className="break-words text-sm text-gray-500">
|
||||
{error.data || error.message || getErrorMessage(statusCode)}
|
||||
</p>
|
||||
|
||||
<div className="pt-2">
|
||||
<Link
|
||||
to="/"
|
||||
className="inline-block"
|
||||
>
|
||||
<Button>
|
||||
{t`Go to home`}
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</LocaleProvider>
|
||||
);
|
||||
<Button asChild className="inline-block pt-2">
|
||||
<Link to="/">{t`Go to home`}</Link>
|
||||
</Button>
|
||||
</div>
|
||||
</main>
|
||||
</LocaleProvider>
|
||||
);
|
||||
};
|
||||
|
||||
@ -15,12 +15,12 @@ import { ResumesPage } from "../pages/dashboard/resumes/page";
|
||||
import { SettingsPage } from "../pages/dashboard/settings/page";
|
||||
import { HomeLayout } from "../pages/home/layout";
|
||||
import { HomePage } from "../pages/home/page";
|
||||
import { ErrorPage } from "../pages/public/error";
|
||||
import { publicLoader, PublicResumePage } from "../pages/public/page";
|
||||
import { Providers } from "../providers";
|
||||
import { AuthGuard } from "./guards/auth";
|
||||
import { GuestGuard } from "./guards/guest";
|
||||
import { authLoader } from "./loaders/auth";
|
||||
import { ErrorPage } from "../pages/public/error";
|
||||
|
||||
export const routes = createRoutesFromElements(
|
||||
<Route element={<Providers />} errorElement={<ErrorPage />}>
|
||||
|
||||
Reference in New Issue
Block a user