@taruvi/navkit 0.0.6 → 0.0.8

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.6",
3
+ "version": "0.0.8",
4
4
  "main": "src/App.tsx",
5
5
  "type": "module",
6
6
  "scripts": {
package/src/App.tsx CHANGED
@@ -31,7 +31,7 @@ const NavkitContent = () => {
31
31
  <AppBar position="static" sx={appStyles.appBar}>
32
32
  <Toolbar sx={appStyles.toolbar}>
33
33
  <Box component={"div"} sx={appStyles.leftSection}>
34
- {isUserAuthenticated &&
34
+ {isUserAuthenticated && appsList.length > 0 &&
35
35
  <IconButton onClick={() => setShowAppLauncher(!showAppLauncher)}>
36
36
  <FontAwesomeIcon icon={["fas", "th"]} style={appStyles.iconStyle} />
37
37
  </IconButton>
@@ -29,7 +29,6 @@ export const NavkitProvider = ({ children, client }: NavkitProviderProps) => {
29
29
  const checkIfDesk = async () => {
30
30
  const fetchedSettings = await settings?.current?.get?.()
31
31
  const frontendUrl = fetchedSettings?.data?.frontendUrl
32
- // const frontendUrl = "http://localhost:5173/desk"
33
32
  if (!frontendUrl) return false
34
33
  return window.location.href.includes(frontendUrl || '')
35
34
  }
@@ -61,32 +60,7 @@ export const NavkitProvider = ({ children, client }: NavkitProviderProps) => {
61
60
  const getData = useCallback(async (isUserAuthenticated: boolean) => {
62
61
  user.current = new User(client)
63
62
  settings.current = new Settings(client)
64
- const fetchedSettings = await settings?.current?.get()
65
- // const fetchedSettings = {
66
- // frontendUrl: "http://localhost:5173/",
67
- // showChat: true,
68
- // mattermostUrl: "https://chatprod.eoxvantage.com/",
69
- // shortcuts: [
70
- // {
71
- // id: "shortcut-helpdesk",
72
- // appname: "Helpdesk",
73
- // icon: "comment-dots",
74
- // url: "/helpdesk"
75
- // },
76
- // {
77
- // id: "shortcut-crm",
78
- // appname: "CRM",
79
- // icon: "address-book",
80
- // url: "/crm"
81
- // },
82
- // {
83
- // id: "shortcut-tasks",
84
- // appname: "Tasks",
85
- // icon: "square-check",
86
- // url: "/tasks"
87
- // }
88
- // ]
89
- // }
63
+ const fetchedSettings = await settings?.current?.get?.()
90
64
  siteSettings.current = fetchedSettings
91
65
  if (isUserAuthenticated) {
92
66
  const userDataResponse = await user.current.getUserData?.()
@@ -94,12 +68,12 @@ export const NavkitProvider = ({ children, client }: NavkitProviderProps) => {
94
68
 
95
69
  // Fetch user apps using username from userData
96
70
  if (userDataResponse?.data?.username) {
97
- const appsResponse = await user.current.getUserApps(userDataResponse.data.username)
71
+ const appsResponse = await user.current.getUserApps?.(userDataResponse.data.username)
98
72
  // Transform API response to match AppData interface
99
- const transformedApps: AppData[] = (appsResponse || []).map((app: any) => ({
73
+ const transformedApps: AppData[] = (appsResponse?.data || []).map?.((app: any) => ({
100
74
  id: app.slug,
101
75
  appname: app.display_name || app.name,
102
- icon: app.icon,
76
+ icon: app.icon || "fa-solid fa-question",
103
77
  url: app.url
104
78
  }))
105
79
  startTransition(() => {
@@ -146,7 +120,7 @@ export const NavkitProvider = ({ children, client }: NavkitProviderProps) => {
146
120
  }, [getData])
147
121
 
148
122
  return (
149
- <NavigationContext.Provider value={{ navigateToUrl, isDesk, appsList, userData, siteSettings: siteSettings.current, jwtToken, isUserAuthenticated }}>
123
+ <NavigationContext.Provider value={{ navigateToUrl, isDesk, appsList, userData, siteSettings: siteSettings.current, jwtToken, isUserAuthenticated, client, auth }}>
150
124
  {children}
151
125
  </NavigationContext.Provider>
152
126
  )
@@ -4,14 +4,14 @@ import { profileStyles } from './Profile.styles'
4
4
  import { useNavigation } from '../../NavkitContext'
5
5
 
6
6
  const ProfileMenu = () => {
7
- const { navigateToUrl, client } = useNavigation()
7
+ const { navigateToUrl, auth } = useNavigation()
8
8
 
9
9
  const handlePreferences = () => {
10
10
  navigateToUrl('preferences', true)
11
11
  }
12
12
 
13
13
  const handleLogout = async () => {
14
- await client.auth.logout()
14
+ await auth.logout()
15
15
  }
16
16
 
17
17
  return (
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from "react"
2
- import type { Client } from "@taruvi/sdk"
2
+ import type { Client, Auth } from "@taruvi/sdk"
3
3
 
4
4
  export interface AppData {
5
5
  appname: string,
@@ -31,6 +31,8 @@ export interface NavigationContextType {
31
31
  siteSettings: SiteSettings
32
32
  jwtToken: string
33
33
  isUserAuthenticated: boolean
34
+ client: Client
35
+ auth: Auth
34
36
  }
35
37
 
36
38
  export interface NavkitProviderProps {