@taruvi/navkit 0.0.6 → 0.0.7

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.7",
4
4
  "main": "src/App.tsx",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -61,32 +61,7 @@ export const NavkitProvider = ({ children, client }: NavkitProviderProps) => {
61
61
  const getData = useCallback(async (isUserAuthenticated: boolean) => {
62
62
  user.current = new User(client)
63
63
  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
- // }
64
+ const fetchedSettings = await settings?.current?.get?.()
90
65
  siteSettings.current = fetchedSettings
91
66
  if (isUserAuthenticated) {
92
67
  const userDataResponse = await user.current.getUserData?.()
@@ -94,9 +69,9 @@ export const NavkitProvider = ({ children, client }: NavkitProviderProps) => {
94
69
 
95
70
  // Fetch user apps using username from userData
96
71
  if (userDataResponse?.data?.username) {
97
- const appsResponse = await user.current.getUserApps(userDataResponse.data.username)
72
+ const appsResponse = await user.current.getUserApps?.(userDataResponse.data.username)
98
73
  // Transform API response to match AppData interface
99
- const transformedApps: AppData[] = (appsResponse || []).map((app: any) => ({
74
+ const transformedApps: AppData[] = (appsResponse?.data || []).map?.((app: any) => ({
100
75
  id: app.slug,
101
76
  appname: app.display_name || app.name,
102
77
  icon: app.icon,
@@ -146,7 +121,7 @@ export const NavkitProvider = ({ children, client }: NavkitProviderProps) => {
146
121
  }, [getData])
147
122
 
148
123
  return (
149
- <NavigationContext.Provider value={{ navigateToUrl, isDesk, appsList, userData, siteSettings: siteSettings.current, jwtToken, isUserAuthenticated }}>
124
+ <NavigationContext.Provider value={{ navigateToUrl, isDesk, appsList, userData, siteSettings: siteSettings.current, jwtToken, isUserAuthenticated, client, auth }}>
150
125
  {children}
151
126
  </NavigationContext.Provider>
152
127
  )
@@ -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 {