Skip to content

Commit

Permalink
feat: update client
Browse files Browse the repository at this point in the history
  • Loading branch information
potts99 committed Nov 15, 2024
1 parent eaefa54 commit 8b08acc
Show file tree
Hide file tree
Showing 3 changed files with 255 additions and 24 deletions.
34 changes: 33 additions & 1 deletion apps/api/src/controllers/ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ export function ticketRoutes(fastify: FastifyInstance) {
preHandler: requirePermission(["issue::update"]),
},
async (request: FastifyRequest, reply: FastifyReply) => {
const { id, note, detail, title, priority, status }: any = request.body;
const { id, note, detail, title, priority, status, client }: any =
request.body;

await prisma.ticket.update({
where: { id: id },
Expand Down Expand Up @@ -538,6 +539,37 @@ export function ticketRoutes(fastify: FastifyInstance) {
}
);

// Transfer an Issue to another client
fastify.post(
"/api/v1/ticket/transfer/client",
{
preHandler: requirePermission(["issue::transfer"]),
},
async (request: FastifyRequest, reply: FastifyReply) => {
const { client, id }: any = request.body;

if (client) {
await prisma.ticket.update({
where: { id: id },
data: {
clientId: client,
},
});
} else {
await prisma.ticket.update({
where: { id: id },
data: {
clientId: null,
},
});
}

reply.send({
success: true,
});
}
);

// Link a ticket to another ticket

// fastify.post(
Expand Down
147 changes: 129 additions & 18 deletions apps/client/components/Combo/index.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import { Coffee, LucideIcon } from "lucide-react";
import * as React from "react";
import {
ArrowUpCircle,
CheckCircle2,
Circle,
HelpCircle,
LucideIcon,
SignalLowIcon,
XCircle,
} from "lucide-react";

import { cn } from "@/shadcn/lib/utils";
import { Button } from "@/shadcn/ui/button";
Expand All @@ -34,6 +26,7 @@ export function UserCombo({
hideInitial,
showIcon,
disabled,
placeholder,
}) {
const [open, setOpen] = React.useState(false);
const [selectedStatus, setSelectedStatus] = React.useState<any | null>(null);
Expand Down Expand Up @@ -83,10 +76,29 @@ export function UserCombo({
</PopoverTrigger>
<PopoverContent className="p-0" side="right" align="start">
<Command>
{/* <CommandInput placeholder="Change status..." /> */}
<CommandInput placeholder={placeholder} />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup>
<CommandItem
className=" hover:cursor-pointer"
value={undefined}
onSelect={() => {
setSelectedStatus(null);
update(null);
setOpen(false);
}}
>
{/* <val.icon
className={cn(
"mr-2 h-4 w-4",
val.value === selectedStatus?.value
? "opacity-100"
: "opacity-40"
)}
/> */}
<span>Unassign</span>
</CommandItem>
{value.map((val) => (
<CommandItem
className=" hover:cursor-pointer"
Expand All @@ -99,14 +111,6 @@ export function UserCombo({
setOpen(false);
}}
>
{/* <val.icon
className={cn(
"mr-2 h-4 w-4",
val.value === selectedStatus?.value
? "opacity-100"
: "opacity-40"
)}
/> */}
<span>{val.name}</span>
</CommandItem>
))}
Expand Down Expand Up @@ -212,3 +216,110 @@ export function IconCombo({
</div>
);
}

export function ClientCombo({
value,
update,
defaultName,
hideInitial,
showIcon,
disabled,
}) {
const [open, setOpen] = React.useState(false);
const [selectedStatus, setSelectedStatus] = React.useState<any | null>(null);

return (
<div className="flex items-center space-x-4">
<Popover open={open} onOpenChange={setOpen}>
<PopoverTrigger asChild>
<Button
variant="outline"
size="sm"
className="w-[180px] justify-start border-none"
disabled={disabled}
>
{selectedStatus ? (
<div className="flex flex-row space-x-2 w-[120px]">
<div className="flex-shrink-0">
<span className="inline-flex h-6 w-6 pl-2.5 items-center justify-center ">
<span className="text-xs font-medium leading-none text-foreground uppercase ">
<Coffee className="mr-2 h-4 w-4 shrink-0 " />
</span>
</span>
</div>
<span className="mt-[2px]">{defaultName}</span>
</div>
) : defaultName ? (
<>
<div className="flex flex-row items-center space-x-2">
<div className="flex-shrink-0">
<span className="inline-flex h-6 w-6 pl-2.5 items-center justify-center ">
<span className="text-xs font-medium leading-none text-foreground uppercase ">
<Coffee className="mr-2 h-4 w-4 shrink-0 " />
</span>
</span>
</div>
<span>{defaultName}</span>
</div>
</>
) : (
<span>unassigned</span>
)}
</Button>
</PopoverTrigger>
<PopoverContent className="p-0" side="right" align="start">
<Command>
<CommandInput placeholder="Change client..." />
<CommandList>
<CommandEmpty>No results found.</CommandEmpty>
<CommandGroup>
<CommandItem
className=" hover:cursor-pointer"
value={undefined}
onSelect={() => {
setSelectedStatus(null);
update(null);
setOpen(false);
}}
>
{/* <val.icon
className={cn(
"mr-2 h-4 w-4",
val.value === selectedStatus?.value
? "opacity-100"
: "opacity-40"
)}
/> */}
<span>Unassign</span>
</CommandItem>
{value.map((val) => (
<CommandItem
className=" hover:cursor-pointer"
key={val.value}
value={val}
onSelect={(selected) => {
const user = value.find((k) => k.name === selected);
setSelectedStatus(user);
update(user);
setOpen(false);
}}
>
{/* <val.icon
className={cn(
"mr-2 h-4 w-4",
val.value === selectedStatus?.value
? "opacity-100"
: "opacity-40"
)}
/> */}
<span>{val.name}</span>
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
</div>
);
}
Loading

0 comments on commit 8b08acc

Please sign in to comment.