Skip to content

Commit a7bbbdd

Browse files
App cleanup
1 parent 75a0bad commit a7bbbdd

1 file changed

Lines changed: 17 additions & 2 deletions

File tree

src/common/hooks/use-app-theme.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import { useEffect, useState } from 'react'
1+
import { useCallback, useEffect, useState } from 'react'
22
import { useDispatch, useSelector } from 'react-redux'
33
import { AnyAction } from 'redux'
4+
import get from 'lodash/get'
45

56
export type UseAppThemeType = {
67
getTheme: (url: string) => any
@@ -47,5 +48,19 @@ export function useAppTheme(options: UseAppThemeType) {
4748
}
4849
}, [appStore.configuration?.theme, dispatch, appTheme, getTheme, setThemes, setTheme])
4950

50-
return [appTheme, themeError]
51+
const getThemeData = useCallback(
52+
(currentTheme: string) => {
53+
if (appTheme) {
54+
const index = appTheme.findIndex((i: any) => Object.keys(i)[0] === currentTheme)
55+
if (index >= 0) {
56+
return get(appTheme[index], `${currentTheme}`, {})
57+
}
58+
}
59+
60+
return {}
61+
},
62+
[appTheme]
63+
)
64+
65+
return [appTheme, themeError, getThemeData]
5166
}

0 commit comments

Comments
 (0)