2024-01-14 09:09:09 -06:00
|
|
|
import React, { useEffect } from "react";
|
2023-01-29 12:12:36 -06:00
|
|
|
import "@/styles/globals.css";
|
2023-12-29 11:21:22 -06:00
|
|
|
import "bootstrap-icons/font/bootstrap-icons.css";
|
2023-02-06 11:59:23 -06:00
|
|
|
import { SessionProvider } from "next-auth/react";
|
2023-01-29 12:12:36 -06:00
|
|
|
import type { AppProps } from "next/app";
|
2023-03-28 02:31:50 -05:00
|
|
|
import Head from "next/head";
|
2023-04-30 15:54:40 -05:00
|
|
|
import AuthRedirect from "@/layouts/AuthRedirect";
|
2024-04-18 12:34:29 -05:00
|
|
|
import toast from "react-hot-toast";
|
|
|
|
import { Toaster, ToastBar } from "react-hot-toast";
|
2023-07-08 05:35:43 -05:00
|
|
|
import { Session } from "next-auth";
|
2024-01-14 09:09:09 -06:00
|
|
|
import { isPWA } from "@/lib/client/utils";
|
2024-05-20 18:23:11 -05:00
|
|
|
import useInitialData from "@/hooks/useInitialData";
|
2023-01-22 15:39:35 -06:00
|
|
|
|
2023-07-08 05:35:43 -05:00
|
|
|
export default function App({
|
|
|
|
Component,
|
|
|
|
pageProps,
|
|
|
|
}: AppProps<{
|
|
|
|
session: Session;
|
|
|
|
}>) {
|
2024-01-14 09:09:09 -06:00
|
|
|
useEffect(() => {
|
|
|
|
if (isPWA()) {
|
|
|
|
const meta = document.createElement("meta");
|
|
|
|
meta.name = "viewport";
|
|
|
|
meta.content = "width=device-width, initial-scale=1, maximum-scale=1";
|
|
|
|
document.getElementsByTagName("head")[0].appendChild(meta);
|
|
|
|
}
|
|
|
|
}, []);
|
|
|
|
|
2023-01-22 15:39:35 -06:00
|
|
|
return (
|
2023-11-06 07:25:57 -06:00
|
|
|
<SessionProvider
|
|
|
|
session={pageProps.session}
|
|
|
|
refetchOnWindowFocus={false}
|
|
|
|
basePath="/api/v1/auth"
|
|
|
|
>
|
2023-03-28 02:31:50 -05:00
|
|
|
<Head>
|
|
|
|
<title>Linkwarden</title>
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
2024-01-14 14:40:00 -06:00
|
|
|
<meta name="theme-color" content="#000000" />
|
2023-03-28 02:31:50 -05:00
|
|
|
<link
|
|
|
|
rel="apple-touch-icon"
|
|
|
|
sizes="180x180"
|
|
|
|
href="/apple-touch-icon.png"
|
|
|
|
/>
|
|
|
|
<link
|
|
|
|
rel="icon"
|
|
|
|
type="image/png"
|
|
|
|
sizes="32x32"
|
|
|
|
href="/favicon-32x32.png"
|
|
|
|
/>
|
|
|
|
<link
|
|
|
|
rel="icon"
|
|
|
|
type="image/png"
|
|
|
|
sizes="16x16"
|
|
|
|
href="/favicon-16x16.png"
|
|
|
|
/>
|
|
|
|
<link rel="manifest" href="/site.webmanifest" />
|
|
|
|
</Head>
|
2023-04-30 15:54:40 -05:00
|
|
|
<AuthRedirect>
|
2024-05-20 18:23:11 -05:00
|
|
|
{/* <GetData> */}
|
2023-11-24 02:06:33 -06:00
|
|
|
<Toaster
|
|
|
|
position="top-center"
|
|
|
|
reverseOrder={false}
|
|
|
|
toastOptions={{
|
|
|
|
className:
|
2023-12-04 09:24:45 -06:00
|
|
|
"border border-sky-100 dark:border-neutral-700 dark:bg-neutral-800 dark:text-white",
|
2023-11-24 02:06:33 -06:00
|
|
|
}}
|
2024-04-18 12:34:29 -05:00
|
|
|
>
|
|
|
|
{(t) => (
|
|
|
|
<ToastBar toast={t}>
|
|
|
|
{({ icon, message }) => (
|
|
|
|
<div
|
|
|
|
className="flex flex-row"
|
|
|
|
data-testid="toast-message-container"
|
|
|
|
data-type={t.type}
|
|
|
|
>
|
|
|
|
{icon}
|
|
|
|
<span data-testid="toast-message">{message}</span>
|
|
|
|
{t.type !== "loading" && (
|
|
|
|
<button
|
2024-04-20 09:49:06 -05:00
|
|
|
className="btn btn-xs outline-none btn-circle btn-ghost"
|
2024-04-18 12:34:29 -05:00
|
|
|
data-testid="close-toast-button"
|
|
|
|
onClick={() => toast.dismiss(t.id)}
|
|
|
|
>
|
|
|
|
<i className="bi bi-x"></i>
|
|
|
|
</button>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</ToastBar>
|
|
|
|
)}
|
|
|
|
</Toaster>
|
2023-11-24 02:06:33 -06:00
|
|
|
<Component {...pageProps} />
|
2024-05-20 18:23:11 -05:00
|
|
|
{/* </GetData> */}
|
2023-04-30 15:54:40 -05:00
|
|
|
</AuthRedirect>
|
2023-02-06 11:59:23 -06:00
|
|
|
</SessionProvider>
|
2023-01-22 15:39:35 -06:00
|
|
|
);
|
|
|
|
}
|
2024-05-20 18:23:11 -05:00
|
|
|
|
|
|
|
// function GetData({ children }: { children: React.ReactNode }) {
|
|
|
|
// const status = useInitialData();
|
|
|
|
// return typeof window !== "undefined" && status !== "loading" ? (
|
|
|
|
// children
|
|
|
|
// ) : (
|
|
|
|
// <></>
|
|
|
|
// );
|
|
|
|
// }
|