Skip to content

Commit

Permalink
client portal
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Nov 25, 2023
1 parent bc3d9ba commit fbfd299
Show file tree
Hide file tree
Showing 8 changed files with 401 additions and 24 deletions.
5 changes: 4 additions & 1 deletion apps/api/src/controllers/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export function ticketRoutes(fastify: FastifyInstance) {
const { name, company, detail, title, priority, email, engineer }: any =
request.body;

console.log(request.body);

const ticket: any = await prisma.ticket.create({
data: {
name,
Expand All @@ -24,7 +26,7 @@ export function ticketRoutes(fastify: FastifyInstance) {
client:
company !== undefined
? {
connect: { id: company.id },
connect: { id: company.id || company },
}
: undefined,
fromImap: false,
Expand Down Expand Up @@ -62,6 +64,7 @@ export function ticketRoutes(fastify: FastifyInstance) {
reply.status(200).send({
message: "Ticket created correctly",
success: true,
id: ticket.id,
});
}
);
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const start = async () => {

client.capture({
event: "server_started",
distinctId: "api_server",
distinctId: "uuid",
});

await client.shutdownAsync();
Expand Down
14 changes: 11 additions & 3 deletions apps/client/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ const queryClient = new QueryClient();
function Auth({ children }: any) {
const { loading, user } = useUser();

const router = useRouter();

React.useEffect(() => {
if (loading) return; // Do nothing while loading
}, [user, loading]);
Expand All @@ -34,9 +36,6 @@ function Auth({ children }: any) {
return children;
}

// Session is being fetched, or no user.
// If no user, useEffect() will redirect.

return (
<div className="flex h-screen justify-center items-center text-green-600">
{/* <ScaleLoader color="green" loading={status} size={100} /> */}
Expand Down Expand Up @@ -148,6 +147,15 @@ function MyApp({ Component, pageProps: { session, ...pageProps } }: any) {
);
}

if (router.pathname.includes("/portal")) {
return (
<>
<Notifications position="top-right" />
<Component {...pageProps} />
</>
);
}

return (
<SessionProvider>
<MantineProvider withNormalizeCSS withGlobalStyles>
Expand Down
12 changes: 11 additions & 1 deletion apps/client/pages/admin/clients/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Link from "next/link";
import { useRouter } from "next/router";
import React from "react";
import { useQuery } from "react-query";
import {
Expand Down Expand Up @@ -207,6 +208,8 @@ export default function Clients() {
fetchAllClients
);

const router = useRouter();

async function deleteClient(id: any) {
await fetch(
`${process.env.NEXT_PUBLIC_API_URL}/api/v1/clients/${id}/delete-client`,
Expand Down Expand Up @@ -247,11 +250,18 @@ export default function Clients() {
<ClientNotesModal notes={row.original.notes} id={row.original.id} /> */}
<button
type="button"
className="rounded bg-white hover:bg-red-100 px-4 py-2 text-sm font-semibold text-red-600 hover:text-white shadow-sm ring-1 ring-inset ring-gray-300"
className="rounded bg-white hover:bg-red-100 px-2.5 py-1.5 text-xs font-semibold text-red-600 hover:text-white shadow-sm ring-1 ring-inset ring-gray-300"
onClick={() => deleteClient(row.original.id)}
>
Delete
</button>
<Link
href={`/portal/${row.original.id}/ticket/new`}
type="button"
className="inline-flex items-center px-2.5 py-1.5 border font-semibold border-gray-300 shadow-sm text-xs rounded text-gray-700 bg-white hover:bg-gray-50 hover:text-gray-900 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500"
>
Portal Url
</Link>
</div>
);
},
Expand Down
1 change: 0 additions & 1 deletion apps/client/pages/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export default function CreateTicket() {

const token = getCookie("session");

const [open, setOpen] = useState(false);
const [name, setName] = useState("");
const [company, setCompany] = useState<any>();
const [engineer, setEngineer] = useState<any>();
Expand Down
Empty file.
Loading

0 comments on commit fbfd299

Please sign in to comment.