diff --git a/.env.development b/.env.development new file mode 100644 index 0000000..5b6c744 --- /dev/null +++ b/.env.development @@ -0,0 +1,3 @@ +VITE_FETCH_URL=http://localhost:8080/ +VITE_FETCH_PATH=simplify/table/ +VITE_FETCH_FULL=$VITE_FETCH_URL$VITE_FETCH_PATH \ No newline at end of file diff --git a/.env.production b/.env.production new file mode 100644 index 0000000..6b8fdb3 --- /dev/null +++ b/.env.production @@ -0,0 +1,3 @@ +VITE_FETCH_URL=https://api.martials.no/ +VITE_FETCH_PATH=simplify-truths/do/simplify/table/ +VITE_FETCH_FULL=$VITE_FETCH_URL$VITE_FETCH_PATH \ No newline at end of file diff --git a/env.d.ts b/env.d.ts new file mode 100644 index 0000000..8f52144 --- /dev/null +++ b/env.d.ts @@ -0,0 +1,11 @@ +/// + +interface ImportMetaEnv { + readonly VITE_FETCH_URL: string, + readonly VITE_FETCH_PATH: string, + readonly VITE_FETCH_FULL: string, +} + +interface ImportMeta { + readonly env: ImportMetaEnv +} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1967080..8ce3eb5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -925,6 +925,14 @@ "resolved": "https://registry.npmjs.org/@types/diff/-/diff-5.0.2.tgz", "integrity": "sha512-uw8eYMIReOwstQ0QKF0sICefSy8cNO/v7gOTiIy9SbwuHyEecJUm7qlgueOO5S1udZ5I/irVydHVwMchgzbKTg==" }, + "node_modules/@types/node": { + "version": "18.15.11", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz", + "integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==", + "dev": true, + "optional": true, + "peer": true + }, "node_modules/acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", diff --git a/src/truth-table.tsx b/src/truth-table.tsx index 80d6b5d..6bcd0e6 100644 --- a/src/truth-table.tsx +++ b/src/truth-table.tsx @@ -25,10 +25,6 @@ import { exportToExcel } from "./functions/export"; import { Link } from "./components/link"; import { isTouch } from "./functions/touch"; -const endpoint = "https://api.martials.no/simplify-truths/do/simplify/table"; -const localhost = "http://localhost:8080/simplify/table"; -const useDev = true; - type Option = { name: string, value: "NONE" | "TRUE" | "FALSE" | "DEFAULT" | "TRUE_FIRST" | "FALSE_FIRST" }; // TODO move some code to new components @@ -95,7 +91,7 @@ const TruthTablePage: Component = () => { let exp = getInputElement()?.value; if (exp) { - exp = exp.replaceAll("|", "/").trimEnd(); + exp = exp.replaceAll("|", ":").trimEnd(); history.pushState(null, "", `?exp=${ encodeURIComponent(exp) }&simplify=${ simplifyEnabled() }& hide=${ hideValues().value }&sort=${ sortValues().value }&hideIntermediate=${ hideIntermediates() }`); @@ -110,8 +106,8 @@ hide=${ hideValues().value }&sort=${ sortValues().value }&hideIntermediate=${ hi if (exp !== "") { setError(null); setIsLoaded(false); - - fetch(`${ useDev ? localhost : endpoint }/${ encodeURIComponent(exp) }? +// TODO add button on DEV to switch between local and remote + fetch(`${ import.meta.env.VITE_FETCH_FULL }${ encodeURIComponent(exp) }? simplify=${ simplifyEnabled() }&hide=${ hideValues().value }&sort=${ sortValues().value }&caseSensitive=false& hideIntermediate=${ hideIntermediates() }`) .then(res => res.json())