From 11a41f591a04588a991e51035fec1f015a85d959 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 23 Oct 2020 06:08:48 -0600 Subject: [PATCH 1/2] Changed how APIs get set in the providers --- src/components/ListGroups/DrugDropdown.tsx | 1 + src/components/Pages/LoginPage.tsx | 3 +++ src/managers/MedicineManager.ts | 2 +- src/providers/MedHistoryProvider.ts | 3 --- src/providers/MedicineProvider.ts | 3 --- src/providers/ResidentProvider.ts | 3 --- 6 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/components/ListGroups/DrugDropdown.tsx b/src/components/ListGroups/DrugDropdown.tsx index 21449fe4..28f9484f 100644 --- a/src/components/ListGroups/DrugDropdown.tsx +++ b/src/components/ListGroups/DrugDropdown.tsx @@ -18,6 +18,7 @@ interface IProps { const DrugDropdown = (props: IProps): JSX.Element | null => { const {medicineList, drugId} = props; + console.log('medicineList', medicineList); // Do not render unless we have the required props. if (!medicineList || medicineList.length === 0 || !drugId) { return null; diff --git a/src/components/Pages/LoginPage.tsx b/src/components/Pages/LoginPage.tsx index 6e4f81dc..12bf8714 100644 --- a/src/components/Pages/LoginPage.tsx +++ b/src/components/Pages/LoginPage.tsx @@ -58,6 +58,9 @@ const LoginPage = (props: IProps): JSX.Element => { if (response.success) { const apiKey = response.apiKey; setApiKey(apiKey).then(() => { + if (apiKey.length === 0) { + setErrorDetails(new Error('Invalid API Key')); + } providers.setApi(apiKey); // Load ALL Resident records up front and save them in the global store. diff --git a/src/managers/MedicineManager.ts b/src/managers/MedicineManager.ts index c4f70bff..303b4f91 100644 --- a/src/managers/MedicineManager.ts +++ b/src/managers/MedicineManager.ts @@ -53,7 +53,7 @@ const MedicineMananger = ( const _loadDrugLog = async (residentId: number) => { const searchCriteria = { where: [{column: 'ResidentId', comparison: '=', value: residentId}], - order_by: [{column: 'Updated', direction: 'desc'}], + order_by: [{column: 'Created', direction: 'desc'}], }; return medHistoryProvider.search(searchCriteria) .catch((err) => {throw err}); diff --git a/src/providers/MedHistoryProvider.ts b/src/providers/MedHistoryProvider.ts index 2e6ae9bc..d6bda22b 100644 --- a/src/providers/MedHistoryProvider.ts +++ b/src/providers/MedHistoryProvider.ts @@ -29,9 +29,6 @@ const MedHistoryProvider = (baseurl: string): IMedHistoryProvider => { * @param {string} apiKey */ setApiKey: (apiKey: string) => { - if (apiKey.length === 0) { - throw new Error('apiKey cannot be empty'); - } _apiKey = apiKey; }, diff --git a/src/providers/MedicineProvider.ts b/src/providers/MedicineProvider.ts index 832440b1..2d87e547 100644 --- a/src/providers/MedicineProvider.ts +++ b/src/providers/MedicineProvider.ts @@ -25,9 +25,6 @@ const MedicineProvider = (baseUrl: string): IMedicineProvider => { let _apiKey = null as string | null; return { setApiKey: (apiKey: string) => { - if (apiKey.length === 0) { - throw new Error('apiKey cannot be empty'); - } _apiKey = apiKey; }, diff --git a/src/providers/ResidentProvider.ts b/src/providers/ResidentProvider.ts index fa5191c8..68363a11 100644 --- a/src/providers/ResidentProvider.ts +++ b/src/providers/ResidentProvider.ts @@ -31,9 +31,6 @@ const ResidentProvider = (url: string): IResidentProvider => { * @param apiKey */ setApiKey: (apiKey: string) => { - if (apiKey.length === 0) { - throw new Error('apiKey cannot be empty'); - } _apiKey = apiKey; }, From 474d5424b1beafd94c7c2c86680b3eaf8dee6432 Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 25 Oct 2020 01:43:31 -0600 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A7=20Fixed=20a=20problem=20with?= =?UTF-8?q?=20the=20DropDown=20button=20The=20dropdown=20button=20would=20?= =?UTF-8?q?stop=20working=20after=20a=20modal=20was=20opened.=20After=20a?= =?UTF-8?q?=20=F0=9F=8C=A6=20day=20of=20pulling=20my=20=F0=9F=A6=B1=20out?= =?UTF-8?q?=20trying=20to=20figure=20out=20what=20had=20happened.=20Finall?= =?UTF-8?q?y=20found=20this:=20https://github.com/react-bootstrap/react-bo?= =?UTF-8?q?otstrap/issues/5409=20Had=20to=20thunk=20React=20back=20down=20?= =?UTF-8?q?to=2016.14.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 4 ++-- src/components/ListGroups/DrugDropdown.tsx | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 9a4202bb..28869b26 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "frak": "^3.1.2", "lodash": ">=4.17.13", "lodash.template": ">=4.5.0", - "react": "^17.0.1", + "react": "^16.14.0", "react-bootstrap": "^1.4.0", - "react-dom": "^17.0.1", + "react-dom": "^16.14.0", "react-scripts": "^3.4.4", "reactn": "^2.2.7", "typescript": "^4.0.3" diff --git a/src/components/ListGroups/DrugDropdown.tsx b/src/components/ListGroups/DrugDropdown.tsx index 28f9484f..21449fe4 100644 --- a/src/components/ListGroups/DrugDropdown.tsx +++ b/src/components/ListGroups/DrugDropdown.tsx @@ -18,7 +18,6 @@ interface IProps { const DrugDropdown = (props: IProps): JSX.Element | null => { const {medicineList, drugId} = props; - console.log('medicineList', medicineList); // Do not render unless we have the required props. if (!medicineList || medicineList.length === 0 || !drugId) { return null;