import { addExcludedAsset , getSettings , removeExcludedAsset , resetCurrentsTo , setFiat , setLanguage , setRates , useDispatch , useSelector } from '@store' ; import { IRates , ISettings , TFiatTicker , TUuid } from '@types' ; export interface ISettingsContext { settings : ISettings ; language : string ; addAssetToExclusionList ( uuid ) : void ; removeAssetfromExclusionList ( uuid ) : void ; updateSettingsAccounts ( accounts ) : void ; updateSettingsRates ( rates ) : void ; updateLanguageSelection ( language ) : void ; updateFiatCurrency ( fiatTicker ) : void ; setDemoMode ( isDemoMode ) : void ; } function useSettings ( ) { const settings = useSelector ( getSettings ) ; const dispatch = useDispatch ( ) ; const language = settings . language || '' ; const updateSettingsAccounts = ( accounts ) => { dispatch ( resetCurrentsTo ( accounts ) ) ; } ; const updateLanguageSelection = ( lang ) => { dispatch ( setLanguage ( lang ) ) ; } ; const updateFiatCurrency = ( fiat ) => { dispatch ( setFiat ( fiat ) ) ; } ; const addAssetToExclusionList = ( assetUuid ) : void => { dispatch ( addExcludedAsset ( assetUuid ) ) ; } ; const removeAssetfromExclusionList = ( assetUuid ) : void => { dispatch ( removeExcludedAsset ( assetUuid ) ) ; } ; const updateSettingsRates = ( rates ) => { dispatch ( setRates ( rates ) ) ; } ; return { settings , language , addAssetToExclusionList , removeAssetfromExclusionList , updateSettingsAccounts , updateSettingsRates , updateLanguageSelection , updateFiatCurrency } ; } export default useSettings ;