Skip to content

Commit 8b08acc

Browse files
committed
feat: update client
1 parent eaefa54 commit 8b08acc

File tree

3 files changed

+255
-24
lines changed

3 files changed

+255
-24
lines changed

apps/api/src/controllers/ticket.ts

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,8 @@ export function ticketRoutes(fastify: FastifyInstance) {
480480
preHandler: requirePermission(["issue::update"]),
481481
},
482482
async (request: FastifyRequest, reply: FastifyReply) => {
483-
const { id, note, detail, title, priority, status }: any = request.body;
483+
const { id, note, detail, title, priority, status, client }: any =
484+
request.body;
484485

485486
await prisma.ticket.update({
486487
where: { id: id },
@@ -538,6 +539,37 @@ export function ticketRoutes(fastify: FastifyInstance) {
538539
}
539540
);
540541

542+
// Transfer an Issue to another client
543+
fastify.post(
544+
"/api/v1/ticket/transfer/client",
545+
{
546+
preHandler: requirePermission(["issue::transfer"]),
547+
},
548+
async (request: FastifyRequest, reply: FastifyReply) => {
549+
const { client, id }: any = request.body;
550+
551+
if (client) {
552+
await prisma.ticket.update({
553+
where: { id: id },
554+
data: {
555+
clientId: client,
556+
},
557+
});
558+
} else {
559+
await prisma.ticket.update({
560+
where: { id: id },
561+
data: {
562+
clientId: null,
563+
},
564+
});
565+
}
566+
567+
reply.send({
568+
success: true,
569+
});
570+
}
571+
);
572+
541573
// Link a ticket to another ticket
542574

543575
// fastify.post(

apps/client/components/Combo/index.tsx

Lines changed: 129 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1+
import { Coffee, LucideIcon } from "lucide-react";
12
import * as React from "react";
2-
import {
3-
ArrowUpCircle,
4-
CheckCircle2,
5-
Circle,
6-
HelpCircle,
7-
LucideIcon,
8-
SignalLowIcon,
9-
XCircle,
10-
} from "lucide-react";
113

124
import { cn } from "@/shadcn/lib/utils";
135
import { Button } from "@/shadcn/ui/button";
@@ -34,6 +26,7 @@ export function UserCombo({
3426
hideInitial,
3527
showIcon,
3628
disabled,
29+
placeholder,
3730
}) {
3831
const [open, setOpen] = React.useState(false);
3932
const [selectedStatus, setSelectedStatus] = React.useState<any | null>(null);
@@ -83,10 +76,29 @@ export function UserCombo({
8376
</PopoverTrigger>
8477
<PopoverContent className="p-0" side="right" align="start">
8578
<Command>
86-
{/* <CommandInput placeholder="Change status..." /> */}
79+
<CommandInput placeholder={placeholder} />
8780
<CommandList>
8881
<CommandEmpty>No results found.</CommandEmpty>
8982
<CommandGroup>
83+
<CommandItem
84+
className=" hover:cursor-pointer"
85+
value={undefined}
86+
onSelect={() => {
87+
setSelectedStatus(null);
88+
update(null);
89+
setOpen(false);
90+
}}
91+
>
92+
{/* <val.icon
93+
className={cn(
94+
"mr-2 h-4 w-4",
95+
val.value === selectedStatus?.value
96+
? "opacity-100"
97+
: "opacity-40"
98+
)}
99+
/> */}
100+
<span>Unassign</span>
101+
</CommandItem>
90102
{value.map((val) => (
91103
<CommandItem
92104
className=" hover:cursor-pointer"
@@ -99,14 +111,6 @@ export function UserCombo({
99111
setOpen(false);
100112
}}
101113
>
102-
{/* <val.icon
103-
className={cn(
104-
"mr-2 h-4 w-4",
105-
val.value === selectedStatus?.value
106-
? "opacity-100"
107-
: "opacity-40"
108-
)}
109-
/> */}
110114
<span>{val.name}</span>
111115
</CommandItem>
112116
))}
@@ -212,3 +216,110 @@ export function IconCombo({
212216
</div>
213217
);
214218
}
219+
220+
export function ClientCombo({
221+
value,
222+
update,
223+
defaultName,
224+
hideInitial,
225+
showIcon,
226+
disabled,
227+
}) {
228+
const [open, setOpen] = React.useState(false);
229+
const [selectedStatus, setSelectedStatus] = React.useState<any | null>(null);
230+
231+
return (
232+
<div className="flex items-center space-x-4">
233+
<Popover open={open} onOpenChange={setOpen}>
234+
<PopoverTrigger asChild>
235+
<Button
236+
variant="outline"
237+
size="sm"
238+
className="w-[180px] justify-start border-none"
239+
disabled={disabled}
240+
>
241+
{selectedStatus ? (
242+
<div className="flex flex-row space-x-2 w-[120px]">
243+
<div className="flex-shrink-0">
244+
<span className="inline-flex h-6 w-6 pl-2.5 items-center justify-center ">
245+
<span className="text-xs font-medium leading-none text-foreground uppercase ">
246+
<Coffee className="mr-2 h-4 w-4 shrink-0 " />
247+
</span>
248+
</span>
249+
</div>
250+
<span className="mt-[2px]">{defaultName}</span>
251+
</div>
252+
) : defaultName ? (
253+
<>
254+
<div className="flex flex-row items-center space-x-2">
255+
<div className="flex-shrink-0">
256+
<span className="inline-flex h-6 w-6 pl-2.5 items-center justify-center ">
257+
<span className="text-xs font-medium leading-none text-foreground uppercase ">
258+
<Coffee className="mr-2 h-4 w-4 shrink-0 " />
259+
</span>
260+
</span>
261+
</div>
262+
<span>{defaultName}</span>
263+
</div>
264+
</>
265+
) : (
266+
<span>unassigned</span>
267+
)}
268+
</Button>
269+
</PopoverTrigger>
270+
<PopoverContent className="p-0" side="right" align="start">
271+
<Command>
272+
<CommandInput placeholder="Change client..." />
273+
<CommandList>
274+
<CommandEmpty>No results found.</CommandEmpty>
275+
<CommandGroup>
276+
<CommandItem
277+
className=" hover:cursor-pointer"
278+
value={undefined}
279+
onSelect={() => {
280+
setSelectedStatus(null);
281+
update(null);
282+
setOpen(false);
283+
}}
284+
>
285+
{/* <val.icon
286+
className={cn(
287+
"mr-2 h-4 w-4",
288+
val.value === selectedStatus?.value
289+
? "opacity-100"
290+
: "opacity-40"
291+
)}
292+
/> */}
293+
<span>Unassign</span>
294+
</CommandItem>
295+
{value.map((val) => (
296+
<CommandItem
297+
className=" hover:cursor-pointer"
298+
key={val.value}
299+
value={val}
300+
onSelect={(selected) => {
301+
const user = value.find((k) => k.name === selected);
302+
setSelectedStatus(user);
303+
update(user);
304+
setOpen(false);
305+
}}
306+
>
307+
{/* <val.icon
308+
className={cn(
309+
"mr-2 h-4 w-4",
310+
val.value === selectedStatus?.value
311+
? "opacity-100"
312+
: "opacity-40"
313+
)}
314+
/> */}
315+
<span>{val.name}</span>
316+
</CommandItem>
317+
))}
318+
</CommandGroup>
319+
</CommandList>
320+
</Command>
321+
</PopoverContent>
322+
</Popover>
323+
</div>
324+
);
325+
}

0 commit comments

Comments
 (0)