Skip to content

Commit

Permalink
client portal tomfoolery
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Mar 26, 2024
1 parent 3b7b37a commit 32be0de
Show file tree
Hide file tree
Showing 5 changed files with 383 additions and 60 deletions.
1 change: 1 addition & 0 deletions apps/api/src/controllers/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ export function authRoutes(fastify: FastifyInstance) {
sso_status: config!.sso_active,
version: config!.client_version,
notifcations,
external_user: user!.external_user,
};

reply.send({
Expand Down
19 changes: 9 additions & 10 deletions apps/client/layouts/newLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,10 @@ export default function NewLayout({ children }: any) {
alert("You do not have the correct perms for that action.");
}

if (user && user.external_user) {
location.push("/portal");
}

const navigation = [
{
name: t("create_ticket"),
Expand Down Expand Up @@ -437,14 +441,6 @@ export default function NewLayout({ children }: any) {
await fetchUserProfile();
}

// useEffect(() => {
// getQueues();
// }, [user]);

// useEffect(() => {
// getQueues();
// }, [user])

function handleKeyPress(event: any) {
const pathname = location.pathname;
console.log(pathname);
Expand Down Expand Up @@ -493,7 +489,8 @@ export default function NewLayout({ children }: any) {
}, [handleKeyPress, location]);

return (
!loading && (
!loading &&
user && (
<div className="min-h-screen overflow-hidden bg-white dark:bg-[#0A090C]">
<Transition.Root show={sidebarOpen} as={Fragment}>
<Dialog
Expand Down Expand Up @@ -1132,7 +1129,9 @@ export default function NewLayout({ children }: any) {
</div>
</div>

<main className="bg-white dark:bg-[#0A090C]">{children}</main>
{!loading && !user.external_user && (
<main className="bg-white dark:bg-[#0A090C]">{children}</main>
)}
</div>
</div>
)
Expand Down
4 changes: 2 additions & 2 deletions apps/client/layouts/portalLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ export default function PortalLayout({ children }: any) {
leaveTo="transform opacity-0 scale-95"
>
<Menu.Items className="bg-white absolute right-0 z-50 w-40 origin-top-right rounded-md shadow-lg ring-1 ring-gray-900/5 focus:outline-none">
<Menu.Item>
{/* <Menu.Item>
{({ active }) => (
<Link
href="/settings/profile"
Expand All @@ -506,7 +506,7 @@ export default function PortalLayout({ children }: any) {
{t("profile")}
</Link>
)}
</Menu.Item>
</Menu.Item> */}
<Menu.Item>
{({ active }) => (
<button
Expand Down
88 changes: 43 additions & 45 deletions apps/client/pages/portal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Link from "next/link";
import { useEffect, useState } from "react";

import useTranslation from "next-translate/useTranslation";
Expand All @@ -22,55 +21,54 @@ export default function Home() {
const [loading, setLoading] = useState(true);
const [tickets, setTickets] = useState<any>();

async function getOpenTickets() {
await fetch(`/api/v1/data/tickets/open`, {
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => res.json())
.then((res) => {
setOpenTickets(res.count);
});
}
// async function getOpenTickets() {
// await fetch(`/api/v1/data/tickets/open`, {
// method: "GET",
// headers: {
// Authorization: `Bearer ${token}`,
// },
// })
// .then((res) => res.json())
// .then((res) => {
// setOpenTickets(res.count);
// });
// }

async function getCompletedTickets() {
await fetch(`/api/v1/data/tickets/completed`, {
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => res.json())
.then((res) => {
setCompletedTickets(res.count);
});
}
// async function getCompletedTickets() {
// await fetch(`/api/v1/data/tickets/completed`, {
// method: "GET",
// headers: {
// Authorization: `Bearer ${token}`,
// },
// })
// .then((res) => res.json())
// .then((res) => {
// setCompletedTickets(res.count);
// });
// }

async function getUnassginedTickets() {
await fetch(`/api/v1/data/tickets/open`, {
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => res.json())
.then((res) => {
setUnassigned(res.count);
});
}
// async function getUnassginedTickets() {
// await fetch(`/api/v1/data/tickets/open`, {
// method: "GET",
// headers: {
// Authorization: `Bearer ${token}`,
// },
// })
// .then((res) => res.json())
// .then((res) => {
// setUnassigned(res.count);
// });
// }

async function fetchTickets() {
await fetch(`/api/v1/tickets/open`, {
await fetch(`/api/v1/tickets/user/open`, {
method: "GET",
headers: {
Authorization: `Bearer ${token}`,
},
})
.then((res) => res.json())
.then((res) => {
console.log(res);
setTickets(res.tickets);
});
}
Expand All @@ -95,9 +93,9 @@ export default function Home() {

async function datafetch() {
fetchTickets();
getOpenTickets();
getCompletedTickets();
getUnassginedTickets();
// getOpenTickets();
// getCompletedTickets();
// getUnassginedTickets();
await setLoading(false);
}

Expand All @@ -110,7 +108,7 @@ export default function Home() {
<div className="w-full xl:w-[70%] max-w-5xl">
{!loading && (
<>
<div>
{/* <div>
<dl className="grid grid-cols-1 gap-5 sm:grid-cols-3">
{stats.map((item) => (
<Link href={item.href}>
Expand All @@ -128,15 +126,15 @@ export default function Home() {
</Link>
))}
</dl>
</div>
</div> */}

<div className="flex w-full flex-col mt-4 px-1 mb-4">
{tickets !== undefined && tickets.length === 0 ? (
<>
<button
type="button"
className="relative block w-full rounded-lg border-2 border-dashed border-gray-300 p-12 text-center hover:border-gray-400 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2"
onClick={() => router.push("/new")}
onClick={() => router.push("/portal/new")}
>
<svg
className="mx-auto h-12 w-12 text-gray-400 dark:text-white"
Expand Down
Loading

0 comments on commit 32be0de

Please sign in to comment.