Back
Version 2
11/18/2024
/** @jsxImportSource https://esm.sh/react */
import React, { useState } from "https://esm.sh/react";
import { createRoot } from "https://esm.sh/react-dom/client";
import { nanoid } from "https://esm.sh/nanoid";
function App() {
const [specId, setSpecId] = useState("");
const [implementationResult, setImplementationResult] = useState(null);
const [error, setError] = useState(null);
const [isLoading, setIsLoading] = useState(false);
const handleSubmit = async (e) => {
e.preventDefault();
setIsLoading(true);
setError(null);
try {
const response = await fetch(window.location.href, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
},
body: JSON.stringify({ specId })
});
if (!response.ok) {
const errorText = await response.text();
throw new Error(`HTTP error! status: ${response.status}, message: ${errorText}`);
}
const result = await response.json();
setImplementationResult(result);
setError(null);
} catch (error) {
console.error("TDD Generation failed:", error);
Updated: November 18, 2024