Calculator
diff --git a/src/ExpressionLoader.jsx b/src/ExpressionLoader.jsx
index 459b30f..ea307ac 100644
--- a/src/ExpressionLoader.jsx
+++ b/src/ExpressionLoader.jsx
@@ -32,22 +32,22 @@ const ExpressionLoader = () => {
setMathExpression([...mathExpression, expressionDetails]);
};
-
-
useEffect(() => {
- async function getMathPixToken(){
+ async function getMathPixToken() {
try {
- let response = await fetch("http://aspacetech.us-east-2.elasticbeanstalk.com/token",{
- "content-type": "application/json",
- method: "POST"
- }).then(res => res.json());
+ let response = await fetch(
+ "http://aspacetech.us-east-2.elasticbeanstalk.com/token",
+ {
+ "content-type": "application/json",
+ method: "POST",
+ }
+ ).then((res) => res.json());
return response.token;
- }
- catch (e){
+ } catch (e) {
console.log("Failed to get temporary token");
}
- };
+ }
async function imageToMathPix(img) {
try {
@@ -84,10 +84,28 @@ const ExpressionLoader = () => {
}, [image]);
return (
-
-
-
-
+
+
+
+
+
+
+
+
+
+
{
+ if (e.key === "Enter") {
+ storeExpression(e.target.value);
+ }
+ }}
+ />
);
};
diff --git a/src/Expressions.jsx b/src/Expressions.jsx
index 410f0e0..3914626 100644
--- a/src/Expressions.jsx
+++ b/src/Expressions.jsx
@@ -1,6 +1,7 @@
import { useContext } from "react";
import MathContext from "./MathContext";
import { MathJax } from "better-react-mathjax";
+import ExpressionUploader from "./ExpressionLoader";
//import EquationSolver from "./EquationSolver";
const Expressions = () => {
@@ -9,52 +10,55 @@ const Expressions = () => {
return (
- {mathExpressions ? (
- mathExpressions.map((mExpr) => {
- return (
-
-
-
- {"`" + mExpr.asciimathExpr + "`"}
-
- {"`" + mExpr.nodeExpr.toString() + "`"}
-
- {Object.keys(mExpr.currentScope).map((variable) => {
- return (
-
-
- {
- mathExpressions.find(
- (m) => m.asciimathExpr === mExpr.asciimathExpr
- ).currentScope[variable] = e.target.value;
- setMathExpressions([...mathExpressions]);
- }}
- >
-
- );
- })}
-
-
+ {mathExpressions
+ ? mathExpressions.map((mExpr, idx) => {
+ return (
-
- );
- })
- ) : (
-
Upload math expression
- )}
+ className="ast-expression w-full font-bold text-black"
+ >
+
+
+
+ {"`" + "y_" + idx + "=" + mExpr.asciimathExpr + "`"}
+
+
+ {"`" + mExpr.nodeExpr.toString() + "`"}
+
+
+ {Object.keys(mExpr.currentScope).map((variable) => {
+ return (
+
+
+ {
+ mathExpressions.find(
+ (m) => m.asciimathExpr === mExpr.asciimathExpr
+ ).currentScope[variable] = e.target.value;
+ setMathExpressions([...mathExpressions]);
+ }}
+ >
+
+ );
+ })}
+
+
+
+ );
+ })
+ : null}
+
);
};
diff --git a/src/ImageCapture.jsx b/src/ImageCapture.jsx
index 8de2fa9..3d38ec7 100644
--- a/src/ImageCapture.jsx
+++ b/src/ImageCapture.jsx
@@ -1,7 +1,7 @@
const ImageCapture = () => {
//const ImageDraw = ({ setImage }) => {
return (
-