Middleware and login updates

This commit is contained in:
Darren Clarke 2023-02-22 13:05:52 +00:00
parent 484e8689a4
commit 4517241ead
23 changed files with 144 additions and 112 deletions

View file

@ -24,6 +24,7 @@ import { useRouter } from "next/router";
import Link from "next/link";
import Image from "next/image";
import LinkLogo from "public/link-logo-small.png";
import { useSession } from "next-auth/react";
const openWidth = 270;
const closedWidth = 100;
@ -152,7 +153,8 @@ interface SidebarProps {
export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
const { pathname } = useRouter();
const [username, setUsername] = useState("Nicholas Smith");
const { data: session } = useSession()
const username = session?.user?.name || "User"
return (
<Drawer
@ -273,9 +275,9 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
{open
? username
: username
.split(" ")
.map((name) => name.substring(0, 1))
.join("")}
.split(" ")
.map((name) => name.substring(0, 1))
.join("")}
</Typography>
</Grid>
<Grid item>
@ -384,10 +386,10 @@ export const Sidebar: FC<SidebarProps> = ({ open, setOpen }) => {
/>
<MenuItem
name="New Ticket UI"
href="/tickets/181"
href="/tickets/2"
Icon={SettingsIcon}
iconSize={0}
selected={pathname.endsWith("/tickets/181")}
selected={pathname.endsWith("/tickets/2")}
open={open}
/>
</List>

View file

@ -2,24 +2,26 @@ import { FC, useState } from "react";
import Iframe from "react-iframe";
type ZammadWrapperProps = {
url: string;
path: string;
hideSidebar?: boolean;
};
export const ZammadWrapper: FC<ZammadWrapperProps> = ({
url,
path,
hideSidebar = true,
}) => {
const [display, setDisplay] = useState("inherit");
const [display, setDisplay] = useState("hidden");
const url = `https://redaranj-bookish-tribble-56jwjx5wh4j4w-8003.preview.app.github.dev/zammad${path}`;
console.log({ base: process.env.LINK_URL, path, url })
return (
<Iframe
< Iframe
id="link"
url={url}
width="100%"
height="100%"
frameBorder={0}
styles={{ display }}
styles={{ display }
}
onLoad={() => {
const linkElement = document.querySelector("iframe");
if (