✨ feat: add service-down error page
This commit is contained in:
11
app/(safe-mode-page)/status/page.tsx
Normal file
11
app/(safe-mode-page)/status/page.tsx
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import StatusIndex from "@/features/status";
|
||||||
|
|
||||||
|
const page = () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<StatusIndex />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default page;
|
||||||
7
app/(session)/(clean)/down/page.tsx
Normal file
7
app/(session)/(clean)/down/page.tsx
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const page = () => {
|
||||||
|
return <div>page</div>;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default page;
|
||||||
12
app/(session)/layout.tsx
Normal file
12
app/(session)/layout.tsx
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import AuthSessionProviderWrapper from "@/shared/providers/AuthSession";
|
||||||
|
import React from "react";
|
||||||
|
|
||||||
|
const layout = ({ children }: Readonly<{ children: React.ReactNode }>) => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<AuthSessionProviderWrapper>{children}</AuthSessionProviderWrapper>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default layout;
|
||||||
@ -30,7 +30,7 @@ export default function RootLayout({
|
|||||||
<body
|
<body
|
||||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||||
>
|
>
|
||||||
<AuthSessionProviderWrapper>{children}</AuthSessionProviderWrapper>
|
{children}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
);
|
);
|
||||||
|
|||||||
32
features/status/index.tsx
Normal file
32
features/status/index.tsx
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import Image from "next/image";
|
||||||
|
import UnderContruction from "@/shared/assets/under-construction.svg";
|
||||||
|
|
||||||
|
const StatusIndex = () => {
|
||||||
|
return (
|
||||||
|
<div>
|
||||||
|
<div className="flex flex-col md:flex-row items-center justify-center text-center md:text-left px-4 pt-12 md:pt-22">
|
||||||
|
<Image
|
||||||
|
src={UnderContruction}
|
||||||
|
alt="Under Construction"
|
||||||
|
draggable={false}
|
||||||
|
width={240}
|
||||||
|
/>
|
||||||
|
<div className="mt-6 md:mt-0 md:ml-6 lg:ml-12 max-w-md">
|
||||||
|
<h1 className="text-xl font-semibold">
|
||||||
|
Service is temporarily unavailable
|
||||||
|
</h1>
|
||||||
|
<p className="text-sm text-neutral-300 mt-2">
|
||||||
|
We're currently experiencing an issue with this service and our team
|
||||||
|
is working to restore it as quickly as possible. You can still
|
||||||
|
browse other features while we fix the problem. Please check back in
|
||||||
|
a few moments. We appreciate your patience.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default StatusIndex;
|
||||||
1
shared/assets/under-construction.svg
Normal file
1
shared/assets/under-construction.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 152 KiB |
@ -1,5 +1,6 @@
|
|||||||
"use server";
|
"use server";
|
||||||
import { headers } from "next/headers";
|
import { headers } from "next/headers";
|
||||||
|
import { redirect } from "next/navigation";
|
||||||
import { UAParser } from "ua-parser-js";
|
import { UAParser } from "ua-parser-js";
|
||||||
|
|
||||||
export interface BackendResponse<T = unknown> {
|
export interface BackendResponse<T = unknown> {
|
||||||
@ -22,22 +23,26 @@ export const backendFetch = async (path: string, options: RequestInit = {}) => {
|
|||||||
ip: userIp,
|
ip: userIp,
|
||||||
};
|
};
|
||||||
|
|
||||||
const res = await fetch(`${process.env.BACKEND_ENDPOINT}/${path}`, {
|
try {
|
||||||
...options,
|
const res = await fetch(`${process.env.BACKEND_ENDPOINT}/${path}`, {
|
||||||
headers: {
|
...options,
|
||||||
"Content-Type": "application/json",
|
headers: {
|
||||||
"x-client-info": JSON.stringify(clientInfo),
|
"Content-Type": "application/json",
|
||||||
Authorization: `Bearer ${process.env.BACKEND_API_KEY}`,
|
"x-client-info": JSON.stringify(clientInfo),
|
||||||
...options.headers,
|
Authorization: `Bearer ${process.env.BACKEND_API_KEY}`,
|
||||||
},
|
...options.headers,
|
||||||
cache: "default",
|
},
|
||||||
});
|
cache: "default",
|
||||||
|
});
|
||||||
|
|
||||||
const resJson = (await res.json()) as BackendResponse;
|
const resJson = (await res.json()) as BackendResponse;
|
||||||
|
|
||||||
if (!res.ok || !resJson.success) {
|
if (!res.ok || !resJson.success) {
|
||||||
throw new Error(`Elysia error: ${resJson.error}`);
|
throw new Error(`Elysia error: ${resJson.error}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return resJson;
|
||||||
|
} catch (error) {
|
||||||
|
redirect("/status?reason=backend-unreachable");
|
||||||
}
|
}
|
||||||
|
|
||||||
return resJson;
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -15,28 +15,28 @@ const NavigationLink = () => {
|
|||||||
<div className="pl-10">
|
<div className="pl-10">
|
||||||
<NavigationMenu viewport={false}>
|
<NavigationMenu viewport={false}>
|
||||||
<NavigationMenuList className="flex-wrap">
|
<NavigationMenuList className="flex-wrap">
|
||||||
<NavigationMenuItem>
|
<NavigationMenuItem key={1}>
|
||||||
<NavigationMenuLink asChild>
|
<NavigationMenuLink asChild>
|
||||||
<Link href="/season" className="text-sm">
|
<Link href="/season" className="text-sm">
|
||||||
Season
|
Season
|
||||||
</Link>
|
</Link>
|
||||||
</NavigationMenuLink>
|
</NavigationMenuLink>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
<NavigationMenuItem>
|
<NavigationMenuItem key={2}>
|
||||||
<NavigationMenuLink asChild>
|
<NavigationMenuLink asChild>
|
||||||
<Link href="/genres" className="text-sm">
|
<Link href="/genres" className="text-sm">
|
||||||
Genres
|
Genres
|
||||||
</Link>
|
</Link>
|
||||||
</NavigationMenuLink>
|
</NavigationMenuLink>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
<NavigationMenuItem>
|
<NavigationMenuItem key={3}>
|
||||||
<NavigationMenuLink asChild>
|
<NavigationMenuLink asChild>
|
||||||
<Link href="/trending" className="text-sm">
|
<Link href="/trending" className="text-sm">
|
||||||
Trending
|
Trending
|
||||||
</Link>
|
</Link>
|
||||||
</NavigationMenuLink>
|
</NavigationMenuLink>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
<NavigationMenuItem>
|
<NavigationMenuItem key={4}>
|
||||||
<NavigationMenuTrigger className="font-normal">
|
<NavigationMenuTrigger className="font-normal">
|
||||||
Media
|
Media
|
||||||
</NavigationMenuTrigger>
|
</NavigationMenuTrigger>
|
||||||
@ -62,7 +62,7 @@ const NavigationLink = () => {
|
|||||||
</ul>
|
</ul>
|
||||||
</NavigationMenuContent>
|
</NavigationMenuContent>
|
||||||
</NavigationMenuItem>
|
</NavigationMenuItem>
|
||||||
<NavigationMenuItem>
|
<NavigationMenuItem key={5}>
|
||||||
<NavigationMenuTrigger className="font-normal">
|
<NavigationMenuTrigger className="font-normal">
|
||||||
Release
|
Release
|
||||||
</NavigationMenuTrigger>
|
</NavigationMenuTrigger>
|
||||||
|
|||||||
Reference in New Issue
Block a user