-
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.
Former-commit-id: 5bf13c3
- Loading branch information
Showing
12 changed files
with
8,171 additions
and
720 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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,50 @@ | ||
| import React from 'react'; | ||
| import useFetch from 'use-http'; | ||
| import API_BASE_PATH, { BASE_PATH } from '../../App.constant'; | ||
| import has from 'lodash/has'; | ||
| import { groupBy } from 'lodash'; | ||
|
|
||
|
|
||
| const PropertiesContext = React.createContext(); | ||
|
|
||
| const { Provider, Consumer } = PropertiesContext; | ||
|
|
||
| function PropertiesProvider({ children, cache = 'no-cache' }) { | ||
|
|
||
| const [properties, setProperties] = React.useState([]); | ||
|
|
||
|
|
||
| const { get, response, loading } = useFetch('', { | ||
| cachePolicy: cache | ||
| }); | ||
|
|
||
| async function loadProperties() { | ||
| const list = await get(`${API_BASE_PATH}/shib/properties`); | ||
| if (response.ok) { | ||
| setProperties(list); | ||
| } | ||
| } | ||
|
|
||
| /*eslint-disable react-hooks/exhaustive-deps*/ | ||
| React.useEffect(() => { loadProperties() }, []); | ||
|
|
||
| return (<Provider value={{properties, loading}}>{children}</Provider>); | ||
| } | ||
|
|
||
| function useProperties() { | ||
| const { properties } = React.useContext(PropertiesContext); | ||
| return properties; | ||
| } | ||
|
|
||
| function usePropertiesLoading() { | ||
| const { loading } = React.useContext(PropertiesContext); | ||
| return loading; | ||
| } | ||
|
|
||
| export { | ||
| PropertiesProvider, | ||
| PropertiesContext, | ||
| Consumer as PropertiesConsumer, | ||
| useProperties, | ||
| usePropertiesLoading, | ||
| }; |
Oops, something went wrong.