fix(priority/delete): pass actorId from useAuth to Convex mutations
This commit is contained in:
parent
97ca2b3b54
commit
65ccb98741
3 changed files with 14 additions and 6 deletions
|
|
@ -5,7 +5,7 @@ import { useMutation } from "convex/react"
|
|||
// @ts-ignore
|
||||
import { api } from "@/convex/_generated/api"
|
||||
import type { Id } from "@/convex/_generated/dataModel"
|
||||
import type { TicketStatus } from "@/lib/schemas/ticket"
|
||||
import { useAuth } from "@/lib/auth-client"
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import { toast } from "sonner"
|
||||
|
|
@ -33,6 +33,7 @@ function badgeClass(p: string) {
|
|||
export function PrioritySelect({ ticketId, value }: { ticketId: Id<"tickets">; value: "LOW" | "MEDIUM" | "HIGH" | "URGENT" }) {
|
||||
const updatePriority = useMutation(api.tickets.updatePriority)
|
||||
const [priority, setPriority] = useState(value)
|
||||
const { userId } = useAuth()
|
||||
return (
|
||||
<Select
|
||||
value={priority}
|
||||
|
|
@ -41,7 +42,8 @@ export function PrioritySelect({ ticketId, value }: { ticketId: Id<"tickets">; v
|
|||
setPriority(val as typeof priority)
|
||||
toast.loading("Atualizando prioridade...", { id: "prio" })
|
||||
try {
|
||||
await updatePriority({ ticketId, priority: val as any, actorId: undefined as unknown as Id<"users"> })
|
||||
if (!userId) throw new Error("No user")
|
||||
await updatePriority({ ticketId, priority: val as any, actorId: userId as Id<"users"> })
|
||||
toast.success("Prioridade atualizada!", { id: "prio" })
|
||||
} catch {
|
||||
setPriority(prev)
|
||||
|
|
@ -64,4 +66,3 @@ export function PrioritySelect({ ticketId, value }: { ticketId: Id<"tickets">; v
|
|||
</Select>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue