Skip to content

Commit 032d765

Browse files
committed
feat: wire up addon fields to component
1 parent 1b685ca commit 032d765

File tree

3 files changed

+16
-26
lines changed

3 files changed

+16
-26
lines changed

src/components/AnswerButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ export const AnswerButton = memo(function MyAddonSelector() {
1111
const isActive = !!globals[KEY];
1212

1313
function saveAnswer() {
14-
localStorage.setItem("answer", localStorage.getItem("response"));
15-
window.dispatchEvent(new Event("storage"));
14+
// window.dispatchEvent(new Event("storage"));
1615
}
1716

1817
return (

src/components/Evaluate.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ export function Evaluate() {
2525
const [response, updateResponse] = useState<string>("");
2626
const [args, updateArgs, resetArgs] = useArgs();
2727
async function evaluate(url: string, params: JSON) {
28-
console.log("remote eval");
29-
console.log(url);
30-
console.log(params);
31-
32-
const answer = parseStoredString(localStorage.getItem("answer"));
28+
const answer = parseStoredString(JSON.stringify(JSON.parse(localStorage.getItem("wizard.input")).answer));
29+
const response = parseStoredString(localStorage.getItem("student.input"));
3330

34-
const response = parseStoredString(localStorage.getItem("response"));
35-
console.log(response);
31+
console.log("remote eval");
32+
console.log("url", url);
33+
console.log("answer:", answer);
34+
console.log("params:", params);
35+
console.log("response", response);
3636

3737
const request = {
3838
url: url,

src/components/Form.tsx

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ type FormProps = {
1111
};
1212
export function Form(props: FormProps) {
1313
const [urlValue, setUrlValue] = useState("");
14-
const [schemaValue, setSchemaValue] = useState("{}");
14+
const [answer, setAnswer] = useState("");
15+
const [schemaValue, setSchemaValue] = useState("");
1516
interface ChangeEvent {
1617
target: {
1718
value: string;
@@ -24,11 +25,6 @@ export function Form(props: FormProps) {
2425
setSchemaValue(event.target.value);
2526
};
2627

27-
const handleAnswerChange = (event: ChangeEvent) => {
28-
localStorage.setItem("answer", event.target.value);
29-
setAnswer(event.target.value);
30-
};
31-
3228
const createEvalButton = () => (
3329
<button
3430
type="button"
@@ -38,7 +34,7 @@ export function Form(props: FormProps) {
3834
props.evalFunc(urlValue, JSON.parse(schemaValue));
3935
}}
4036
>
41-
Test Evaluation Function
37+
Test Evaluation Function (with Student View input)
4238
</button>
4339
);
4440

@@ -51,14 +47,9 @@ export function Form(props: FormProps) {
5147
</tr>
5248
);
5349

54-
const [answer, setAnswer] = useState("{}");
55-
useEffect(() => {
56-
const handleStorage = () => {
57-
setAnswer(localStorage.getItem("answer"));
58-
};
59-
window.addEventListener("storage", handleStorage);
60-
return () => window.removeEventListener("storage", handleStorage);
61-
}, []);
50+
window.addEventListener("storage", () => {
51+
setAnswer(JSON.stringify(JSON.parse(localStorage.getItem("wizard.input")).answer));
52+
})
6253

6354
return (
6455
<div style={formStyles.topLevelDiv}>
@@ -73,11 +64,11 @@ export function Form(props: FormProps) {
7364
/>
7465
)}
7566
{createRow(
76-
"Answer JSON:",
67+
"Answer:",
7768
<textarea
7869
style={formStyles.inputArea}
7970
value={answer}
80-
onChange={handleAnswerChange}
71+
onChange={(_) => {}}
8172
/>
8273
)}
8374
{createRow(

0 commit comments

Comments
 (0)