"use client"; import { FC, useState } from "react"; import { Grid, Button, Dialog, DialogActions, DialogContent, TextField, Autocomplete, } from "@mui/material"; import useSWR, { useSWRConfig } from "swr"; import { createTicketMutation } from "app/_graphql/createTicketMutation"; interface TicketCreateDialogProps { open: boolean; closeDialog: () => void; } export const TicketCreateDialog: FC = ({ open, closeDialog, }) => { const [kind, setKind] = useState("note"); const [customerID, setCustomerID] = useState(""); const [groupID, setGroupID] = useState(""); const [ownerID, setOwnerID] = useState(""); const [priorityID, setPriorityID] = useState(""); const [stateID, setStateID] = useState(""); const [tags, setTags] = useState([]); const [title, setTitle] = useState(""); const [body, setBody] = useState(""); const backgroundColor = "#1982FC"; const color = "white"; const { fetcher } = useSWRConfig(); const ticket = { customerId: customerID, groupId: groupID, ownerId: ownerID, priorityId: priorityID, stateId: stateID, tags, title, article: { body, type: kind, internal: kind === "note", }, }; const { data: users, error: usersError }: any = useSWR({ url: "/api/v1/users", method: "GET", }); console.log({ users, usersError }); const customers = users?.filter((user: any) => user.role_ids.includes(3)) ?? []; const formattedCustomers = customers.map((customer: any) => ({ label: customer.login, id: `${customer.id}`, })); const createTicket = async () => { await fetcher({ document: createTicketMutation, variables: { input: { ticket, }, }, }); closeDialog(); setBody(""); }; return ( setTitle(e.target.value)} /> setCustomerID(e.target.value.id)} renderInput={(params) => ( )} /> setBody(e.target.value)} /> ); };