import type { FunctionComponent } from "react"; import { IoSend } from "react-icons/io5"; import { type Message, Direction, MessageStatus } from "@prisma/client"; import useSession from "~/features/core/hooks/use-session"; type Props = { recipient: string; onSend?: () => void; }; const NewMessageArea: FunctionComponent = ({ recipient, onSend }) => { const { currentOrganization, /*hasOngoingSubscription*/ } = useSession(); // const phoneNumber = useCurrentPhoneNumber(); // const sendMessageMutation = useMutation(sendMessage)[0]; const onSubmit = async () => { /*const id = uuidv4(); const message: Message = { id, organizationId: organization!.id, phoneNumberId: phoneNumber!.id, from: phoneNumber!.number, to: recipient, content: hasOngoingSubscription ? content : content + "\n\nSent from Shellphone (https://www.shellphone.app)", direction: Direction.Outbound, status: MessageStatus.Queued, sentAt: new Date(), };*/ /*await setConversationsQueryData( (conversations) => { const nextConversations = { ...conversations }; if (!nextConversations[recipient]) { nextConversations[recipient] = { recipient, formattedPhoneNumber: recipient, messages: [], }; } nextConversations[recipient]!.messages = [...nextConversations[recipient]!.messages, message]; return Object.fromEntries( Object.entries(nextConversations).sort( ([, a], [, b]) => b.messages[b.messages.length - 1]!.sentAt.getTime() - a.messages[a.messages.length - 1]!.sentAt.getTime(), ), ); }, { refetch: false }, );*/ // setValue("content", ""); // onSend?.(); }; return (