Skip to content

Commit

Permalink
Merge pull request #58 from RyanNerd/api-set-change
Browse files Browse the repository at this point in the history
Changed how APIs get set in the providers
  • Loading branch information
RyanNerd authored Oct 25, 2020
2 parents b9390a4 + 474d542 commit ff70335
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions src/components/Pages/LoginPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/managers/MedicineManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down
3 changes: 0 additions & 3 deletions src/providers/MedHistoryProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

Expand Down
3 changes: 0 additions & 3 deletions src/providers/MedicineProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

Expand Down
3 changes: 0 additions & 3 deletions src/providers/ResidentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
},

Expand Down

0 comments on commit ff70335

Please sign in to comment.