control bar shows conditionally based on if user is signed in
This commit is contained in:
parent
6fc925da87
commit
6bcd20897d
@ -1,3 +1,5 @@
|
|||||||
|
import { useSession } from "next-auth/react";
|
||||||
|
|
||||||
const AdminBarLayout = ({
|
const AdminBarLayout = ({
|
||||||
actions,
|
actions,
|
||||||
children,
|
children,
|
||||||
@ -5,14 +7,18 @@ const AdminBarLayout = ({
|
|||||||
actions: JSX.Element | JSX.Element[];
|
actions: JSX.Element | JSX.Element[];
|
||||||
children: JSX.Element | JSX.Element[];
|
children: JSX.Element | JSX.Element[];
|
||||||
}) => {
|
}) => {
|
||||||
|
const { data } = useSession();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
|
{data?.user ? (
|
||||||
<div className="sticky left-0 right-0 top-[71px] z-10 mx-auto mb-6 mt-[15px] flex max-w-4xl flex-row justify-between rounded-xl border border-neutral-600 bg-red-300 drop-shadow-xl">
|
<div className="sticky left-0 right-0 top-[71px] z-10 mx-auto mb-6 mt-[15px] flex max-w-4xl flex-row justify-between rounded-xl border border-neutral-600 bg-red-300 drop-shadow-xl">
|
||||||
<h1 className="rounded-lg px-4 py-2 font-semibold text-black">
|
<h1 className="rounded-lg px-4 py-2 font-semibold text-black">
|
||||||
Admin Mode
|
Admin Mode
|
||||||
</h1>
|
</h1>
|
||||||
<div className="flex flex-row space-x-2 p-1">{actions}</div>
|
<div className="flex flex-row space-x-2 p-1">{actions}</div>
|
||||||
</div>
|
</div>
|
||||||
|
) : undefined}
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
import Footer from "~/components/Footer";
|
||||||
|
import Header from "~/components/Header";
|
||||||
|
|
||||||
|
const EditResourcePage = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Header />
|
||||||
|
<Footer />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EditResourcePage;
|
@ -13,6 +13,7 @@ import Footer from "~/components/Footer";
|
|||||||
import Header from "~/components/Header";
|
import Header from "~/components/Header";
|
||||||
import { AdminBarLayout } from "~/components/admin/ControlBar";
|
import { AdminBarLayout } from "~/components/admin/ControlBar";
|
||||||
import { AdminActionLink } from "~/components/admin/common";
|
import { AdminActionLink } from "~/components/admin/common";
|
||||||
|
import { useRouter } from "next/router";
|
||||||
|
|
||||||
export const getStaticPaths = async () => {
|
export const getStaticPaths = async () => {
|
||||||
const resources = await prisma.auditoryResource.findMany({
|
const resources = await prisma.auditoryResource.findMany({
|
||||||
@ -127,6 +128,7 @@ const ResourceViewPage = (
|
|||||||
) => {
|
) => {
|
||||||
const { id } = props;
|
const { id } = props;
|
||||||
const resourceQuery = api.auditoryResource.byId.useQuery({ id });
|
const resourceQuery = api.auditoryResource.byId.useQuery({ id });
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
if (!resourceQuery.data) {
|
if (!resourceQuery.data) {
|
||||||
return <></>;
|
return <></>;
|
||||||
@ -141,7 +143,7 @@ const ResourceViewPage = (
|
|||||||
<AdminActionLink
|
<AdminActionLink
|
||||||
symbol={<PencilSquareIcon className="w-4" />}
|
symbol={<PencilSquareIcon className="w-4" />}
|
||||||
label="Edit Page"
|
label="Edit Page"
|
||||||
href="/"
|
href={`${router.asPath}/edit`}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user