From cfb37cecd2b9489183bc104b35a816f4049449cb Mon Sep 17 00:00:00 2001 From: "Ziyuan (Jerry) Zhang" Date: Tue, 2 Apr 2024 11:23:27 -0400 Subject: [PATCH] add config, formatting --- demo/src/MemoryModelsSample.tsx | 45 +++++++++++-------- .../automation}/automation.json | 0 demo/src/sample/automation/config.json | 1 + .../blankspace}/blankspace.json | 13 +----- demo/src/sample/blankspace/config.json | 1 + demo/src/sample/manual/config.json | 3 ++ .../manual}/manual.json | 0 demo/src/sample/simple/config.json | 1 + .../simple}/simple.json | 8 +--- 9 files changed, 36 insertions(+), 36 deletions(-) rename demo/src/{sample_json => sample/automation}/automation.json (100%) create mode 100644 demo/src/sample/automation/config.json rename demo/src/{sample_json => sample/blankspace}/blankspace.json (84%) create mode 100644 demo/src/sample/blankspace/config.json create mode 100644 demo/src/sample/manual/config.json rename demo/src/{sample_json => sample/manual}/manual.json (100%) create mode 100644 demo/src/sample/simple/config.json rename demo/src/{sample_json => sample/simple}/simple.json (72%) diff --git a/demo/src/MemoryModelsSample.tsx b/demo/src/MemoryModelsSample.tsx index 6a41dafc..92c8d551 100644 --- a/demo/src/MemoryModelsSample.tsx +++ b/demo/src/MemoryModelsSample.tsx @@ -9,19 +9,22 @@ type MemoryModelsSamplePropTypes = { }; export default function MemoryModelsSample(props: MemoryModelsSamplePropTypes) { - const [fileContents, setFileContents] = useState<{ [key: string]: string }>( - {} - ); + const [fileContents, setFileContents] = useState<{ + [key: string]: [string, Object]; + }>({}); useEffect(() => { - const sampleFiles = ["automation", "blankspace", "manual", "simple"]; + const samples = ["automation", "blankspace", "manual", "simple"]; const tempFileContents = {}; - for (const fileName of sampleFiles) { - tempFileContents[fileName] = JSON.stringify( - require(`./sample_json/${fileName}.json`), - null, - 2 - ); + for (const sample of samples) { + tempFileContents[sample] = [ + JSON.stringify( + require(`./sample/${sample}/${sample}.json`), + null, + 2 + ), + require(`./sample/${sample}/config.json`), + ]; } setFileContents({ ...fileContents, @@ -29,14 +32,16 @@ export default function MemoryModelsSample(props: MemoryModelsSamplePropTypes) { }); }, []); - const handleButtonClick = (name: string, content: string) => { + const handleButtonClick = ( + name: string, + content: string, + config: Object + ) => { props.setTextData(content); - if (name === "manual") { - props.setConfigData({ - ...props.configData, - useAutomation: false, - }); - } + props.setConfigData({ + ...props.configData, + ...config, + }); }; return ( @@ -48,7 +53,11 @@ export default function MemoryModelsSample(props: MemoryModelsSamplePropTypes) {