feat: implement server-side rendering for various admin pages and update backend URL configuration
This commit is contained in:
parent
47d5a01275
commit
bc1f114837
23 changed files with 305 additions and 8 deletions
|
|
@ -5,6 +5,8 @@
|
||||||
|
|
||||||
import { env } from "node:process";
|
import { env } from "node:process";
|
||||||
|
|
||||||
|
const backendUrl = "http://localhost:1323";
|
||||||
|
|
||||||
/** @type {import("next").NextConfig} */
|
/** @type {import("next").NextConfig} */
|
||||||
const nextConfig = {
|
const nextConfig = {
|
||||||
compiler: {
|
compiler: {
|
||||||
|
|
@ -46,7 +48,7 @@ const nextConfig = {
|
||||||
protocol: "https",
|
protocol: "https",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
hostname: `${env.BACKENDSERVER_URL}`,
|
hostname: backendUrl,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
@ -59,11 +61,11 @@ const nextConfig = {
|
||||||
source: "/api/panel",
|
source: "/api/panel",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
destination: `${env.BACKENDSERVER_URL}/images/get/:slug*`,
|
destination: `${backendUrl}/images/get/:slug*`,
|
||||||
source: "/go-api/images/get/:slug*",
|
source: "/go-api/images/get/:slug*",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
destination: `${env.BACKENDSERVER_URL}/storage/get/:slug*`,
|
destination: `${backendUrl}/storage/get/:slug*`,
|
||||||
has: [
|
has: [
|
||||||
{ key: "access_token", type: "cookie" },
|
{ key: "access_token", type: "cookie" },
|
||||||
{
|
{
|
||||||
|
|
@ -76,7 +78,7 @@ const nextConfig = {
|
||||||
source: "/go-api/storage/get/:slug*",
|
source: "/go-api/storage/get/:slug*",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
destination: `${env.BACKENDSERVER_URL}/storage/upload:slug*`,
|
destination: `${backendUrl}/storage/upload:slug*`,
|
||||||
has: [
|
has: [
|
||||||
{ key: "access_token", type: "cookie" },
|
{ key: "access_token", type: "cookie" },
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import { Status500 } from "~/components/status-page";
|
||||||
import { AnnunciTable } from "~/components/tables/annunci-tables";
|
import { AnnunciTable } from "~/components/tables/annunci-tables";
|
||||||
import { Button } from "~/components/ui/button";
|
import { Button } from "~/components/ui/button";
|
||||||
import type { NextPageWithLayout } from "~/pages/_app";
|
import type { NextPageWithLayout } from "~/pages/_app";
|
||||||
|
import { generateSSGHelper } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const Admin_Annunci: NextPageWithLayout = () => {
|
const Admin_Annunci: NextPageWithLayout = () => {
|
||||||
|
|
@ -62,6 +63,18 @@ const Admin_Annunci: NextPageWithLayout = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export async function getServerSideProps() {
|
||||||
|
const helpers = generateSSGHelper();
|
||||||
|
|
||||||
|
await helpers.annunci.getAnnunciList.prefetch();
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default Admin_Annunci;
|
export default Admin_Annunci;
|
||||||
|
|
||||||
Admin_Annunci.getLayout = function getLayout(page) {
|
Admin_Annunci.getLayout = function getLayout(page) {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ import {
|
||||||
import { FormBanners } from "~/forms/FormBanners";
|
import { FormBanners } from "~/forms/FormBanners";
|
||||||
import type { NextPageWithLayout } from "~/pages/_app";
|
import type { NextPageWithLayout } from "~/pages/_app";
|
||||||
import type { Banners } from "~/schemas/public/Banners";
|
import type { Banners } from "~/schemas/public/Banners";
|
||||||
|
import { generateSSGHelper } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const AdminBanners: NextPageWithLayout = () => {
|
const AdminBanners: NextPageWithLayout = () => {
|
||||||
|
|
@ -83,6 +84,17 @@ const AdminBanners: NextPageWithLayout = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default AdminBanners;
|
export default AdminBanners;
|
||||||
|
export async function getServerSideProps() {
|
||||||
|
const helpers = generateSSGHelper();
|
||||||
|
|
||||||
|
await helpers.settings.getBannerAllData.prefetch();
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
AdminBanners.getLayout = function getLayout(page) {
|
AdminBanners.getLayout = function getLayout(page) {
|
||||||
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { Plus, RefreshCcw } from "lucide-react";
|
import { Plus, RefreshCcw } from "lucide-react";
|
||||||
|
import type { GetServerSideProps } from "next";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { AreaRiservataLayout } from "~/components/Layout";
|
import { AreaRiservataLayout } from "~/components/Layout";
|
||||||
|
|
@ -17,6 +18,7 @@ import {
|
||||||
import { FormBanlist } from "~/forms/FormBanlist";
|
import { FormBanlist } from "~/forms/FormBanlist";
|
||||||
import type { NextPageWithLayout } from "~/pages/_app";
|
import type { NextPageWithLayout } from "~/pages/_app";
|
||||||
import type { Banlist } from "~/schemas/public/Banlist";
|
import type { Banlist } from "~/schemas/public/Banlist";
|
||||||
|
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const AdminBlacklist: NextPageWithLayout = () => {
|
const AdminBlacklist: NextPageWithLayout = () => {
|
||||||
|
|
@ -84,6 +86,23 @@ const AdminBlacklist: NextPageWithLayout = () => {
|
||||||
};
|
};
|
||||||
export default AdminBlacklist;
|
export default AdminBlacklist;
|
||||||
|
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const access_token = context.req.cookies.access_token;
|
||||||
|
|
||||||
|
const helpers = await TrpcAuthedFetchingIstance({ access_token });
|
||||||
|
if (helpers) {
|
||||||
|
await helpers.trpc.banlist.getBanlist.prefetch();
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.trpc.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
|
|
||||||
AdminBlacklist.getLayout = function getLayout(page) {
|
AdminBlacklist.getLayout = function getLayout(page) {
|
||||||
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { GetServerSideProps } from "next";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { Sidebar } from "~/components/area-riservata/sidebar";
|
import { Sidebar } from "~/components/area-riservata/sidebar";
|
||||||
import { ChatSidebar } from "~/components/chat/chat-sidebar";
|
import { ChatSidebar } from "~/components/chat/chat-sidebar";
|
||||||
|
|
@ -7,6 +8,7 @@ import { Status500 } from "~/components/status-page";
|
||||||
import type { NextPageWithLayout } from "~/pages/_app";
|
import type { NextPageWithLayout } from "~/pages/_app";
|
||||||
import { useTranslation } from "~/providers/I18nProvider";
|
import { useTranslation } from "~/providers/I18nProvider";
|
||||||
import { useSession } from "~/providers/SessionProvider";
|
import { useSession } from "~/providers/SessionProvider";
|
||||||
|
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const AdminChats: NextPageWithLayout = () => {
|
const AdminChats: NextPageWithLayout = () => {
|
||||||
|
|
@ -55,6 +57,24 @@ const AdminChats: NextPageWithLayout = () => {
|
||||||
};
|
};
|
||||||
export default AdminChats;
|
export default AdminChats;
|
||||||
|
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const access_token = context.req.cookies.access_token;
|
||||||
|
|
||||||
|
const helpers = await TrpcAuthedFetchingIstance({ access_token });
|
||||||
|
if (helpers) {
|
||||||
|
await helpers.trpc.chat.getActiveChats.prefetch();
|
||||||
|
await helpers.trpc.users.getActiveUsersWithoutChat.prefetch();
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.trpc.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
|
|
||||||
AdminChats.getLayout = function getLayout(page) {
|
AdminChats.getLayout = function getLayout(page) {
|
||||||
return (
|
return (
|
||||||
<div className="h-screen">
|
<div className="h-screen">
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { Plus, RefreshCcw } from "lucide-react";
|
import { Plus, RefreshCcw } from "lucide-react";
|
||||||
|
import type { GetServerSideProps } from "next";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { AreaRiservataLayout } from "~/components/Layout";
|
import { AreaRiservataLayout } from "~/components/Layout";
|
||||||
|
|
@ -17,6 +18,7 @@ import {
|
||||||
import { FormEtichette } from "~/forms/FormEtichette";
|
import { FormEtichette } from "~/forms/FormEtichette";
|
||||||
import type { NextPageWithLayout } from "~/pages/_app";
|
import type { NextPageWithLayout } from "~/pages/_app";
|
||||||
import type { Etichette } from "~/schemas/public/Etichette";
|
import type { Etichette } from "~/schemas/public/Etichette";
|
||||||
|
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const AdminEtichette: NextPageWithLayout = () => {
|
const AdminEtichette: NextPageWithLayout = () => {
|
||||||
|
|
@ -84,6 +86,23 @@ const AdminEtichette: NextPageWithLayout = () => {
|
||||||
};
|
};
|
||||||
export default AdminEtichette;
|
export default AdminEtichette;
|
||||||
|
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const access_token = context.req.cookies.access_token;
|
||||||
|
|
||||||
|
const helpers = await TrpcAuthedFetchingIstance({ access_token });
|
||||||
|
if (helpers) {
|
||||||
|
await helpers.trpc.settings.getAllEtichette.prefetch();
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.trpc.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
|
|
||||||
AdminEtichette.getLayout = function getLayout(page) {
|
AdminEtichette.getLayout = function getLayout(page) {
|
||||||
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { Plus, RefreshCcw } from "lucide-react";
|
import { Plus, RefreshCcw } from "lucide-react";
|
||||||
|
import type { GetServerSideProps } from "next";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { AreaRiservataLayout } from "~/components/Layout";
|
import { AreaRiservataLayout } from "~/components/Layout";
|
||||||
|
|
@ -15,6 +16,7 @@ import {
|
||||||
} from "~/components/ui/dialog";
|
} from "~/components/ui/dialog";
|
||||||
import { FormFlags, type initialValues } from "~/forms/FormFlags";
|
import { FormFlags, type initialValues } from "~/forms/FormFlags";
|
||||||
import type { NextPageWithLayout } from "~/pages/_app";
|
import type { NextPageWithLayout } from "~/pages/_app";
|
||||||
|
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const AdminFlags: NextPageWithLayout = () => {
|
const AdminFlags: NextPageWithLayout = () => {
|
||||||
|
|
@ -82,6 +84,23 @@ const AdminFlags: NextPageWithLayout = () => {
|
||||||
};
|
};
|
||||||
export default AdminFlags;
|
export default AdminFlags;
|
||||||
|
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const access_token = context.req.cookies.access_token;
|
||||||
|
|
||||||
|
const helpers = await TrpcAuthedFetchingIstance({ access_token });
|
||||||
|
if (helpers) {
|
||||||
|
await helpers.trpc.settings.GetFlags.prefetch();
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.trpc.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
|
|
||||||
AdminFlags.getLayout = function getLayout(page) {
|
AdminFlags.getLayout = function getLayout(page) {
|
||||||
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { GetServerSideProps } from "next";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { AreaRiservataLayout } from "~/components/Layout";
|
import { AreaRiservataLayout } from "~/components/Layout";
|
||||||
import { LoadingPage } from "~/components/loading";
|
import { LoadingPage } from "~/components/loading";
|
||||||
|
|
@ -5,6 +6,7 @@ import { Status500 } from "~/components/status-page";
|
||||||
import { OrdiniTable } from "~/components/tables/orders-table";
|
import { OrdiniTable } from "~/components/tables/orders-table";
|
||||||
import type { NextPageWithLayout } from "~/pages/_app";
|
import type { NextPageWithLayout } from "~/pages/_app";
|
||||||
import { useTranslation } from "~/providers/I18nProvider";
|
import { useTranslation } from "~/providers/I18nProvider";
|
||||||
|
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const Ordini: NextPageWithLayout = () => {
|
const Ordini: NextPageWithLayout = () => {
|
||||||
|
|
@ -36,6 +38,23 @@ const Ordini: NextPageWithLayout = () => {
|
||||||
};
|
};
|
||||||
export default Ordini;
|
export default Ordini;
|
||||||
|
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const access_token = context.req.cookies.access_token;
|
||||||
|
|
||||||
|
const helpers = await TrpcAuthedFetchingIstance({ access_token });
|
||||||
|
if (helpers) {
|
||||||
|
await helpers.trpc.servizio.getOrdini.prefetch({});
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.trpc.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
|
|
||||||
Ordini.getLayout = function getLayout(page) {
|
Ordini.getLayout = function getLayout(page) {
|
||||||
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ import type {
|
||||||
Prezziario,
|
Prezziario,
|
||||||
PrezziarioIdprezziario,
|
PrezziarioIdprezziario,
|
||||||
} from "~/schemas/public/Prezziario";
|
} from "~/schemas/public/Prezziario";
|
||||||
|
import { generateSSGHelper } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const Admin_Prezziario: NextPageWithLayout = () => {
|
const Admin_Prezziario: NextPageWithLayout = () => {
|
||||||
|
|
@ -72,6 +73,18 @@ const Admin_Prezziario: NextPageWithLayout = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export async function getServerSideProps() {
|
||||||
|
const helpers = generateSSGHelper();
|
||||||
|
|
||||||
|
await helpers.prezziario.getPrezziario.prefetch();
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default Admin_Prezziario;
|
export default Admin_Prezziario;
|
||||||
|
|
||||||
Admin_Prezziario.getLayout = function getLayout(page) {
|
Admin_Prezziario.getLayout = function getLayout(page) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { ChevronsUpDown, RefreshCcw } from "lucide-react";
|
import { ChevronsUpDown, RefreshCcw } from "lucide-react";
|
||||||
|
import type { GetServerSideProps } from "next";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { AreaRiservataLayout } from "~/components/Layout";
|
import { AreaRiservataLayout } from "~/components/Layout";
|
||||||
|
|
@ -42,6 +43,7 @@ import type {
|
||||||
StorageindexId,
|
StorageindexId,
|
||||||
} from "~/schemas/public/Storageindex";
|
} from "~/schemas/public/Storageindex";
|
||||||
import type { Users } from "~/schemas/public/Users";
|
import type { Users } from "~/schemas/public/Users";
|
||||||
|
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const AdminStorage: NextPageWithLayout = () => {
|
const AdminStorage: NextPageWithLayout = () => {
|
||||||
|
|
@ -91,6 +93,23 @@ const AdminStorage: NextPageWithLayout = () => {
|
||||||
</StorageTableProvider>
|
</StorageTableProvider>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const access_token = context.req.cookies.access_token;
|
||||||
|
|
||||||
|
const helpers = await TrpcAuthedFetchingIstance({ access_token });
|
||||||
|
if (helpers) {
|
||||||
|
await helpers.trpc.storage.getAll.prefetch();
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.trpc.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
export default AdminStorage;
|
export default AdminStorage;
|
||||||
|
|
||||||
const StorageTableHeader = ({
|
const StorageTableHeader = ({
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { Plus, RefreshCcw } from "lucide-react";
|
import { Plus, RefreshCcw } from "lucide-react";
|
||||||
|
import type { GetServerSideProps } from "next";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import toast from "react-hot-toast";
|
import toast from "react-hot-toast";
|
||||||
import { AreaRiservataLayout } from "~/components/Layout";
|
import { AreaRiservataLayout } from "~/components/Layout";
|
||||||
|
|
@ -17,6 +18,7 @@ import {
|
||||||
import { FormStringhe } from "~/forms/FormStringhe";
|
import { FormStringhe } from "~/forms/FormStringhe";
|
||||||
import type { NextPageWithLayout } from "~/pages/_app";
|
import type { NextPageWithLayout } from "~/pages/_app";
|
||||||
import type { TestiEStringhe } from "~/schemas/public/TestiEStringhe";
|
import type { TestiEStringhe } from "~/schemas/public/TestiEStringhe";
|
||||||
|
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const AdminTestiStringhe: NextPageWithLayout = () => {
|
const AdminTestiStringhe: NextPageWithLayout = () => {
|
||||||
|
|
@ -82,6 +84,23 @@ const AdminTestiStringhe: NextPageWithLayout = () => {
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const access_token = context.req.cookies.access_token;
|
||||||
|
|
||||||
|
const helpers = await TrpcAuthedFetchingIstance({ access_token });
|
||||||
|
if (helpers) {
|
||||||
|
await helpers.trpc.settings.getStringhe.prefetch();
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.trpc.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
export default AdminTestiStringhe;
|
export default AdminTestiStringhe;
|
||||||
|
|
||||||
AdminTestiStringhe.getLayout = function getLayout(page) {
|
AdminTestiStringhe.getLayout = function getLayout(page) {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
import { RefreshCcw } from "lucide-react";
|
import { RefreshCcw } from "lucide-react";
|
||||||
|
import type { GetServerSideProps } from "next";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { AreaRiservataLayout } from "~/components/Layout";
|
import { AreaRiservataLayout } from "~/components/Layout";
|
||||||
import { LoadingPage } from "~/components/loading";
|
import { LoadingPage } from "~/components/loading";
|
||||||
|
|
@ -16,6 +17,7 @@ import {
|
||||||
import { FormNewUser } from "~/forms/FormNewUser";
|
import { FormNewUser } from "~/forms/FormNewUser";
|
||||||
|
|
||||||
import type { NextPageWithLayout } from "~/pages/_app";
|
import type { NextPageWithLayout } from "~/pages/_app";
|
||||||
|
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
||||||
|
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
|
|
@ -56,6 +58,23 @@ const Admin_Utenti: NextPageWithLayout = () => {
|
||||||
|
|
||||||
export default Admin_Utenti;
|
export default Admin_Utenti;
|
||||||
|
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const access_token = context.req.cookies.access_token;
|
||||||
|
|
||||||
|
const helpers = await TrpcAuthedFetchingIstance({ access_token });
|
||||||
|
if (helpers) {
|
||||||
|
await helpers.trpc.users.getUsersWChatInfo.prefetch();
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.trpc.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
|
|
||||||
Admin_Utenti.getLayout = function getLayout(page) {
|
Admin_Utenti.getLayout = function getLayout(page) {
|
||||||
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,12 @@ const Allegati: NextPageWithLayout = () => {
|
||||||
};
|
};
|
||||||
export default Allegati;
|
export default Allegati;
|
||||||
|
|
||||||
|
export async function getServerSideProps() {
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Allegati.getLayout = function getLayout(page) {
|
Allegati.getLayout = function getLayout(page) {
|
||||||
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,11 @@ const Comunicazioni: NextPageWithLayout = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
export default Comunicazioni;
|
export default Comunicazioni;
|
||||||
|
export async function getServerSideProps() {
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Comunicazioni.getLayout = function getLayout(page) {
|
Comunicazioni.getLayout = function getLayout(page) {
|
||||||
return <AreaRiservataLayout noFooter>{page}</AreaRiservataLayout>;
|
return <AreaRiservataLayout noFooter>{page}</AreaRiservataLayout>;
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,12 @@ const Dashboard: NextPageWithLayout = () => {
|
||||||
|
|
||||||
export default Dashboard;
|
export default Dashboard;
|
||||||
|
|
||||||
|
export async function getServerSideProps() {
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
Dashboard.getLayout = function getLayout(page) {
|
Dashboard.getLayout = function getLayout(page) {
|
||||||
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { GetServerSideProps } from "next";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { AreaRiservataLayout } from "~/components/Layout";
|
import { AreaRiservataLayout } from "~/components/Layout";
|
||||||
import { LoadingPage } from "~/components/loading";
|
import { LoadingPage } from "~/components/loading";
|
||||||
|
|
@ -7,6 +8,7 @@ import type { NextPageWithLayout } from "~/pages/_app";
|
||||||
import { useTranslation } from "~/providers/I18nProvider";
|
import { useTranslation } from "~/providers/I18nProvider";
|
||||||
import { useEnforcedSession } from "~/providers/SessionProvider";
|
import { useEnforcedSession } from "~/providers/SessionProvider";
|
||||||
import type { UsersId } from "~/schemas/public/Users";
|
import type { UsersId } from "~/schemas/public/Users";
|
||||||
|
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const Ordini: NextPageWithLayout = () => {
|
const Ordini: NextPageWithLayout = () => {
|
||||||
|
|
@ -24,6 +26,23 @@ const Ordini: NextPageWithLayout = () => {
|
||||||
};
|
};
|
||||||
export default Ordini;
|
export default Ordini;
|
||||||
|
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const access_token = context.req.cookies.access_token;
|
||||||
|
|
||||||
|
const helpers = await TrpcAuthedFetchingIstance({ access_token });
|
||||||
|
if (helpers) {
|
||||||
|
await helpers.trpc.servizio.getOrdini.prefetch({});
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.trpc.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
|
|
||||||
const SessionWrapper = ({ userId }: { userId: UsersId }) => {
|
const SessionWrapper = ({ userId }: { userId: UsersId }) => {
|
||||||
const { data, isLoading } = api.servizio.getOrdini.useQuery({
|
const { data, isLoading } = api.servizio.getOrdini.useQuery({
|
||||||
userId,
|
userId,
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import type { GetServerSideProps } from "next";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { AreaRiservataLayout } from "~/components/Layout";
|
import { AreaRiservataLayout } from "~/components/Layout";
|
||||||
import { LoadingPage } from "~/components/loading";
|
import { LoadingPage } from "~/components/loading";
|
||||||
|
|
@ -17,6 +18,7 @@ import { ProfileFormAnagrafica } from "~/forms/FormProfilo_Anagrafica";
|
||||||
import type { NextPageWithLayout } from "~/pages/_app";
|
import type { NextPageWithLayout } from "~/pages/_app";
|
||||||
import { useTranslation } from "~/providers/I18nProvider";
|
import { useTranslation } from "~/providers/I18nProvider";
|
||||||
import { useEnforcedSession } from "~/providers/SessionProvider";
|
import { useEnforcedSession } from "~/providers/SessionProvider";
|
||||||
|
import { TrpcAuthedFetchingIstance } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const Dashboard: NextPageWithLayout = () => {
|
const Dashboard: NextPageWithLayout = () => {
|
||||||
|
|
@ -114,6 +116,23 @@ const Dashboard: NextPageWithLayout = () => {
|
||||||
};
|
};
|
||||||
export default Dashboard;
|
export default Dashboard;
|
||||||
|
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const access_token = context.req.cookies.access_token;
|
||||||
|
|
||||||
|
const helpers = await TrpcAuthedFetchingIstance({ access_token });
|
||||||
|
if (helpers) {
|
||||||
|
await helpers.trpc.users.getClientProfilo.prefetch({ id: undefined });
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.trpc.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
|
|
||||||
Dashboard.getLayout = function getLayout(page) {
|
Dashboard.getLayout = function getLayout(page) {
|
||||||
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
return <AreaRiservataLayout>{page}</AreaRiservataLayout>;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -20,4 +20,9 @@ const NewPasswordResetPage: NextPage = () => {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
export async function getServerSideProps() {
|
||||||
|
return {
|
||||||
|
props: {},
|
||||||
|
};
|
||||||
|
}
|
||||||
export default NewPasswordResetPage;
|
export default NewPasswordResetPage;
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import { Status500 } from "~/components/status-page";
|
||||||
import { Separator } from "~/components/ui/separator";
|
import { Separator } from "~/components/ui/separator";
|
||||||
import { useTranslation } from "~/providers/I18nProvider";
|
import { useTranslation } from "~/providers/I18nProvider";
|
||||||
import TipologiaPosizioneEnum from "~/schemas/public/TipologiaPosizioneEnum";
|
import TipologiaPosizioneEnum from "~/schemas/public/TipologiaPosizioneEnum";
|
||||||
|
import { generateSSGHelper } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const Prezzi: NextPage = () => {
|
const Prezzi: NextPage = () => {
|
||||||
|
|
@ -191,4 +192,14 @@ const Prezzi: NextPage = () => {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
export async function getServerSideProps() {
|
||||||
|
const helper = generateSSGHelper();
|
||||||
|
await helper.prezziario.getPrezziPerTipologiaAll.fetch();
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helper.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export default Prezzi;
|
export default Prezzi;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import type { NextPage } from "next";
|
import type { GetServerSideProps, NextPage } from "next";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { useTranslation } from "~/providers/I18nProvider";
|
import { useTranslation } from "~/providers/I18nProvider";
|
||||||
import type { TestiEStringheStingaId } from "~/schemas/public/TestiEStringhe";
|
import type { TestiEStringheStingaId } from "~/schemas/public/TestiEStringhe";
|
||||||
|
import { generateSSGHelper } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const PrivacyPolicy: NextPage = () => {
|
const PrivacyPolicy: NextPage = () => {
|
||||||
|
|
@ -31,4 +32,19 @@ const PrivacyPolicy: NextPage = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const locale = context.locale || "it";
|
||||||
|
const key = locale === "en" ? "PRIVACY_POLICY_ENG" : "PRIVACY_POLICY";
|
||||||
|
const helpers = generateSSGHelper();
|
||||||
|
|
||||||
|
await helpers.settings.getStringa.prefetch({
|
||||||
|
stringaId: key as TestiEStringheStingaId,
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
|
|
||||||
export default PrivacyPolicy;
|
export default PrivacyPolicy;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
import type { NextPage } from "next";
|
import type { GetServerSideProps, NextPage } from "next";
|
||||||
import Head from "next/head";
|
import Head from "next/head";
|
||||||
import { useTranslation } from "~/providers/I18nProvider";
|
import { useTranslation } from "~/providers/I18nProvider";
|
||||||
import type { TestiEStringheStingaId } from "~/schemas/public/TestiEStringhe";
|
import type { TestiEStringheStingaId } from "~/schemas/public/TestiEStringhe";
|
||||||
|
import { generateSSGHelper } from "~/server/utils/ssgHelper";
|
||||||
import { api } from "~/utils/api";
|
import { api } from "~/utils/api";
|
||||||
|
|
||||||
const Termini_Condizioni: NextPage = () => {
|
const Termini_Condizioni: NextPage = () => {
|
||||||
|
|
@ -30,4 +31,19 @@ const Termini_Condizioni: NextPage = () => {
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
export const getServerSideProps = (async (context) => {
|
||||||
|
const locale = context.locale || "it";
|
||||||
|
const key = locale === "en" ? "TERMINI_CONDIZIONI_ENG" : "TERMINI_CONDIZIONI";
|
||||||
|
const helpers = generateSSGHelper();
|
||||||
|
|
||||||
|
await helpers.settings.getStringa.prefetch({
|
||||||
|
stringaId: key as TestiEStringheStingaId,
|
||||||
|
});
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
trpcState: helpers.dehydrate(),
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}) satisfies GetServerSideProps;
|
||||||
|
|
||||||
export default Termini_Condizioni;
|
export default Termini_Condizioni;
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,8 @@ import { usersRouter } from "~/server/api/routers/users";
|
||||||
import { createTRPCRouter } from "~/server/api/trpc";
|
import { createTRPCRouter } from "~/server/api/trpc";
|
||||||
import { syncRouter } from "./routers/sync";
|
import { syncRouter } from "./routers/sync";
|
||||||
|
|
||||||
|
//import { lazy } from '@trpc/server';
|
||||||
|
|
||||||
export const appRouter = createTRPCRouter({
|
export const appRouter = createTRPCRouter({
|
||||||
annunci: annunciRouter,
|
annunci: annunciRouter,
|
||||||
auth: authRouter,
|
auth: authRouter,
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import {
|
||||||
adminProcedure,
|
adminProcedure,
|
||||||
createTRPCRouter,
|
createTRPCRouter,
|
||||||
protectedProcedure,
|
protectedProcedure,
|
||||||
publicProcedure,
|
|
||||||
} from "~/server/api/trpc";
|
} from "~/server/api/trpc";
|
||||||
import {
|
import {
|
||||||
blockUserHandler,
|
blockUserHandler,
|
||||||
|
|
@ -93,7 +92,7 @@ export const usersRouter = createTRPCRouter({
|
||||||
|
|
||||||
return query;
|
return query;
|
||||||
}),
|
}),
|
||||||
getUsersWChatInfo: publicProcedure.query(async () => {
|
getUsersWChatInfo: adminProcedure.query(async () => {
|
||||||
return await getUsersWithChatInfoHandler({ db });
|
return await getUsersWithChatInfoHandler({ db });
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue