Skip to content

Commit

Permalink
ticket types
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Nov 25, 2023
1 parent 2f16d76 commit 56be07f
Show file tree
Hide file tree
Showing 9 changed files with 166 additions and 9 deletions.
13 changes: 11 additions & 2 deletions apps/api/src/controllers/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -23,6 +31,7 @@ export function ticketRoutes(fastify: FastifyInstance) {
detail,
priority: priority ? priority : "low",
email,
type: type ? type.toLowerCase() : "support",
client:
company !== undefined
? {
Expand Down
5 changes: 5 additions & 0 deletions apps/api/src/prisma/migrations/20231125042344_/migration.sql
Original file line number Diff line number Diff line change
@@ -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';
12 changes: 12 additions & 0 deletions apps/api/src/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down Expand Up @@ -298,3 +299,14 @@ enum TicketStatus {
in_review
done
}

enum TicketType {
bug
feature
support
incident
service
maintenance
access
feedback
}
12 changes: 12 additions & 0 deletions apps/client/components/TicketViews/assigned.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,18 @@ export default function AssignedTickets() {
);
},
},
{
Header: "Client",
accessor: "client.name",
id: "client",
Cell: ({ row, value }: any) => {
return (
<>
<span className="w-[80px] truncate">{value ? value : "n/a"}</span>
</>
);
},
},
{
Header: "Priority",
accessor: "priority",
Expand Down
12 changes: 12 additions & 0 deletions apps/client/components/TicketViews/closed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,18 @@ export default function ClosedTickets() {
);
},
},
{
Header: "Client",
accessor: "client.name",
id: "client",
Cell: ({ row, value }: any) => {
return (
<>
<span className="w-[80px] truncate">{value ? value : "n/a"}</span>
</>
);
},
},
{
Header: "Priority",
accessor: "priority",
Expand Down
12 changes: 12 additions & 0 deletions apps/client/components/TicketViews/open.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,18 @@ export default function OpenTickets() {
);
},
},
{
Header: "Client",
accessor: "client.name",
id: "client",
Cell: ({ row, value }: any) => {
return (
<>
<span className="w-[80px] truncate">{value ? value : "n/a"}</span>
</>
);
},
},
{
Header: "Priority",
accessor: "priority",
Expand Down
12 changes: 12 additions & 0 deletions apps/client/components/TicketViews/unassiged.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,18 @@ export default function UnassignedTickets() {
);
},
},
{
Header: "Client",
accessor: "client.name",
id: "client",
Cell: ({ row, value }: any) => {
return (
<>
<span className="w-[80px] truncate">{value ? value : "n/a"}</span>
</>
);
},
},
{
Header: "Priority",
accessor: "priority",
Expand Down
81 changes: 81 additions & 0 deletions apps/client/pages/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -34,6 +44,7 @@ export default function CreateTicket() {
const [priority, setPriority] = useState("Normal");
const [options, setOptions] = useState<any>();
const [users, setUsers] = useState<any>();
const [selected, setSelected] = useState<any>(type[2]);

const editor = useEditor({
extensions: [
Expand Down Expand Up @@ -102,6 +113,7 @@ export default function CreateTicket() {
detail: issue,
priority,
engineer,
type: selected.name,
}),
})
.then((res) => res.json())
Expand Down Expand Up @@ -314,6 +326,75 @@ export default function CreateTicket() {
</>
)}
</Listbox>
<Listbox value={selected} onChange={setSelected}>
{({ open }) => (
<>
<div className="relative mt-2">
<Listbox.Button className="relative w-full min-w-[172px] cursor-default rounded-md bg-white py-1.5 pl-3 pr-10 text-left text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 focus:outline-none sm:text-sm sm:leading-6">
<span className="block truncate">{selected.name}</span>
<span className="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
<ChevronUpDownIcon
className="h-5 w-5 text-gray-400"
aria-hidden="true"
/>
</span>
</Listbox.Button>

<Transition
show={open}
as={Fragment}
leave="transition ease-in duration-100"
leaveFrom="opacity-100"
leaveTo="opacity-0"
>
<Listbox.Options className="absolute z-10 mt-1 max-h-60 w-full overflow-auto rounded-md bg-white py-1 text-base shadow-lg ring-1 ring-black ring-opacity-5 focus:outline-none sm:text-sm">
{type.map((person) => (
<Listbox.Option
key={person.id}
className={({ active }) =>
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 }) => (
<>
<span
className={classNames(
selected ? "font-semibold" : "font-normal",
"block truncate"
)}
>
{person.name}
</span>

{selected ? (
<span
className={classNames(
active ? "text-white" : "text-indigo-600",
"absolute inset-y-0 right-0 flex items-center pr-4"
)}
>
<CheckIcon
className="h-5 w-5"
aria-hidden="true"
/>
</span>
) : null}
</>
)}
</Listbox.Option>
))}
</Listbox.Options>
</Transition>
</div>
</>
)}
</Listbox>
</div>

<RichTextEditor editor={editor}>
Expand Down
16 changes: 9 additions & 7 deletions apps/client/pages/portal/[id]/ticket/new.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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]);
Expand All @@ -61,6 +62,7 @@ export default function ClientTicketNew() {
email,
detail: description,
priority: priority.name,
type: selected.name,
}),
})
.then((res) => res.json())
Expand Down

0 comments on commit 56be07f

Please sign in to comment.