diff --git a/app/(safe-mode-page)/status/page.tsx b/app/(safe-mode-page)/status/page.tsx new file mode 100644 index 0000000..c27905e --- /dev/null +++ b/app/(safe-mode-page)/status/page.tsx @@ -0,0 +1,23 @@ +import StatusIndex from "@/features/status"; +import { backendFetch } from "@/shared/helpers/backendFetch"; +import { redirect } from "next/navigation"; + +const page = async () => { + // Check service status with API call + let isDown = false; + try { + const data = await backendFetch("status"); + console.log(data); + } catch (_) { + isDown = true; + } + if (!isDown) redirect("/"); + + return ( +
+ +
+ ); +}; + +export default page; diff --git a/app/(clean)/auth/providers/[name]/callback/page.tsx b/app/(session)/(clean)/auth/providers/[name]/callback/page.tsx similarity index 100% rename from app/(clean)/auth/providers/[name]/callback/page.tsx rename to app/(session)/(clean)/auth/providers/[name]/callback/page.tsx diff --git a/app/(session)/(clean)/down/page.tsx b/app/(session)/(clean)/down/page.tsx new file mode 100644 index 0000000..a54c709 --- /dev/null +++ b/app/(session)/(clean)/down/page.tsx @@ -0,0 +1,7 @@ +import React from "react"; + +const page = () => { + return
page
; +}; + +export default page; diff --git a/app/(main)/home/page.tsx b/app/(session)/(main)/home/page.tsx similarity index 100% rename from app/(main)/home/page.tsx rename to app/(session)/(main)/home/page.tsx diff --git a/app/(main)/layout.tsx b/app/(session)/(main)/layout.tsx similarity index 100% rename from app/(main)/layout.tsx rename to app/(session)/(main)/layout.tsx diff --git a/app/(main)/page.tsx b/app/(session)/(main)/page.tsx similarity index 100% rename from app/(main)/page.tsx rename to app/(session)/(main)/page.tsx diff --git a/app/(session)/layout.tsx b/app/(session)/layout.tsx new file mode 100644 index 0000000..5d04563 --- /dev/null +++ b/app/(session)/layout.tsx @@ -0,0 +1,12 @@ +import AuthSessionProviderWrapper from "@/shared/providers/AuthSession"; +import React from "react"; + +const layout = ({ children }: Readonly<{ children: React.ReactNode }>) => { + return ( +
+ {children} +
+ ); +}; + +export default layout; diff --git a/app/layout.tsx b/app/layout.tsx index 00aa0d9..ab9cda4 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -30,7 +30,7 @@ export default function RootLayout({ - {children} + {children} ); diff --git a/features/status/index.tsx b/features/status/index.tsx new file mode 100644 index 0000000..a8ca445 --- /dev/null +++ b/features/status/index.tsx @@ -0,0 +1,32 @@ +"use client"; + +import Image from "next/image"; +import UnderContruction from "@/shared/assets/under-construction.svg"; + +const StatusIndex = () => { + return ( +
+
+ Under Construction +
+

+ Service is temporarily unavailable +

+

+ 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. +

+
+
+
+ ); +}; + +export default StatusIndex; diff --git a/shared/assets/under-construction.svg b/shared/assets/under-construction.svg new file mode 100644 index 0000000..ced5c39 --- /dev/null +++ b/shared/assets/under-construction.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/shared/helpers/backendFetch.ts b/shared/helpers/backendFetch.ts index fe1a273..bfe592e 100644 --- a/shared/helpers/backendFetch.ts +++ b/shared/helpers/backendFetch.ts @@ -1,5 +1,6 @@ "use server"; import { headers } from "next/headers"; +import { redirect } from "next/navigation"; import { UAParser } from "ua-parser-js"; export interface BackendResponse { @@ -22,22 +23,26 @@ export const backendFetch = async (path: string, options: RequestInit = {}) => { ip: userIp, }; - const res = await fetch(`${process.env.BACKEND_ENDPOINT}/${path}`, { - ...options, - headers: { - "Content-Type": "application/json", - "x-client-info": JSON.stringify(clientInfo), - Authorization: `Bearer ${process.env.BACKEND_API_KEY}`, - ...options.headers, - }, - cache: "default", - }); + try { + const res = await fetch(`${process.env.BACKEND_ENDPOINT}/${path}`, { + ...options, + headers: { + "Content-Type": "application/json", + "x-client-info": JSON.stringify(clientInfo), + Authorization: `Bearer ${process.env.BACKEND_API_KEY}`, + ...options.headers, + }, + cache: "default", + }); - const resJson = (await res.json()) as BackendResponse; + const resJson = (await res.json()) as BackendResponse; - if (!res.ok || !resJson.success) { - throw new Error(`Elysia error: ${resJson.error}`); + if (!res.ok || !resJson.success) { + throw new Error(`Elysia error: ${resJson.error}`); + } + + return resJson; + } catch (error) { + redirect("/status?reason=backend-unreachable"); } - - return resJson; }; diff --git a/shared/widgets/navbar/components/NavigationLink.tsx b/shared/widgets/navbar/components/NavigationLink.tsx index b8f8e9a..42ecde6 100644 --- a/shared/widgets/navbar/components/NavigationLink.tsx +++ b/shared/widgets/navbar/components/NavigationLink.tsx @@ -15,28 +15,28 @@ const NavigationLink = () => {
- + Season - + Genres - + Trending - + Media @@ -62,7 +62,7 @@ const NavigationLink = () => { - + Release diff --git a/shared/widgets/signin/components/SignInCard.tsx b/shared/widgets/signin/components/SignInCard.tsx index c631832..50f228c 100644 --- a/shared/widgets/signin/components/SignInCard.tsx +++ b/shared/widgets/signin/components/SignInCard.tsx @@ -35,7 +35,7 @@ const SignInCard = () => { // Open OAuth endpoint in a new popup window const getOauthEndpointUrl = async ( providerReqEndpoint: string, - providerName: string + providerName: string, ) => { const res = await getOauthEndpoint({ endpointUrl: providerReqEndpoint, @@ -70,7 +70,7 @@ const SignInCard = () => {
-
+
@@ -81,7 +81,7 @@ const SignInCard = () => {
{oAuthProviders ? ( -
+
{oAuthProviders.data?.map((provider, index) => (