diff --git a/apps/api/src/controllers/ticket.ts b/apps/api/src/controllers/ticket.ts
index 4cb205f92..f1aeff869 100644
--- a/apps/api/src/controllers/ticket.ts
+++ b/apps/api/src/controllers/ticket.ts
@@ -153,7 +153,7 @@ export function ticketRoutes(fastify: FastifyInstance) {
if (token) {
const tickets = await prisma.ticket.findMany({
- where: { isComplete: false },
+ where: { isComplete: false, hidden: false },
include: {
client: {
select: { id: true, name: true, number: true },
@@ -187,7 +187,7 @@ export function ticketRoutes(fastify: FastifyInstance) {
const user = await checkSession(bearer);
const tickets = await prisma.ticket.findMany({
- where: { isComplete: false, userId: user!.id },
+ where: { isComplete: false, userId: user!.id, hidden: false },
include: {
client: {
select: { id: true, name: true, number: true },
@@ -219,7 +219,7 @@ export function ticketRoutes(fastify: FastifyInstance) {
if (token) {
const tickets = await prisma.ticket.findMany({
- where: { isComplete: true },
+ where: { isComplete: true, hidden: false },
include: {
client: {
select: { id: true, name: true, number: true },
@@ -254,6 +254,7 @@ export function ticketRoutes(fastify: FastifyInstance) {
where: {
isComplete: false,
assignedTo: null,
+ hidden: false,
},
});
@@ -430,6 +431,34 @@ export function ticketRoutes(fastify: FastifyInstance) {
});
}
}
+
+ reply.send({
+ success: true,
+ });
+ }
+ );
+
+ // Hide a ticket
+ fastify.put(
+ "/api/v1/ticket/status/hide",
+
+ async (request: FastifyRequest, reply: FastifyReply) => {
+ const { hidden, id }: any = request.body;
+
+ await prisma.ticket
+ .update({
+ where: { id: id },
+ data: {
+ hidden: hidden,
+ },
+ })
+ .then(async (ticket) => {
+ // await sendTicketStatus(ticket);
+ });
+
+ reply.send({
+ success: true,
+ });
}
);
diff --git a/apps/api/src/main.ts b/apps/api/src/main.ts
index 0f22f38c1..bc4861bc9 100644
--- a/apps/api/src/main.ts
+++ b/apps/api/src/main.ts
@@ -29,6 +29,7 @@ server.register(require("@fastify/swagger"), {
url: "https://swagger.io",
description: "Find more info here",
},
+ mode: "static",
host: "localhost",
schemes: ["http"],
consumes: ["application/json"],
@@ -37,6 +38,7 @@ server.register(require("@fastify/swagger"), {
{ name: "user", description: "User related end-points" },
{ name: "code", description: "Code related end-points" },
],
+ exposeRoute: true,
definitions: {
User: {
type: "object",
diff --git a/apps/api/src/prisma/migrations/20231125221631_hidden/migration.sql b/apps/api/src/prisma/migrations/20231125221631_hidden/migration.sql
new file mode 100644
index 000000000..e55b74cb5
--- /dev/null
+++ b/apps/api/src/prisma/migrations/20231125221631_hidden/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "Ticket" ADD COLUMN "hidden" BOOLEAN NOT NULL DEFAULT false;
diff --git a/apps/api/src/prisma/schema.prisma b/apps/api/src/prisma/schema.prisma
index dfbd68da1..fa54db79e 100644
--- a/apps/api/src/prisma/schema.prisma
+++ b/apps/api/src/prisma/schema.prisma
@@ -106,6 +106,7 @@ model Ticket {
Number Int @default(autoincrement())
status TicketStatus @default(needs_support)
type TicketType @default(support)
+ hidden Boolean @default(false)
TicketFile TicketFile[]
Comment Comment[]
diff --git a/apps/client/package.json b/apps/client/package.json
index 4babf918f..8a6fcddc0 100644
--- a/apps/client/package.json
+++ b/apps/client/package.json
@@ -5,9 +5,7 @@
"scripts": {
"dev": "next dev",
"build": "next build",
- "start": "next start",
- "docker": "yarn run migrate && yarn run generate && yarn run seed && yarn start",
- "pm2-prod": "yarn run migrate && yarn run generate && yarn run seed && yarn run build && pm2 start npm --name \"next\" -- start"
+ "start": "next start"
},
"dependencies": {
"@headlessui/react": "^1.4.2",
@@ -47,6 +45,7 @@
"next-themes": "^0.0.15",
"next-translate": "^1.3.4",
"nodemailer": "^6.7.2",
+ "posthog-js": "^1.93.2",
"prosemirror-model": "^1.18.1",
"pug": "^3.0.2",
"react": "18.2.0",
diff --git a/apps/client/pages/auth/login.tsx b/apps/client/pages/auth/login.tsx
index 2fd297986..623581a91 100644
--- a/apps/client/pages/auth/login.tsx
+++ b/apps/client/pages/auth/login.tsx
@@ -14,7 +14,7 @@ export default function Login({}) {
const { setUser } = useUser();
async function postData() {
- await fetch("http://localhost:5003/api/v1/auth/login", {
+ await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/auth/login`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ email, password }),
diff --git a/apps/client/pages/tickets/[id].tsx b/apps/client/pages/tickets/[id].tsx
index f8f30159f..51fc33ab7 100644
--- a/apps/client/pages/tickets/[id].tsx
+++ b/apps/client/pages/tickets/[id].tsx
@@ -7,7 +7,6 @@ import {
ChevronUpDownIcon,
LockClosedIcon,
LockOpenIcon,
- PencilIcon,
} from "@heroicons/react/20/solid";
import { Link, RichTextEditor } from "@mantine/tiptap";
import Highlight from "@tiptap/extension-highlight";
@@ -23,6 +22,7 @@ import renderHTML from "react-render-html";
import SubScript from "@tiptap/extension-subscript";
import Superscript from "@tiptap/extension-superscript";
import { getCookie } from "cookies-next";
+import { useUser } from "../../store/session";
function classNames(...classes: any) {
return classes.filter(Boolean).join(" ");
@@ -33,6 +33,10 @@ export default function Ticket() {
const token = getCookie("session");
+ const { user } = useUser();
+
+ console.log(user);
+
const fetchTicketById = async () => {
const id = router.query.id;
const res = await fetch(
@@ -113,9 +117,9 @@ export default function Ticket() {
async function updateStatus() {
await fetch(
- `${process.env.NEXT_PUBLIC_API_URL}/api/v1/ticket/update-status`,
+ `${process.env.NEXT_PUBLIC_API_URL}/api/v1/ticket/status/update`,
{
- method: "POST",
+ method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
@@ -129,6 +133,26 @@ export default function Ticket() {
.then((res) => res.json())
.then(() => refetch());
}
+
+ async function hide(hidden) {
+ await fetch(
+ `${process.env.NEXT_PUBLIC_API_URL}/api/v1/ticket/status/hide`,
+ {
+ method: "PUT",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${token}`,
+ },
+ body: JSON.stringify({
+ hidden,
+ id,
+ }),
+ }
+ )
+ .then((res) => res.json())
+ .then(() => refetch());
+ }
+
async function addComment() {
await fetch(`${process.env.NEXT_PUBLIC_API_URL}/api/v1/ticket/comment`, {
method: "POST",
@@ -303,16 +327,23 @@ export default function Ticket() {
+ {user.isAdmin && (
+
+ )}
{!edit ? (
) : (
@@ -322,12 +353,8 @@ export default function Ticket() {
update();
setEdit(false);
}}
- className="inline-flex justify-center gap-x-1.5 rounded-md bg-white px-3 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
+ className="inline-flex justify-center gap-x-1.5 rounded-md bg-white px-5 py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50"
>
-
Save
)}
@@ -766,9 +793,7 @@ export default function Ticket() {
className="-ml-0.5 h-5 w-5 text-red-500"
aria-hidden="true"
/>
-
- Re-Open issue
-
+
Re-Open issue
) : (