()
| 32 | }; |
| 33 | |
| 34 | export const ThreadMaker = () => { |
| 35 | const [url, setUrl] = useState<string>(""); |
| 36 | const [tweetCount, setTweetCount] = useState<number>(6); |
| 37 | |
| 38 | const { |
| 39 | data: twitterThread, |
| 40 | isLoading, |
| 41 | mutateAsync, |
| 42 | } = useMutation(createTwitterThread); |
| 43 | |
| 44 | async function makeThread(event: React.FormEvent) { |
| 45 | event.preventDefault(); |
| 46 | |
| 47 | if (url) { |
| 48 | await mutateAsync({ url, tweetCount }); |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | return ( |
| 53 | <> |
| 54 | <form onSubmit={makeThread}> |
| 55 | <h2>Turn article into Twitter thread</h2> |
| 56 | <Label>Article URL:</Label> |
| 57 | <Input |
| 58 | name="url" |
| 59 | value={url} |
| 60 | onChange={(e) => setUrl(e.currentTarget.value)} |
| 61 | /> |
| 62 | <Label>How many tweets?</Label> |
| 63 | <Input |
| 64 | name="tweetCount" |
| 65 | type="number" |
| 66 | value={tweetCount} |
| 67 | onChange={(e) => |
| 68 | setTweetCount(Number(e.currentTarget.value)) |
| 69 | } |
| 70 | sx={{ width: 60 }} |
| 71 | /> |
| 72 | {isLoading ? ( |
| 73 | <Spinner /> |
| 74 | ) : ( |
| 75 | <Button type="submit">Make Thread</Button> |
| 76 | )} |
| 77 | </form> |
| 78 | |
| 79 | {twitterThread ? <Thread text={twitterThread} /> : null} |
| 80 | </> |
| 81 | ); |
| 82 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected