| 1 |
import {createContext, ReactNode, useContext} from 'react'; |
| 2 |
import {CurrencySwitcherSetting} from '@givewp/forms/types'; |
| 3 |
|
| 4 |
const StoreContext = createContext(null); |
| 5 |
StoreContext.displayName = 'DonationFormSettings'; |
| 6 |
|
| 7 |
type PropTypes = { |
| 8 |
value: { |
| 9 |
[key: string]: unknown; |
| 10 |
currencySwitcherSettings?: CurrencySwitcherSetting[]; |
| 11 |
currencySwitcherMessage?: string; |
| 12 |
donateButtonCaption: string; |
| 13 |
multiStepNextButtonText: string; |
| 14 |
multiStepFirstButtonText: string; |
| 15 |
showHeader: boolean; |
| 16 |
}; |
| 17 |
children: ReactNode; |
| 18 |
}; |
| 19 |
|
| 20 |
/** |
| 21 |
* @since 3.0.0 |
| 22 |
*/ |
| 23 |
const DonationFormSettingsProvider = ({value, children}: PropTypes) => { |
| 24 |
return <StoreContext.Provider value={value}>{children}</StoreContext.Provider>; |
| 25 |
}; |
| 26 |
|
| 27 |
const useDonationFormSettings = () => useContext<PropTypes['value']>(StoreContext); |
| 28 |
|
| 29 |
export {DonationFormSettingsProvider, useDonationFormSettings}; |
| 30 |
|