Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeparticle committed May 31, 2024
1 parent 74994d8 commit b6b5b8d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions ui/src/pages/Generator/CSharpBuilder/CSharpBuilder.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, useState } from "react";
import { FC, useEffect, useState } from "react";
import { Card, Form } from "antd";
import { Clipboard } from "components/ComponentInjector";
import { CodeEditor } from "components/General";
Expand All @@ -9,14 +9,20 @@ import { generateBuilderMethods } from "./helper";
const CSharpBuilde: FC = () => {
const [input, setInput] = useState("");
const [result, setResult] = useState("");
const [imports, setImports] = useState("using Bogus;\n\n");
const [imports, setImports] = useState("using Bogus;");
const [useImports, setUseImports] = useState(
"\tprivate static Faker faker = new();\n\n"
"private static Faker faker = new();"
);

const onClick = (value: string) => {
setResult(generateBuilderMethods(value, imports, useImports));
};
useEffect(() => {
setResult(
generateBuilderMethods(
input,
`${imports}\n\n`,
`\t${useImports}\n\n`
)
);
}, [imports, useImports, input]);

return (
<PageGrid>
Expand All @@ -30,7 +36,6 @@ const CSharpBuilde: FC = () => {
height="17dvh"
handleCode={(value) => {
setImports(value ?? "");
onClick(input ?? "");
}}
/>
<CodeEditor
Expand All @@ -40,7 +45,6 @@ const CSharpBuilde: FC = () => {
height="17dvh"
handleCode={(value) => {
setUseImports(value ?? "");
onClick(input ?? "");
}}
/>
</PageGrid>
Expand All @@ -51,7 +55,6 @@ const CSharpBuilde: FC = () => {
language="csharp"
handleCode={(value) => {
setInput(value ?? "");
onClick(value ?? "");
}}
/>
<Clipboard
Expand Down
2 changes: 1 addition & 1 deletion ui/src/pages/Generator/CSharpBuilder/helper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ export function generateBuilderMethods(
})
.join("\n");

return `${imports}public class ${className}Builder : ${className} \n{\n${useImports}${builderProperties}\n\n${buildMethod}\n}`;
return `${imports}public class ${className}Builder : ${className} \n{\n${useImports}${builderProperties}\n\n${buildMethod}\n}`.trim();
}

0 comments on commit b6b5b8d

Please sign in to comment.