fix issue with ssg for resources
This commit is contained in:
parent
a174aafbf2
commit
9fb09d9585
@ -1,7 +1,7 @@
|
||||
import { type NextPage } from "next/types";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { signOut, useSession } from "next-auth/react";
|
||||
|
||||
interface QuickLink {
|
||||
label: string;
|
||||
@ -97,12 +97,26 @@ const ContactInfo = ({ name, title, email, phone }: ContactInfo) => {
|
||||
const AdminLogin = () => {
|
||||
const { data: sessionData } = useSession();
|
||||
|
||||
if (sessionData?.user) {
|
||||
return (
|
||||
<button
|
||||
onClick={() => {
|
||||
void signOut();
|
||||
}}
|
||||
className="text-sm text-neutral-300 hover:underline"
|
||||
type="submit"
|
||||
>
|
||||
Logout of Site Admin
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<Link
|
||||
className="text-sm text-neutral-300 hover:underline"
|
||||
href={sessionData?.user ? "/admin/logout" : "/admin/login"}
|
||||
href="/admin/login"
|
||||
>
|
||||
{sessionData?.user ? "Logout of Site Admin" : "Site Admin Login"}
|
||||
Site Admin Login
|
||||
</Link>
|
||||
);
|
||||
};
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { type InferGetStaticPropsType, type GetStaticPropsContext } from "next";
|
||||
import { GlobeAltIcon, DocumentIcon } from "@heroicons/react/24/solid";
|
||||
import { createProxySSGHelpers } from "@trpc/react-query/ssg";
|
||||
import { createServerSideHelpers } from "@trpc/react-query/server";
|
||||
import { appRouter } from "~/server/api/root";
|
||||
import { prisma } from "~/server/db";
|
||||
import { api } from "~/utils/api";
|
||||
@ -31,20 +31,21 @@ export const getStaticPaths = async () => {
|
||||
export async function getStaticProps(
|
||||
context: GetStaticPropsContext<{ id: string }>
|
||||
) {
|
||||
const ssg = createProxySSGHelpers({
|
||||
const helpers = createServerSideHelpers({
|
||||
router: appRouter,
|
||||
ctx: {
|
||||
prisma,
|
||||
session: null,
|
||||
},
|
||||
});
|
||||
|
||||
const id = context.params?.id as string;
|
||||
|
||||
await ssg.auditoryResource.byId.prefetch({ id });
|
||||
await helpers.auditoryResource.byId.prefetch({ id });
|
||||
|
||||
return {
|
||||
props: {
|
||||
trpcState: ssg.dehydrate(),
|
||||
trpcState: helpers.dehydrate(),
|
||||
id,
|
||||
},
|
||||
revalidate: 1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user