feat: update do generate code
This commit is contained in:
parent
3ae5cbfe19
commit
ac47e9d622
@ -96,7 +96,7 @@ function App() {
|
||||
setAppState(AppState.CODE_READY);
|
||||
};
|
||||
|
||||
function doGenerateCode(params: CodeGenerationParams) {
|
||||
function doGenerateCode(params: CodeGenerationParams, setCode: (value: React.SetStateAction<string>) => void = setGeneratedCode) {
|
||||
setExecutionConsole([]);
|
||||
setAppState(AppState.CODING);
|
||||
|
||||
@ -106,8 +106,8 @@ function App() {
|
||||
generateCode(
|
||||
wsRef,
|
||||
updatedParams,
|
||||
(token) => setGeneratedCode((prev) => prev + token),
|
||||
(code) => setGeneratedCode(code),
|
||||
(token) => setCode((prev) => prev + token),
|
||||
(code) => setCode(code),
|
||||
(line) => setExecutionConsole((prev) => [...prev, line]),
|
||||
() => setAppState(AppState.CODE_READY)
|
||||
);
|
||||
|
||||
@ -19,7 +19,7 @@ import { Textarea } from "./ui/textarea";
|
||||
|
||||
|
||||
interface IProps {
|
||||
doGenerateCode: (params: CodeGenerationParams) => void;
|
||||
doGenerateCode: (params: CodeGenerationParams, setCode: (value: React.SetStateAction<string>) => void) => void;
|
||||
referenceImage: string;
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ export const ReactCodeEditor: React.FC<IProps> = ({ doGenerateCode, referenceIma
|
||||
codeType: CodeType.REACT,
|
||||
image: referenceImage,
|
||||
history: updatedHistory,
|
||||
});
|
||||
}, setGeneratedReactCode);
|
||||
|
||||
setReactHistory(updatedHistory);
|
||||
setGeneratedReactCode("");
|
||||
|
||||
@ -8,7 +8,7 @@ const ERROR_MESSAGE =
|
||||
const STOP_MESSAGE = "Code generation stopped";
|
||||
|
||||
export enum CodeType {
|
||||
HTML = "HTML",
|
||||
HTML = "html",
|
||||
REACT = "react",
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user