diff --git a/apps/infoalloggi/src/_app/layout.tsx b/apps/infoalloggi/src/_app/layout.tsx new file mode 100644 index 0000000..fea34bf --- /dev/null +++ b/apps/infoalloggi/src/_app/layout.tsx @@ -0,0 +1,39 @@ +import type { Metadata } from "next"; +import "~/styles/globals.css"; +export const metadata: Metadata = { + title: "Home", + description: "Welcome to Next.js", + icons: { + apple: { + url: "/favicon/apple-touch-icon.png", + sizes: "180x180", + type: "image/png", + }, + icon: [ + { url: "/favicon/favicon-32x32.png", sizes: "32x32", type: "image/png" }, + { url: "/favicon/favicon-16x16.png", sizes: "16x16", type: "image/png" }, + ], + other: [ + { + rel: "mask-icon", + url: "/favicon/safari-pinned-tab.svg", + color: "#5bbad5", + }, + ], + }, + manifest: "/site.webmanifest", +}; + +export default function RootLayout({ + // Layouts must accept a children prop. + // This will be populated with nested layouts or pages + children, +}: { + children: React.ReactNode; +}) { + return ( + + {children} + + ); +} diff --git a/apps/infoalloggi/src/_app/lib/annunci.ts b/apps/infoalloggi/src/_app/lib/annunci.ts new file mode 100644 index 0000000..bfae57f --- /dev/null +++ b/apps/infoalloggi/src/_app/lib/annunci.ts @@ -0,0 +1,20 @@ +import TipologiaPosizioneEnum from "~/schemas/public/TipologiaPosizioneEnum"; +import { db } from "~/server/db"; + +export async function getDataFromDB() { + try { + // Example query - adjust to your database schema + const data = await db + .selectFrom("annunci") + .select("codice") + .where("web", "=", true) + .where("tipo", "=", TipologiaPosizioneEnum.Transitorio) + .where("stato", "=", "Attivo") + .execute(); + + return data; + } catch (error) { + console.error("Database error:", error); + return []; + } +} diff --git a/apps/infoalloggi/src/_app/testapp/page.tsx b/apps/infoalloggi/src/_app/testapp/page.tsx new file mode 100644 index 0000000..a636b18 --- /dev/null +++ b/apps/infoalloggi/src/_app/testapp/page.tsx @@ -0,0 +1,22 @@ +import { Suspense } from "react"; +import Annunci from "~/app/ui/annunci"; +import { getDataFromDB } from "~/app/lib/annunci"; +import { LoadingPage } from "~/components/loading"; + +export default function TestAppPage() { + const annunci = getDataFromDB(); + + return ( +
+

Test App Page

+ +
+

Data from Database:

+ + }> + + +
+
+ ); +} diff --git a/apps/infoalloggi/src/_app/ui/annunci.tsx b/apps/infoalloggi/src/_app/ui/annunci.tsx new file mode 100644 index 0000000..465f946 --- /dev/null +++ b/apps/infoalloggi/src/_app/ui/annunci.tsx @@ -0,0 +1,19 @@ +"use client"; +import { use } from "react"; +import type { Annunci } from "~/schemas/public/Annunci"; + +type AnnunciProps = { + annunci: Promise[]>; +}; + +export default function Annunci({ annunci }: AnnunciProps) { + const allAnnunci = use(annunci); + + return ( + + ); +} diff --git a/apps/infoalloggi/src/components/failed-loading.tsx b/apps/infoalloggi/src/components/failed-loading.tsx new file mode 100644 index 0000000..622040e --- /dev/null +++ b/apps/infoalloggi/src/components/failed-loading.tsx @@ -0,0 +1,38 @@ +import Link from "next/link"; +import { useRouter } from "next/router"; +import { useTranslation } from "~/providers/I18nProvider"; +import { HomeIcon } from "~/components/IconComponents"; + +export default function FailedAnnuncioLoading() { + const router = useRouter(); + const { t } = useTranslation(); + return ( +
+
+
+ +

+ {t.annuncio_load_fail.titolo} +

+

{t.annuncio_load_fail.sottotitolo}

+
+ + + {t.annuncio_load_fail.home} + +
+
+
+
+ ); +} diff --git a/apps/infoalloggi/src/components/loading.tsx b/apps/infoalloggi/src/components/loading.tsx index 6fa959a..353f9bf 100644 --- a/apps/infoalloggi/src/components/loading.tsx +++ b/apps/infoalloggi/src/components/loading.tsx @@ -1,7 +1,4 @@ -import Link from "next/link"; -import { useRouter } from "next/router"; -import { useTranslation } from "~/providers/I18nProvider"; -import { HomeIcon } from "~/components/IconComponents"; +"use client"; import { ASvg } from "~/components/svgs"; export const LoadingPage = () => { @@ -12,37 +9,3 @@ export const LoadingPage = () => { ); }; - -export default function FailedAnnuncioLoading() { - const router = useRouter(); - const { t } = useTranslation(); - return ( -
-
-
- -

- {t.annuncio_load_fail.titolo} -

-

{t.annuncio_load_fail.sottotitolo}

-
- - - {t.annuncio_load_fail.home} - -
-
-
-
- ); -}