import { useState } from "react"; import classNames from "classnames"; import { CircleCheck, OctagonX } from "lucide-react"; import { check_user } from "@/app/actions/check_user"; import { on } from "events"; interface Props { value?: string; onChange: (s?: string) => void; } export const Input: React.FC = ({ onChange, value }) => { const [error, setError] = useState(false); const [valid, setValid] = useState(false); const [username, setUsername] = useState(""); const handleCheckUser = async (username: string) => { const user = await check_user(username); if (!user) { setError(true); setValid(false); onChange(undefined); } else { setError(false); setValid(true); onChange(username); } }; return (
https://huggingface.co/
{ onChange(""); setUsername(e.target.value); }} onBlur={(e) => handleCheckUser(e.target.value)} placeholder="enzostvs" className="outline-none bg-transparent border-none w-full text-sm px-3 py-2.5 flex-1" /> {error && } {valid && ( )}
); };