Skip to content

Commit

Permalink
Improve error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
domdomegg committed Nov 13, 2023
1 parent 76d13b5 commit 7aad139
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 18 deletions.
12 changes: 10 additions & 2 deletions frontend/other.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,23 @@ const OtherPage = () => {

const base = useBase();

const [recalculating, setRecalculating] = useState<boolean>(false);
const [error, setError] = useState<Error | undefined>(undefined);

const configuredPersonTypes = Object.values(preset.personTypes)
.filter((personType) =>
personType.cohortOverlapFullField ||
personType.cohortOverlapPartialField
)

if (!preset.cohortsTable) {
return <Text>Select a cohorts table</Text>
}
const cohortsTable = base.getTableByIdIfExists(preset.cohortsTable);
if (!cohortsTable) {
return <Text>Cohorts table ({preset.cohortsTable}) not found</Text>
}
// eslint-disable-next-line react-hooks/rules-of-hooks
const rawCohorts = useRecords(cohortsTable, {
fields: [
preset.cohortsTableStartDateField,
Expand Down Expand Up @@ -57,8 +67,6 @@ const OtherPage = () => {
}];
});

const [recalculating, setRecalculating] = useState<boolean>(false);
const [error, setError] = useState<Error | undefined>(undefined);
const recalculateOverlap = async () => {
try {
setError(undefined);
Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 7aad139

Please sign in to comment.