"use client"; import { FC } from "react"; import { useFormState } from "react-dom"; import { Grid } from "@mui/material"; import { Dialog, Button, TextField, Autocomplete } from "@link-stack/ui"; import { createTicketAction } from "app/_actions/tickets"; import useSWR from "swr"; interface TicketCreateDialogProps { open: boolean; closeDialog: () => void; } export const TicketCreateDialog: FC = ({ open, closeDialog, }) => { const initialState = { messages: [], errors: [], values: { customerId: "", groupId: "", ownerId: "", priorityId: "", stateId: "", tags: [], title: "", article: { body: "", type: "note", internal: true, }, }, }; const [formState, formAction] = useFormState( createTicketAction, initialState, ); const { data: users, error: usersError }: any = useSWR({ url: "/api/v1/users", method: "GET", }); const customers = users?.filter((user: any) => user.role_ids.includes(3)) ?? []; const formattedCustomers = customers.map((customer: any) => ({ label: customer.login, id: `${customer.id}`, })); return ( ); };