From 7aad1396075747bbf0c43f8f1cb39b2b82b9237f Mon Sep 17 00:00:00 2001 From: Adam Jones Date: Mon, 13 Nov 2023 21:59:45 +0000 Subject: [PATCH] Improve error handling --- frontend/other.tsx | 12 ++++++++++-- package-lock.json | 28 ++++++++++++++-------------- package.json | 4 ++-- 3 files changed, 26 insertions(+), 18 deletions(-) diff --git a/frontend/other.tsx b/frontend/other.tsx index 47f5f2b..a51e129 100644 --- a/frontend/other.tsx +++ b/frontend/other.tsx @@ -23,13 +23,23 @@ const OtherPage = () => { const base = useBase(); + const [recalculating, setRecalculating] = useState(false); + const [error, setError] = useState(undefined); + const configuredPersonTypes = Object.values(preset.personTypes) .filter((personType) => personType.cohortOverlapFullField || personType.cohortOverlapPartialField ) + if (!preset.cohortsTable) { + return Select a cohorts table + } const cohortsTable = base.getTableByIdIfExists(preset.cohortsTable); + if (!cohortsTable) { + return Cohorts table ({preset.cohortsTable}) not found + } + // eslint-disable-next-line react-hooks/rules-of-hooks const rawCohorts = useRecords(cohortsTable, { fields: [ preset.cohortsTableStartDateField, @@ -57,8 +67,6 @@ const OtherPage = () => { }]; }); - const [recalculating, setRecalculating] = useState(false); - const [error, setError] = useState(undefined); const recalculateOverlap = async () => { try { setError(undefined); diff --git a/package-lock.json b/package-lock.json index db3c1be..4f6fadb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7,14 +7,14 @@ "": { "hasInstallScript": true, "dependencies": { - "@airtable/blocks": "^1.17.0", + "@airtable/blocks": "^1.18.0", "@headlessui/react": "^1.7.7", "glpk.js": "^4.0.1", "react": "^16.14.0", "react-dom": "^16.14.0" }, "devDependencies": { - "@airtable/blocks-cli": "^2.0.3", + "@airtable/blocks-cli": "^2.0.4", "@types/jest": "^29.2.5", "@typescript-eslint/eslint-plugin": "^5.48.1", "@typescript-eslint/parser": "^5.48.1", @@ -28,9 +28,9 @@ } }, "node_modules/@airtable/blocks": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/@airtable/blocks/-/blocks-1.17.0.tgz", - "integrity": "sha512-IeZI76Cx9+pf9VdmzxXJfiDW5kQNx152rhk7xOkeenemX9GJjYW36NH6yq/v/72bBwcZ/SBjMBHRZqZTIAp9UQ==", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/@airtable/blocks/-/blocks-1.18.0.tgz", + "integrity": "sha512-nIgV1BA0N6lykqyMI771+gUNQW4bTtqUr2gvmWNOcswkhrlMoKoCBY6IDwzbg4IBBqgwR8L91WizfQ5G0CrJtg==", "dependencies": { "@airtable/eslint-plugin-blocks": "^1.0.2", "@babel/runtime": "^7.7.6", @@ -58,9 +58,9 @@ } }, "node_modules/@airtable/blocks-cli": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@airtable/blocks-cli/-/blocks-cli-2.0.3.tgz", - "integrity": "sha512-My6Ua6SeGWqbU59jB/tFu0lL03i7OXTbqZdtEY/yPGdmi5fy+99+gZ+AYJBfY1WQhCCwddFyrB/BF+3D7EpSVg==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@airtable/blocks-cli/-/blocks-cli-2.0.4.tgz", + "integrity": "sha512-vlpKckiMqXi/ocXaSwSIVVFY92QM9PTV3FaoXPUrU0cAgYj4mks08Z/yBdtvSc+vPNbISUzx6RtwaYejoAVMBQ==", "dev": true, "dependencies": { "@airtable/blocks-webpack-bundler": ">=0.0.2 || >=0.0.2-beta", @@ -17229,9 +17229,9 @@ }, "dependencies": { "@airtable/blocks": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/@airtable/blocks/-/blocks-1.17.0.tgz", - "integrity": "sha512-IeZI76Cx9+pf9VdmzxXJfiDW5kQNx152rhk7xOkeenemX9GJjYW36NH6yq/v/72bBwcZ/SBjMBHRZqZTIAp9UQ==", + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/@airtable/blocks/-/blocks-1.18.0.tgz", + "integrity": "sha512-nIgV1BA0N6lykqyMI771+gUNQW4bTtqUr2gvmWNOcswkhrlMoKoCBY6IDwzbg4IBBqgwR8L91WizfQ5G0CrJtg==", "requires": { "@airtable/eslint-plugin-blocks": "^1.0.2", "@babel/runtime": "^7.7.6", @@ -17266,9 +17266,9 @@ } }, "@airtable/blocks-cli": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/@airtable/blocks-cli/-/blocks-cli-2.0.3.tgz", - "integrity": "sha512-My6Ua6SeGWqbU59jB/tFu0lL03i7OXTbqZdtEY/yPGdmi5fy+99+gZ+AYJBfY1WQhCCwddFyrB/BF+3D7EpSVg==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@airtable/blocks-cli/-/blocks-cli-2.0.4.tgz", + "integrity": "sha512-vlpKckiMqXi/ocXaSwSIVVFY92QM9PTV3FaoXPUrU0cAgYj4mks08Z/yBdtvSc+vPNbISUzx6RtwaYejoAVMBQ==", "dev": true, "requires": { "@airtable/blocks-webpack-bundler": ">=0.0.2 || >=0.0.2-beta", diff --git a/package.json b/package.json index 68a36d1..3b1ed6d 100644 --- a/package.json +++ b/package.json @@ -11,14 +11,14 @@ "deploy": "node deploy.js" }, "dependencies": { - "@airtable/blocks": "^1.17.0", + "@airtable/blocks": "^1.18.0", "@headlessui/react": "^1.7.7", "glpk.js": "^4.0.1", "react": "^16.14.0", "react-dom": "^16.14.0" }, "devDependencies": { - "@airtable/blocks-cli": "^2.0.3", + "@airtable/blocks-cli": "^2.0.4", "@types/jest": "^29.2.5", "@typescript-eslint/eslint-plugin": "^5.48.1", "@typescript-eslint/parser": "^5.48.1",