Public
Back
Version 78
7/28/2024
/** @jsxImportSource https://esm.sh/react */
import copy from "https://esm.sh/copy-text-to-clipboard";
import { useEffect, useState } from "https://esm.sh/react";
import { render } from "https://esm.town/v/jxnblk/ReactStream";
import { useStreamingAPI } from "https://esm.town/v/jxnblk/useStreamingAPI";
// chat and encode/decode
import api, { decode } from "https://esm.town/v/jxnblk/IndirectionAPI";
import { GoogleFonts } from "https://esm.town/v/jxnblk/reactGoogleFonts";
function App(props) {
console.log(props);
const [history, setHistory] = useState<Turn[]>(props.data.history || []);
const [word, setWord] = useState<string>("");
const [turn, setTurn] = useState(props.data.turn || emptyTurn);
const [ui, setUI] = useState<UIState>(props.data?.turn?.clue ? UIState.Guessing : UIState.Start);
const { message, submit, loading, error } = useStreamingAPI<APIRequestBody>();
const addHistoryGuess = (guess: string) => {
setHistory([
...history,
{
word: turn.word,
clue: turn.clue,
guess: guess,
},
]);
}
const handleSubmit = e => {
e.preventDefault();
let correct = null;
if (ui === UIState.Guessing) {
// is a guess play
addHistoryGuess(word);
jxnblk-indirection.web.val.run
Updated: August 13, 2024