2020-12-14 06:44:10 -05:00
|
|
|
import React, { createContext, useContext } from 'react'
|
|
|
|
import PropTypes from 'prop-types'
|
2021-01-14 10:16:54 -05:00
|
|
|
import ExposedSettings from '../../main/exposed-settings'
|
2020-12-14 06:44:10 -05:00
|
|
|
|
|
|
|
export const ApplicationContext = createContext()
|
|
|
|
|
|
|
|
export function ApplicationProvider({ children }) {
|
2021-01-14 10:16:54 -05:00
|
|
|
const applicationContextValue = {
|
|
|
|
user: window.user,
|
|
|
|
exposedSettings: ExposedSettings
|
|
|
|
}
|
2020-12-14 06:44:10 -05:00
|
|
|
return (
|
2021-01-14 10:16:54 -05:00
|
|
|
<ApplicationContext.Provider value={applicationContextValue}>
|
2020-12-14 06:44:10 -05:00
|
|
|
{children}
|
|
|
|
</ApplicationContext.Provider>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
ApplicationProvider.propTypes = {
|
|
|
|
children: PropTypes.any
|
|
|
|
}
|
|
|
|
|
|
|
|
export function useApplicationContext() {
|
2021-01-14 10:16:54 -05:00
|
|
|
const applicationContext = useContext(ApplicationContext)
|
|
|
|
return applicationContext
|
2020-12-14 06:44:10 -05:00
|
|
|
}
|