Middleware and login updates
This commit is contained in:
parent
484e8689a4
commit
4517241ead
23 changed files with 144 additions and 112 deletions
|
|
@ -22,7 +22,7 @@ const Link = () => (
|
|||
}}
|
||||
>
|
||||
<ZammadWrapper
|
||||
url="http://localhost:3000/zammad/#manage"
|
||||
path="/#manage"
|
||||
hideSidebar={false}
|
||||
/>
|
||||
</Grid>
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import NextAuth from "next-auth";
|
||||
import Google from "next-auth/providers/google";
|
||||
import Apple from "next-auth/providers/apple";
|
||||
// import Apple from "next-auth/providers/apple";
|
||||
|
||||
export default NextAuth({
|
||||
providers: [
|
||||
|
|
@ -8,10 +8,12 @@ export default NextAuth({
|
|||
clientId: process.env.GOOGLE_CLIENT_ID,
|
||||
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
|
||||
}),
|
||||
/*
|
||||
Apple({
|
||||
clientId: process.env.APPLE_CLIENT_ID,
|
||||
clientSecret: process.env.APPLE_CLIENT_SECRET
|
||||
}),
|
||||
*/
|
||||
],
|
||||
secret: process.env.NEXTAUTH_SECRET,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const Home = () => (
|
|||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<ZammadWrapper url="https://8003-digiresilienc-linkshell-c2tqwgcccbs.ws-eu86.gitpod.io/zammad/#dashboard" />
|
||||
<ZammadWrapper path="/#dashboard" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Layout>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const Link = () => (
|
|||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<ZammadWrapper url="http://localhost:3000/zammad/#ticket/zoom/518/1490" />
|
||||
<ZammadWrapper path="/zammad/#ticket/zoom/518/1490" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Layout>
|
||||
|
|
|
|||
|
|
@ -40,13 +40,15 @@ const Login = ({ session }) => {
|
|||
sx={buttonStyles}
|
||||
onClick={() =>
|
||||
signIn("google", {
|
||||
callbackUrl: `${window.location.origin}/setup`,
|
||||
callbackUrl: `https://redaranj-bookish-tribble-56jwjx5wh4j4w-8003.preview.app.github.dev/auth/sso`,
|
||||
})
|
||||
}
|
||||
>
|
||||
<GoogleIcon sx={{ mr: 1 }} />
|
||||
Google
|
||||
</IconButton>
|
||||
</Grid>
|
||||
{/*
|
||||
<Grid item sx={{ width: "100%" }}>
|
||||
<IconButton
|
||||
sx={buttonStyles}
|
||||
|
|
@ -58,7 +60,7 @@ const Login = ({ session }) => {
|
|||
>
|
||||
<AppleIcon sx={{ mr: 1 }} />
|
||||
</IconButton>
|
||||
</Grid>
|
||||
</Grid>*/}
|
||||
<Grid item sx={{ mt: 2 }} />
|
||||
</Grid>
|
||||
) : null}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ const Profile = () => (
|
|||
}}
|
||||
>
|
||||
<ZammadWrapper
|
||||
url="http://localhost:3000/zammad/#profile"
|
||||
path="/#profile"
|
||||
hideSidebar={false}
|
||||
/>
|
||||
</Grid>
|
||||
|
|
|
|||
|
|
@ -1,54 +0,0 @@
|
|||
import Head from "next/head";
|
||||
import { NextPage, GetServerSideProps, GetServerSidePropsContext } from "next";
|
||||
import { Grid, Box } from "@mui/material";
|
||||
import { Layout } from "components/Layout";
|
||||
import { TicketDetail } from "components/TicketDetail";
|
||||
import { TicketEdit } from "components/TicketEdit";
|
||||
|
||||
const Link: NextPage = ({ ticket, articles }: any) => (
|
||||
<Layout>
|
||||
<Head>
|
||||
<title>Link Shell</title>
|
||||
</Head>
|
||||
<Grid container spacing={0} sx={{ height: "100vh" }} direction="row">
|
||||
<Grid item sx={{ height: "100vh" }} xs={10}>
|
||||
<TicketDetail ticket={ticket} articles={articles} />
|
||||
</Grid>
|
||||
<Grid item xs={2} sx={{ height: "100vh" }}>
|
||||
<TicketEdit ticket={ticket} />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Layout>
|
||||
);
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (
|
||||
context: GetServerSidePropsContext
|
||||
) => {
|
||||
const {
|
||||
params: { id },
|
||||
} = context;
|
||||
const baseURL = `${process.env.ZAMMAD_URL}/api/v1`;
|
||||
const token = process.env.ZAMMAD_API_TOKEN;
|
||||
const headers = { Authorization: `Token ${token}` };
|
||||
const rawTicket = await fetch(`${baseURL}/tickets/${id}`, {
|
||||
headers,
|
||||
});
|
||||
const ticket = await rawTicket.json();
|
||||
const rawArticles = await fetch(
|
||||
`${baseURL}/ticket_articles/by_ticket/${id}`,
|
||||
{
|
||||
headers,
|
||||
}
|
||||
);
|
||||
const articles = await rawArticles.json();
|
||||
|
||||
console.log({ ticket, articles });
|
||||
|
||||
return {
|
||||
props: {
|
||||
ticket,
|
||||
articles,
|
||||
},
|
||||
};
|
||||
};
|
||||
export default Link;
|
||||
58
apps/link/pages/tickets/[id].tsx
Normal file
58
apps/link/pages/tickets/[id].tsx
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import { GetServerSideProps, GetServerSidePropsContext } from "next";
|
||||
import Head from "next/head";
|
||||
import useSWR from "swr";
|
||||
import { NextPage } from "next";
|
||||
import { Grid, } from "@mui/material";
|
||||
import { Layout } from "components/Layout";
|
||||
import { TicketDetail } from "components/TicketDetail";
|
||||
import { TicketEdit } from "components/TicketEdit";
|
||||
|
||||
type TicketProps = {
|
||||
id: string;
|
||||
};
|
||||
|
||||
const Ticket: NextPage<TicketProps> = ({ id }) => {
|
||||
const fetcher = async (url: string) => {
|
||||
const res = await fetch(url);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
const { data: ticketData, error: ticketError } = useSWR(
|
||||
`https://redaranj-bookish-tribble-56jwjx5wh4j4w-8003.preview.app.github.dev/api/v1/tickets/${id}`,
|
||||
fetcher
|
||||
);
|
||||
|
||||
const { data: articlesData, error: articlesError } = useSWR(
|
||||
`https://redaranj-bookish-tribble-56jwjx5wh4j4w-8003.preview.app.github.dev/api/v1/ticket_articles/by_ticket/${id}`,
|
||||
fetcher
|
||||
);
|
||||
|
||||
const shouldRender = !ticketError && !articlesError && ticketData && articlesData && !ticketData.error && !articlesData.error;
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
<Head>
|
||||
<title>Link Shell</title>
|
||||
</Head>
|
||||
{shouldRender && (
|
||||
<Grid container spacing={0} sx={{ height: "100vh" }} direction="row">
|
||||
<Grid item sx={{ height: "100vh" }} xs={10}>
|
||||
|
||||
<TicketDetail ticket={ticketData} articles={articlesData} />
|
||||
</Grid>
|
||||
<Grid item xs={2} sx={{ height: "100vh" }}>
|
||||
<TicketEdit ticket={ticketData} />
|
||||
</Grid>
|
||||
</Grid>)}
|
||||
{ticketError && <div>{ticketError.toString()}</div>}
|
||||
</Layout>
|
||||
);
|
||||
}
|
||||
|
||||
export const getServerSideProps: GetServerSideProps = async (
|
||||
context: GetServerSidePropsContext) => {
|
||||
const { id } = context.query;
|
||||
return { props: { id } };
|
||||
}
|
||||
|
||||
export default Ticket;
|
||||
|
|
@ -21,7 +21,7 @@ const Link = () => (
|
|||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<ZammadWrapper url="http://localhost:8003/zammad/#ticket/view/my_tickets" />
|
||||
<ZammadWrapper path="/#ticket/view/my_tickets" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Layout>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const Link = () => (
|
|||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<ZammadWrapper url="http://localhost:3000/zammad/#ticket/view/my_pending_reached" />
|
||||
<ZammadWrapper path="/#ticket/view/my_pending_reached" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Layout>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const Link = () => (
|
|||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<ZammadWrapper url="http://localhost:3000/zammad/#ticket/view/all_unassigned" />
|
||||
<ZammadWrapper path="/#ticket/view/all_unassigned" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Layout>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const Link = () => (
|
|||
width: "100%",
|
||||
}}
|
||||
>
|
||||
<ZammadWrapper url="http://localhost:3000/zammad/#ticket/view/all_escalated" />
|
||||
<ZammadWrapper path="/#ticket/view/all_escalated" />
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Layout>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue