@vertesia/ui 0.70.0 → 0.71.0

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.
Files changed (37) hide show
  1. package/lib/esm/core/components/shadcn/tabs.js +13 -8
  2. package/lib/esm/core/components/shadcn/tabs.js.map +1 -1
  3. package/lib/esm/session/auth/useCurrentTenant.js +63 -0
  4. package/lib/esm/session/auth/useCurrentTenant.js.map +1 -0
  5. package/lib/esm/session/index.js +1 -0
  6. package/lib/esm/session/index.js.map +1 -1
  7. package/lib/esm/shell/SplashScreen.js +10 -3
  8. package/lib/esm/shell/SplashScreen.js.map +1 -1
  9. package/lib/esm/shell/VertesiaShell.js +2 -2
  10. package/lib/esm/shell/VertesiaShell.js.map +1 -1
  11. package/lib/esm/shell/login/InviteAcceptModal.js +29 -12
  12. package/lib/esm/shell/login/InviteAcceptModal.js.map +1 -1
  13. package/lib/tsconfig.tsbuildinfo +1 -1
  14. package/lib/types/core/components/shadcn/tabs.d.ts +4 -1
  15. package/lib/types/core/components/shadcn/tabs.d.ts.map +1 -1
  16. package/lib/types/session/auth/useCurrentTenant.d.ts +15 -0
  17. package/lib/types/session/auth/useCurrentTenant.d.ts.map +1 -0
  18. package/lib/types/session/index.d.ts +1 -0
  19. package/lib/types/session/index.d.ts.map +1 -1
  20. package/lib/types/shell/SplashScreen.d.ts +3 -1
  21. package/lib/types/shell/SplashScreen.d.ts.map +1 -1
  22. package/lib/types/shell/VertesiaShell.d.ts +3 -1
  23. package/lib/types/shell/VertesiaShell.d.ts.map +1 -1
  24. package/lib/types/shell/login/InviteAcceptModal.d.ts.map +1 -1
  25. package/lib/vertesia-ui-core.js +1 -1
  26. package/lib/vertesia-ui-core.js.map +1 -1
  27. package/lib/vertesia-ui-session.js +1 -1
  28. package/lib/vertesia-ui-session.js.map +1 -1
  29. package/lib/vertesia-ui-shell.js +1 -1
  30. package/lib/vertesia-ui-shell.js.map +1 -1
  31. package/package.json +4 -4
  32. package/src/core/components/shadcn/tabs.tsx +31 -14
  33. package/src/session/auth/useCurrentTenant.ts +73 -0
  34. package/src/session/index.ts +1 -0
  35. package/src/shell/SplashScreen.tsx +36 -3
  36. package/src/shell/VertesiaShell.tsx +4 -2
  37. package/src/shell/login/InviteAcceptModal.tsx +36 -20
@@ -3,19 +3,21 @@ import { UserPermissionProvider } from "@vertesia/ui/features";
3
3
  import { UserSessionProvider } from "@vertesia/ui/session";
4
4
  import { SplashScreen } from "./SplashScreen";
5
5
  import { SigninScreen } from "./login/SigninScreen";
6
+ import { ReactNode } from "react";
6
7
 
7
8
 
8
9
  interface VertesiaShellProps {
9
10
  children: React.ReactNode;
10
11
  lightLogo?: string;
11
12
  darkLogo?: string;
13
+ loadingIcon?: ReactNode;
12
14
  }
13
- export function VertesiaShell({ children, lightLogo, darkLogo }: VertesiaShellProps) {
15
+ export function VertesiaShell({ children, lightLogo, darkLogo, loadingIcon }: VertesiaShellProps) {
14
16
  return (
15
17
  <ToastProvider>
16
18
  <UserSessionProvider>
17
19
  <ThemeProvider defaultTheme="system" storageKey="vite-ui-theme">
18
- <SplashScreen />
20
+ <SplashScreen icon={loadingIcon} />
19
21
  <SigninScreen allowedPrefix="/shared/" lightLogo={lightLogo} darkLogo={darkLogo} />
20
22
  <UserPermissionProvider>
21
23
  {children}
@@ -1,5 +1,5 @@
1
1
  import { TransientToken, UserInviteTokenData } from "@vertesia/common"
2
- import { Button, Modal, ModalBody, ModalTitle } from "@vertesia/ui/core"
2
+ import { Button, VModal, VModalBody, VModalTitle } from "@vertesia/ui/core"
3
3
  import { useEffect, useState } from "react"
4
4
  import { useUserSession } from "@vertesia/ui/session"
5
5
 
@@ -14,15 +14,22 @@ export function InviteAcceptModal() {
14
14
  useEffect(() => {
15
15
  client.account.listInvites().then(invites => {
16
16
  if (invites.length > 0) {
17
- console.log("Got invites - showing modal")
18
- setInvites(invites)
19
- /*toast({
20
- status: 'info',
21
- title: 'You have pending invites',
22
- description: 'Click the button on the top right to review them.'
23
- })*/
17
+ // Filter out legacy invites that do not have account data
18
+ const notLegacyInvites = invites.filter(i => i.data.account);
19
+ if (notLegacyInvites.length === 0) {
20
+ console.log("No valid invites found, closing modal")
21
+ return;
22
+ }
23
+ // If we have valid invites, show the modal
24
+ console.log("Found valid invites", notLegacyInvites.length)
24
25
  setShowModal(true);
26
+ setInvites(notLegacyInvites);
27
+ } else {
28
+ console.log("No invites found, closing modal")
29
+ setShowModal(false);
25
30
  }
31
+ }).catch(err => {
32
+ console.error("Error fetching invites", err);
26
33
  })
27
34
  }, [account?.id])
28
35
 
@@ -32,8 +39,11 @@ export function InviteAcceptModal() {
32
39
  await client.account.acceptInvite(invite.id);
33
40
  await session.fetchAccounts();
34
41
  const remainingInvites = invites.filter(i => i.id !== invite.id)
35
- setInvites(remainingInvites)
36
- if (remainingInvites.length === 0) {
42
+
43
+ const notLegacyInvites = remainingInvites.filter(i => i.data.account);
44
+ if (notLegacyInvites.length > 0) {
45
+ setInvites(notLegacyInvites);
46
+ } else {
37
47
  closeModal();
38
48
  }
39
49
  }
@@ -47,31 +57,37 @@ export function InviteAcceptModal() {
47
57
  }
48
58
  }
49
59
 
50
- const inviteList = invites.map(invite => (
51
- <div key={invite.id} className="flex flex-row w-full justify-between border rounded-sm px-2 py-2 ">
60
+ const inviteList = invites.map(invite => {
61
+ if (!invite.data.account) {
62
+ console.warn("Invite has no account data", invite);
63
+ return null; // Skip rendering this invite
64
+ }
65
+
66
+ return (<div key={invite.id} className="flex flex-row w-full justify-between border rounded-sm px-2 py-2 ">
52
67
  <div className="flex flex-col">
53
- <div className="w-full font-semibold">{invite.data.account.name}</div>
68
+ <div className="w-full font-semibold">{invite.data.account.name ?? invite.data.account}</div>
69
+ {invite.data.project && <div className="w-full text-base">- {invite.data.project.name}</div>}
54
70
  <div className="text-xs">Role: {invite.data.role}</div>
55
71
  <div className="text-xs">by {invite.data.invitedBy.name}</div>
56
72
  </div>
57
73
  <div className="flex flex-col gap-4">
58
74
  <Button size={'xs'} onClick={() => accept(invite)}>Accept</Button> <Button size={'xs'} variant="secondary" onClick={() => reject(invite)}>Reject</Button>
59
75
  </div>
60
- </div>
61
- ))
76
+ </div>)
77
+ })
62
78
 
63
79
  return (
64
80
  <div>
65
- <Modal isOpen={showModal} onClose={closeModal}>
66
- <ModalTitle>Review Invites</ModalTitle>
67
- <ModalBody>
81
+ <VModal isOpen={showModal} onClose={closeModal}>
82
+ <VModalTitle>Review Invites</VModalTitle>
83
+ <VModalBody>
68
84
  <div className="text-sm pb-4">
69
85
  You have received the following invites to join other accounts.
70
86
  Please review and accept or declined them.
71
87
  </div>
72
88
  {inviteList}
73
- </ModalBody>
74
- </Modal>
89
+ </VModalBody>
90
+ </VModal>
75
91
  </div>
76
92
  )
77
93