@taruvi/navkit 0.0.39 → 0.0.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taruvi/navkit",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "main": "src/App.tsx",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/App.tsx CHANGED
@@ -14,7 +14,8 @@ import type { Client } from "@taruvi/sdk"
14
14
 
15
15
  const NavkitContent = () => {
16
16
  const { isUserAuthenticated, siteSettings, appSettings, appName, userData, jwtToken, themeMode } = useNavigation();
17
- const showTaruviLogo = !appName
17
+ const resolvedAppName = appName || appSettings?.displayName
18
+ const showTaruviLogo = !resolvedAppName && !appSettings?.icon
18
19
  const styles = getAppStyles(themeMode)
19
20
  const [showAppLauncher, setShowAppLauncher] = useState<boolean>(false)
20
21
  const [showProfileMenu, setShowProfileMenu] = useState<boolean>(false)
@@ -42,9 +43,9 @@ const NavkitContent = () => {
42
43
  ) : (
43
44
  <>
44
45
  {appSettings?.icon ? <Box component="img" src={appSettings?.icon} sx={styles.logo} /> : <></>}
45
- {(appName || appSettings?.displayName) &&
46
+ {resolvedAppName &&
46
47
  <Typography sx={styles.appName} onClick={() => (window.location.href = "/")}>
47
- {(() => { const name = appName || appSettings!.displayName!; return name.length > 40 ? `${name.substring(0, 40)}...` : name })()}
48
+ {resolvedAppName.length > 40 ? `${resolvedAppName.substring(0, 40)}...` : resolvedAppName}
48
49
  </Typography>
49
50
  }
50
51
  </>
@@ -130,4 +131,4 @@ const Navkit = ({ client, getTheme, appName }: NavkitProps) => {
130
131
  )
131
132
  }
132
133
 
133
- export default Navkit
134
+ export default Navkit
@@ -31,7 +31,7 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
31
31
  frontendUrl: '',
32
32
  enableDarkMode: false,
33
33
  })
34
- const appSettings = useRef<AppSettings>({})
34
+ const [appSettings, setAppSettings] = useState<AppSettings>({})
35
35
 
36
36
  const [isDesk, setIsDesk] = useState<boolean>(false)
37
37
  const [appsList, setAppsList] = useState<AppData[]>([])
@@ -87,12 +87,12 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
87
87
  // Fetch app settings to get the app name
88
88
  try {
89
89
  const { data } = appName ? { data: { display_name: appName } } : await new App(client).settings().execute() as { data: { display_name?: string, icon?: string, primary_color?: string, secondary_color?: string } }
90
- appSettings.current = {
90
+ setAppSettings({
91
91
  displayName: data?.display_name,
92
92
  icon: data?.icon,
93
93
  primaryColor: data?.primary_color,
94
94
  secondaryColor: data?.secondary_color
95
- }
95
+ })
96
96
  } catch {
97
97
  // App settings not available, continue without app settings
98
98
  }
@@ -126,7 +126,7 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
126
126
  }
127
127
  }
128
128
 
129
- }, [client])
129
+ }, [appName, client])
130
130
 
131
131
  useLayoutEffect(() => {
132
132
  const init = async () => {
@@ -169,7 +169,7 @@ export const NavkitProvider = ({ children, client, onThemeChange, appName }: Nav
169
169
  }, [themeMode, onThemeChange])
170
170
 
171
171
  return (
172
- <NavigationContext.Provider value={{ navigateToUrl, isDesk, appsList, userData, siteSettings: siteSettings.current, appSettings: appSettings.current, appName, jwtToken, isUserAuthenticated, client, auth, themeMode, toggleTheme }}>
172
+ <NavigationContext.Provider value={{ navigateToUrl, isDesk, appsList, userData, siteSettings: siteSettings.current, appSettings, appName, jwtToken, isUserAuthenticated, client, auth, themeMode, toggleTheme }}>
173
173
  {children}
174
174
  </NavigationContext.Provider>
175
175
  )
@@ -181,4 +181,4 @@ export const useNavigation = () => {
181
181
  throw new Error('useNavigation must be used within a NavkitProvider')
182
182
  }
183
183
  return context
184
- }
184
+ }