import { Suspense, useRef, useState } from "react"; import { BottomSheet } from "react-spring-bottom-sheet"; import { useAtom } from "jotai"; import { useRouter, Routes } from "blitz"; import "react-spring-bottom-sheet/dist/style.css"; import NewMessageArea from "./new-message-area"; import { bottomSheetOpenAtom } from "../pages/messages"; export default function NewMessageBottomSheet() { const router = useRouter(); const [isOpen, setIsOpen] = useAtom(bottomSheetOpenAtom); const [recipient, setRecipient] = useState(""); const recipientRef = useRef(null); return ( { if (event.type === "OPEN") { // doesn't work with iOS safari *sigh* recipientRef.current?.focus(); } }} onDismiss={() => setIsOpen(false)} snapPoints={({ maxHeight }) => maxHeight / 2} header={
New Message
} >
To: setRecipient(event.target.value)} className="bg-none border-none outline-none flex-1 text-black" type="tel" />
{ router.push(Routes.ConversationPage({ recipient })).then(() => setIsOpen(false)); }} />
); }