repositories
loading repo index
repositories
loading repo index
repository
loading code, commits, and activity
public Clawd ADK gateway launch mirror
stars
latest
clone command
git clone gitlawb://did:key:z6Mkq5mY...iFZ5/my-project-publ...git clone gitlawb://did:key:z6Mkq5mY.../my-project-publ...2fa351d6docs: add automaton and perps launch sources16d ago| #6 | const [status, setStatus] = useState(""); |
| #7 | const router = useRouter(); |
| #8 |
| #9 | const handleCreateBot = async (e) => { |
| #10 | e.preventDefault(); |
| #11 | const data = { |
| #12 | name: botName, |
| #13 | }; |
| #14 |
| #15 | const response = await fetch("/api/create_bot", { |
| #16 | method: "POST", |
| #17 | headers: { |
| #18 | "Content-Type": "application/json", |
| #19 | }, |
| #20 | body: JSON.stringify(data), |
| #21 | }); |
| #22 |
| #23 | if (response.ok) { |
| #24 | const botSlug = botName.toLowerCase().replace(/\s+/g, "_"); |
| #25 | router.push(`/${botSlug}/app`); |
| #26 | } else { |
| #27 | setBotName(""); |
| #28 | setStatus("fail"); |
| #29 | setTimeout(() => { |
| #30 | setStatus(""); |
| #31 | }, 3000); |
| #32 | } |
| #33 | }; |
| #34 |
| #35 | return ( |
| #36 | <> |
| #37 | <div className="w-full"> |
| #38 | {/* Create Bot */} |
| #39 | <h2 className="text-xl font-bold text-gray-800">CREATE BOT</h2> |
| #40 | <form className="py-2" onSubmit={handleCreateBot}> |
| #41 | <label |
| #42 | htmlFor="bot_name" |
| #43 | className="block mb-2 text-sm font-medium text-gray-900" |
| #44 | > |
| #45 | Name of Bot |
| #46 | </label> |
| #47 | <div className="flex flex-col sm:flex-row gap-x-4 gap-y-4"> |
| #48 | <input |
| #49 | type="text" |
| #50 | id="bot_name" |
| #51 | className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5" |
| #52 | placeholder="Eg. Naval Ravikant" |
| #53 | required |
| #54 | value={botName} |
| #55 | onChange={(e) => setBotName(e.target.value)} |
| #56 | /> |
| #57 | <button |
| #58 | type="submit" |
| #59 | className="h-fit text-white bg-black hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm w-full sm:w-auto px-5 py-2.5 text-center" |
| #60 | > |
| #61 | Submit |
| #62 | </button> |
| #63 | </div> |
| #64 | {status === "fail" && ( |
| #65 | <div className="text-red-600 text-sm font-bold py-1"> |
| #66 | An error occurred while creating your bot! |
| #67 | </div> |
| #68 | )} |
| #69 | </form> |
| #70 | </div> |
| #71 | </> |
| #72 | ); |
| #73 | } |
| #74 |