export default function FreeChatContext() {
const [currentMessage, setCurrentMessage] = useState("");
const [errorMessage, setErrorMessage] = useState("");
const [isTyping, setIsTyping] = useState(false);
// get free user account from cookies or create new
const cookieStore = useCookies();
const userUUID: string =
cookieStore.get("user_uuid") ??
api.account.generateUniqueUser.useQuery().data?.sessionToken ??
"";
useEffect(() => {
if (userUUID) cookieStore.set("user_uuid", userUUID);
}, [userUUID]);
// Load messages
const chatMessageData = api.getChats.getChatUnauth.useQuery({
uuid: userUUID,
});
const utils = api.useUtils();
const { mutate, error } = api.getChats.getFreeChatMessage.useMutation({
...
export default function FreeChatContext() {
const [currentMessage, setCurrentMessage] = useState("");
const [errorMessage, setErrorMessage] = useState("");
const [isTyping, setIsTyping] = useState(false);
// get free user account from cookies or create new
const cookieStore = useCookies();
const userUUID: string =
cookieStore.get("user_uuid") ??
api.account.generateUniqueUser.useQuery().data?.sessionToken ??
"";
useEffect(() => {
if (userUUID) cookieStore.set("user_uuid", userUUID);
}, [userUUID]);
// Load messages
const chatMessageData = api.getChats.getChatUnauth.useQuery({
uuid: userUUID,
});
const utils = api.useUtils();
const { mutate, error } = api.getChats.getFreeChatMessage.useMutation({
...