-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
course mapping connection to backend
- Loading branch information
Showing
5 changed files
with
59 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { axiosInstance } from '../config/axiosInstance'; | ||
import { uiConfigUrl } from '../config/endpoints'; | ||
import { twentyFourHours } from '../config/timeConstants'; | ||
import { useQuery } from 'react-query'; | ||
|
||
/** | ||
* @description Reaches out to the backend and gets the configuration data required for the application. Valid for 24hrs | ||
*/ | ||
|
||
export function useInfoMappings() { | ||
return useQuery( | ||
'ui-config', | ||
() => axiosInstance.get(uiConfigUrl).then((res) => res.data), | ||
{ | ||
staleTime: twentyFourHours, | ||
cacheTime: twentyFourHours, | ||
} | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Functions to render data | ||
export const getDeeplyNestedData = (strKey, data) => { | ||
if (!strKey) return null; | ||
|
||
// gets the keys for the data mapping | ||
const objKeys = strKey.split('.'); | ||
|
||
// inits with all the data | ||
let valueToReturn = data; | ||
|
||
// Reduces it down to the specific value | ||
objKeys.forEach((key) => { | ||
if (valueToReturn) { | ||
valueToReturn = valueToReturn[key]; | ||
} | ||
}); | ||
|
||
// Returning the desired value. | ||
return valueToReturn; | ||
}; |