diff --git a/apps/api/src/controllers/ticket.ts b/apps/api/src/controllers/ticket.ts index 5494d3b57..4cb205f92 100644 --- a/apps/api/src/controllers/ticket.ts +++ b/apps/api/src/controllers/ticket.ts @@ -11,8 +11,16 @@ export function ticketRoutes(fastify: FastifyInstance) { "/api/v1/ticket/create", async (request: FastifyRequest, reply: FastifyReply) => { - const { name, company, detail, title, priority, email, engineer }: any = - request.body; + const { + name, + company, + detail, + title, + priority, + email, + engineer, + type, + }: any = request.body; console.log(request.body); @@ -23,6 +31,7 @@ export function ticketRoutes(fastify: FastifyInstance) { detail, priority: priority ? priority : "low", email, + type: type ? type.toLowerCase() : "support", client: company !== undefined ? { diff --git a/apps/api/src/prisma/migrations/20231125042344_/migration.sql b/apps/api/src/prisma/migrations/20231125042344_/migration.sql new file mode 100644 index 000000000..3ef65483a --- /dev/null +++ b/apps/api/src/prisma/migrations/20231125042344_/migration.sql @@ -0,0 +1,5 @@ +-- CreateEnum +CREATE TYPE "TicketType" AS ENUM ('bug', 'feature', 'support', 'incident', 'service', 'maintenance', 'access', 'feedback'); + +-- AlterTable +ALTER TABLE "Ticket" ADD COLUMN "type" "TicketType" NOT NULL DEFAULT 'support'; diff --git a/apps/api/src/prisma/schema.prisma b/apps/api/src/prisma/schema.prisma index 01775cc14..dfbd68da1 100644 --- a/apps/api/src/prisma/schema.prisma +++ b/apps/api/src/prisma/schema.prisma @@ -105,6 +105,7 @@ model Ticket { fromImap Boolean Number Int @default(autoincrement()) status TicketStatus @default(needs_support) + type TicketType @default(support) TicketFile TicketFile[] Comment Comment[] @@ -298,3 +299,14 @@ enum TicketStatus { in_review done } + +enum TicketType { + bug + feature + support + incident + service + maintenance + access + feedback +} diff --git a/apps/client/components/TicketViews/assigned.tsx b/apps/client/components/TicketViews/assigned.tsx index f67d023dd..6563bac6c 100644 --- a/apps/client/components/TicketViews/assigned.tsx +++ b/apps/client/components/TicketViews/assigned.tsx @@ -253,6 +253,18 @@ export default function AssignedTickets() { ); }, }, + { + Header: "Client", + accessor: "client.name", + id: "client", + Cell: ({ row, value }: any) => { + return ( + <> + {value ? value : "n/a"} + + ); + }, + }, { Header: "Priority", accessor: "priority", diff --git a/apps/client/components/TicketViews/closed.tsx b/apps/client/components/TicketViews/closed.tsx index 94aeece99..58ba34790 100644 --- a/apps/client/components/TicketViews/closed.tsx +++ b/apps/client/components/TicketViews/closed.tsx @@ -247,6 +247,18 @@ export default function ClosedTickets() { ); }, }, + { + Header: "Client", + accessor: "client.name", + id: "client", + Cell: ({ row, value }: any) => { + return ( + <> + {value ? value : "n/a"} + + ); + }, + }, { Header: "Priority", accessor: "priority", diff --git a/apps/client/components/TicketViews/open.tsx b/apps/client/components/TicketViews/open.tsx index d52175d24..71b09cb7e 100644 --- a/apps/client/components/TicketViews/open.tsx +++ b/apps/client/components/TicketViews/open.tsx @@ -247,6 +247,18 @@ export default function OpenTickets() { ); }, }, + { + Header: "Client", + accessor: "client.name", + id: "client", + Cell: ({ row, value }: any) => { + return ( + <> + {value ? value : "n/a"} + + ); + }, + }, { Header: "Priority", accessor: "priority", diff --git a/apps/client/components/TicketViews/unassiged.tsx b/apps/client/components/TicketViews/unassiged.tsx index 076160c1c..77a41437a 100644 --- a/apps/client/components/TicketViews/unassiged.tsx +++ b/apps/client/components/TicketViews/unassiged.tsx @@ -250,6 +250,18 @@ export default function UnassignedTickets() { ); }, }, + { + Header: "Client", + accessor: "client.name", + id: "client", + Cell: ({ row, value }: any) => { + return ( + <> + {value ? value : "n/a"} + + ); + }, + }, { Header: "Priority", accessor: "priority", diff --git a/apps/client/pages/new.tsx b/apps/client/pages/new.tsx index 54c3244ed..f6e5623c1 100644 --- a/apps/client/pages/new.tsx +++ b/apps/client/pages/new.tsx @@ -18,6 +18,16 @@ function classNames(...classes: any) { return classes.filter(Boolean).join(" "); } +const type = [ + { id: 5, name: "Incident" }, + { id: 1, name: "Service" }, + { id: 2, name: "Feature" }, + { id: 3, name: "Bug" }, + { id: 4, name: "Maintenance" }, + { id: 6, name: "Access" }, + { id: 8, name: "Feedback" }, +]; + export default function CreateTicket() { const { t, lang } = useTranslation("peppermint"); @@ -34,6 +44,7 @@ export default function CreateTicket() { const [priority, setPriority] = useState("Normal"); const [options, setOptions] = useState(); const [users, setUsers] = useState(); + const [selected, setSelected] = useState(type[2]); const editor = useEditor({ extensions: [ @@ -102,6 +113,7 @@ export default function CreateTicket() { detail: issue, priority, engineer, + type: selected.name, }), }) .then((res) => res.json()) @@ -314,6 +326,75 @@ export default function CreateTicket() { )} + + {({ open }) => ( + <> +
+ + {selected.name} + + + + + + + {type.map((person) => ( + + classNames( + active + ? "bg-gray-400 text-white" + : "text-gray-900", + "relative cursor-default select-none py-2 pl-3 pr-9" + ) + } + value={person} + > + {({ selected, active }) => ( + <> + + {person.name} + + + {selected ? ( + + + ) : null} + + )} + + ))} + + +
+ + )} +
diff --git a/apps/client/pages/portal/[id]/ticket/new.tsx b/apps/client/pages/portal/[id]/ticket/new.tsx index 5bbe6033d..dc6759f91 100644 --- a/apps/client/pages/portal/[id]/ticket/new.tsx +++ b/apps/client/pages/portal/[id]/ticket/new.tsx @@ -16,12 +16,13 @@ import { useRouter } from "next/router"; import { Fragment, useState } from "react"; const type = [ - { id: 1, name: "Bug" }, - { id: 2, name: "Feature Request" }, - { id: 3, name: "Support" }, - { id: 4, name: "Billing" }, - { id: 5, name: "Hardware" }, - { id: 6, name: "Software" }, + { id: 5, name: "Incident" }, + { id: 1, name: "Service" }, + { id: 2, name: "Feature" }, + { id: 3, name: "Bug" }, + { id: 4, name: "Maintenance" }, + { id: 6, name: "Access" }, + { id: 8, name: "Feedback" }, ]; const pri = [ @@ -37,7 +38,7 @@ export default function ClientTicketNew() { const router = useRouter(); const [isLoading, setIsLoading] = useState(false); - const [view, setView] = useState("success"); + const [view, setView] = useState("new"); const [ticketID, setTicketID] = useState(""); const [selected, setSelected] = useState(type[2]); @@ -61,6 +62,7 @@ export default function ClientTicketNew() { email, detail: description, priority: priority.name, + type: selected.name, }), }) .then((res) => res.json())