@shipfox/client-invitations 4.0.0 → 5.0.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.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +12 -0
- package/dist/complete-acceptance.d.ts +1 -1
- package/dist/complete-acceptance.js +1 -1
- package/dist/complete-acceptance.js.map +1 -1
- package/dist/core/invitation-preview.d.ts +21 -0
- package/dist/core/invitation-preview.d.ts.map +1 -0
- package/dist/core/invitation-preview.js +5 -0
- package/dist/core/invitation-preview.js.map +1 -0
- package/dist/hooks/api/invitation-preview-mapper.d.ts +4 -0
- package/dist/hooks/api/invitation-preview-mapper.d.ts.map +1 -0
- package/dist/hooks/api/invitation-preview-mapper.js +32 -0
- package/dist/hooks/api/invitation-preview-mapper.js.map +1 -0
- package/dist/hooks/api/preview-invitation.d.ts +12 -7
- package/dist/hooks/api/preview-invitation.d.ts.map +1 -1
- package/dist/hooks/api/preview-invitation.js +12 -6
- package/dist/hooks/api/preview-invitation.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/pages/invitation-accept-page.js +13 -13
- package/dist/pages/invitation-accept-page.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +3 -4
- package/src/complete-acceptance.ts +1 -1
- package/src/core/invitation-preview.ts +18 -0
- package/src/hooks/api/invitation-preview-mapper.test.ts +36 -0
- package/src/hooks/api/invitation-preview-mapper.ts +22 -0
- package/src/hooks/api/preview-invitation.ts +24 -9
- package/src/index.ts +2 -0
- package/src/pages/invitation-accept-page.tsx +15 -15
- package/tsconfig.build.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
$ shipfox-swc
|
|
2
|
-
Successfully compiled:
|
|
2
|
+
Successfully compiled: 9 files with swc (351.19ms)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @shipfox/client-invitations
|
|
2
2
|
|
|
3
|
+
## 5.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- ffd727b: Converges auth session and invitation state onto shared camelCase domain types validated at the API boundary, replacing the raw snake_case DTOs previously returned by login, signup, password reset, email verification, workspace creation, and invitation preview. `AuthState.user`, `useRefreshAuth()`, and `usePreviewInvitation()` now resolve to `UserIdentity`/`AuthenticatedSession`/`InvitationPreview` shapes (for example `accessToken` instead of `token`, `workspaceName` instead of `workspace_name`). Also moves the shared `AuthShell` component and session mapping helpers into `@shipfox/client-shell`, breaking the former `client-auth` ↔ `client-invitations` circular dependency.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 79df9d1: Fixes invitation query declarations for packed TypeScript consumers.
|
|
12
|
+
- Updated dependencies [ffd727b]
|
|
13
|
+
- @shipfox/client-shell@5.0.0
|
|
14
|
+
|
|
3
15
|
## 4.0.0
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -6,7 +6,7 @@ import type { NavigateOptions } from '@tanstack/react-router';
|
|
|
6
6
|
* routes the user into the workspace home.
|
|
7
7
|
*
|
|
8
8
|
* `refreshAuth` is passed in so this helper stays a plain function (no hook).
|
|
9
|
-
* Call sites construct it via `useRefreshAuth()` from `@shipfox/client-
|
|
9
|
+
* Call sites construct it via `useRefreshAuth()` from `@shipfox/client-shell/runtime`.
|
|
10
10
|
*/
|
|
11
11
|
export declare function completeInvitationAcceptance(params: {
|
|
12
12
|
workspaceId: string;
|
|
@@ -6,7 +6,7 @@ import { toast } from '@shipfox/react-ui/toast';
|
|
|
6
6
|
* routes the user into the workspace home.
|
|
7
7
|
*
|
|
8
8
|
* `refreshAuth` is passed in so this helper stays a plain function (no hook).
|
|
9
|
-
* Call sites construct it via `useRefreshAuth()` from `@shipfox/client-
|
|
9
|
+
* Call sites construct it via `useRefreshAuth()` from `@shipfox/client-shell/runtime`.
|
|
10
10
|
*/ export async function completeInvitationAcceptance(params) {
|
|
11
11
|
// Access tokens embed memberships at issue time, so refresh before AuthGuard
|
|
12
12
|
// reads the accepted workspace.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/complete-acceptance.ts"],"sourcesContent":["import {toast} from '@shipfox/react-ui/toast';\nimport type {NavigateOptions} from '@tanstack/react-router';\n\n/**\n * Final step of every successful invitation accept path (existing-user match,\n * signup-with-invitation success, login-then-accept). Refreshes the auth\n * session so the JWT carries the new membership before navigating, then\n * routes the user into the workspace home.\n *\n * `refreshAuth` is passed in so this helper stays a plain function (no hook).\n * Call sites construct it via `useRefreshAuth()` from `@shipfox/client-
|
|
1
|
+
{"version":3,"sources":["../src/complete-acceptance.ts"],"sourcesContent":["import {toast} from '@shipfox/react-ui/toast';\nimport type {NavigateOptions} from '@tanstack/react-router';\n\n/**\n * Final step of every successful invitation accept path (existing-user match,\n * signup-with-invitation success, login-then-accept). Refreshes the auth\n * session so the JWT carries the new membership before navigating, then\n * routes the user into the workspace home.\n *\n * `refreshAuth` is passed in so this helper stays a plain function (no hook).\n * Call sites construct it via `useRefreshAuth()` from `@shipfox/client-shell/runtime`.\n */\nexport async function completeInvitationAcceptance(params: {\n workspaceId: string;\n workspaceName: string;\n refreshAuth: () => Promise<unknown>;\n navigate: (opts: NavigateOptions) => Promise<void> | void;\n}): Promise<void> {\n // Access tokens embed memberships at issue time, so refresh before AuthGuard\n // reads the accepted workspace.\n try {\n await params.refreshAuth();\n } catch {\n // Even if refresh fails the membership is real in the DB; surface the\n // success toast and let the user re-auth if their session has fully\n // expired. The next API call will redirect to login as usual.\n }\n toast.success(`You joined ${params.workspaceName}.`);\n await params.navigate({\n to: '/workspaces/$wid',\n params: {wid: params.workspaceId},\n });\n}\n"],"names":["toast","completeInvitationAcceptance","params","refreshAuth","success","workspaceName","navigate","to","wid","workspaceId"],"mappings":"AAAA,SAAQA,KAAK,QAAO,0BAA0B;AAG9C;;;;;;;;CAQC,GACD,OAAO,eAAeC,6BAA6BC,MAKlD;IACC,6EAA6E;IAC7E,gCAAgC;IAChC,IAAI;QACF,MAAMA,OAAOC,WAAW;IAC1B,EAAE,OAAM;IACN,sEAAsE;IACtE,oEAAoE;IACpE,8DAA8D;IAChE;IACAH,MAAMI,OAAO,CAAC,CAAC,WAAW,EAAEF,OAAOG,aAAa,CAAC,CAAC,CAAC;IACnD,MAAMH,OAAOI,QAAQ,CAAC;QACpBC,IAAI;QACJL,QAAQ;YAACM,KAAKN,OAAOO,WAAW;QAAA;IAClC;AACF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type InvitationPreview = {
|
|
2
|
+
status: 'pending';
|
|
3
|
+
workspaceId: string;
|
|
4
|
+
workspaceName: string;
|
|
5
|
+
email: string;
|
|
6
|
+
invitedByDisplay?: string;
|
|
7
|
+
expiresAt: string;
|
|
8
|
+
} | {
|
|
9
|
+
status: 'expired';
|
|
10
|
+
workspaceName: string;
|
|
11
|
+
expiresAt: string;
|
|
12
|
+
} | {
|
|
13
|
+
status: 'already_used';
|
|
14
|
+
workspaceName: string;
|
|
15
|
+
} | {
|
|
16
|
+
status: 'invalid';
|
|
17
|
+
};
|
|
18
|
+
export declare function pendingInvitation(preview: InvitationPreview | undefined): Extract<InvitationPreview, {
|
|
19
|
+
status: 'pending';
|
|
20
|
+
}> | undefined;
|
|
21
|
+
//# sourceMappingURL=invitation-preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invitation-preview.d.ts","sourceRoot":"","sources":["../../src/core/invitation-preview.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GACzB;IACE,MAAM,EAAE,SAAS,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;CACnB,GACD;IAAC,MAAM,EAAE,SAAS,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAC,GAC7D;IAAC,MAAM,EAAE,cAAc,CAAC;IAAC,aAAa,EAAE,MAAM,CAAA;CAAC,GAC/C;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,CAAC;AAExB,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,iBAAiB,GAAG,SAAS,GACrC,OAAO,CAAC,iBAAiB,EAAE;IAAC,MAAM,EAAE,SAAS,CAAA;CAAC,CAAC,GAAG,SAAS,CAE7D"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/invitation-preview.ts"],"sourcesContent":["export type InvitationPreview =\n | {\n status: 'pending';\n workspaceId: string;\n workspaceName: string;\n email: string;\n invitedByDisplay?: string;\n expiresAt: string;\n }\n | {status: 'expired'; workspaceName: string; expiresAt: string}\n | {status: 'already_used'; workspaceName: string}\n | {status: 'invalid'};\n\nexport function pendingInvitation(\n preview: InvitationPreview | undefined,\n): Extract<InvitationPreview, {status: 'pending'}> | undefined {\n return preview?.status === 'pending' ? preview : undefined;\n}\n"],"names":["pendingInvitation","preview","status","undefined"],"mappings":"AAaA,OAAO,SAASA,kBACdC,OAAsC;IAEtC,OAAOA,SAASC,WAAW,YAAYD,UAAUE;AACnD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { PreviewInvitationResponseDto } from '@shipfox/api-workspaces-dto';
|
|
2
|
+
import type { InvitationPreview } from '#core/invitation-preview.js';
|
|
3
|
+
export declare function toInvitationPreview(dto: PreviewInvitationResponseDto): InvitationPreview;
|
|
4
|
+
//# sourceMappingURL=invitation-preview-mapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invitation-preview-mapper.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/invitation-preview-mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,6BAA6B,CAAC;AAC9E,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAEnE,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,4BAA4B,GAAG,iBAAiB,CAkBxF"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export function toInvitationPreview(dto) {
|
|
2
|
+
switch(dto.status){
|
|
3
|
+
case 'pending':
|
|
4
|
+
return {
|
|
5
|
+
status: dto.status,
|
|
6
|
+
workspaceId: dto.workspace_id,
|
|
7
|
+
workspaceName: dto.workspace_name,
|
|
8
|
+
email: dto.email,
|
|
9
|
+
...dto.invited_by_display ? {
|
|
10
|
+
invitedByDisplay: dto.invited_by_display
|
|
11
|
+
} : {},
|
|
12
|
+
expiresAt: dto.expires_at
|
|
13
|
+
};
|
|
14
|
+
case 'expired':
|
|
15
|
+
return {
|
|
16
|
+
status: dto.status,
|
|
17
|
+
workspaceName: dto.workspace_name,
|
|
18
|
+
expiresAt: dto.expires_at
|
|
19
|
+
};
|
|
20
|
+
case 'already_used':
|
|
21
|
+
return {
|
|
22
|
+
status: dto.status,
|
|
23
|
+
workspaceName: dto.workspace_name
|
|
24
|
+
};
|
|
25
|
+
case 'invalid':
|
|
26
|
+
return {
|
|
27
|
+
status: dto.status
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//# sourceMappingURL=invitation-preview-mapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/api/invitation-preview-mapper.ts"],"sourcesContent":["import type {PreviewInvitationResponseDto} from '@shipfox/api-workspaces-dto';\nimport type {InvitationPreview} from '#core/invitation-preview.js';\n\nexport function toInvitationPreview(dto: PreviewInvitationResponseDto): InvitationPreview {\n switch (dto.status) {\n case 'pending':\n return {\n status: dto.status,\n workspaceId: dto.workspace_id,\n workspaceName: dto.workspace_name,\n email: dto.email,\n ...(dto.invited_by_display ? {invitedByDisplay: dto.invited_by_display} : {}),\n expiresAt: dto.expires_at,\n };\n case 'expired':\n return {status: dto.status, workspaceName: dto.workspace_name, expiresAt: dto.expires_at};\n case 'already_used':\n return {status: dto.status, workspaceName: dto.workspace_name};\n case 'invalid':\n return {status: dto.status};\n }\n}\n"],"names":["toInvitationPreview","dto","status","workspaceId","workspace_id","workspaceName","workspace_name","email","invited_by_display","invitedByDisplay","expiresAt","expires_at"],"mappings":"AAGA,OAAO,SAASA,oBAAoBC,GAAiC;IACnE,OAAQA,IAAIC,MAAM;QAChB,KAAK;YACH,OAAO;gBACLA,QAAQD,IAAIC,MAAM;gBAClBC,aAAaF,IAAIG,YAAY;gBAC7BC,eAAeJ,IAAIK,cAAc;gBACjCC,OAAON,IAAIM,KAAK;gBAChB,GAAIN,IAAIO,kBAAkB,GAAG;oBAACC,kBAAkBR,IAAIO,kBAAkB;gBAAA,IAAI,CAAC,CAAC;gBAC5EE,WAAWT,IAAIU,UAAU;YAC3B;QACF,KAAK;YACH,OAAO;gBAACT,QAAQD,IAAIC,MAAM;gBAAEG,eAAeJ,IAAIK,cAAc;gBAAEI,WAAWT,IAAIU,UAAU;YAAA;QAC1F,KAAK;YACH,OAAO;gBAACT,QAAQD,IAAIC,MAAM;gBAAEG,eAAeJ,IAAIK,cAAc;YAAA;QAC/D,KAAK;YACH,OAAO;gBAACJ,QAAQD,IAAIC,MAAM;YAAA;IAC9B;AACF"}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
|
+
import { type FetchQueryOptions } from '@tanstack/react-query';
|
|
2
|
+
import type { InvitationPreview } from '#core/invitation-preview.js';
|
|
1
3
|
export declare const previewInvitationQueryKey: (token: string) => readonly ["invitations", "preview", string];
|
|
4
|
+
type PreviewInvitationQueryOptions = FetchQueryOptions<InvitationPreview, Error, InvitationPreview, ReturnType<typeof previewInvitationQueryKey>>;
|
|
5
|
+
export declare function previewInvitationQueryOptions(token: string): PreviewInvitationQueryOptions;
|
|
2
6
|
export declare function usePreviewInvitation(token: string | undefined): import("@tanstack/react-query").UseQueryResult<NoInfer<{
|
|
3
7
|
status: "pending";
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
workspaceId: string;
|
|
9
|
+
workspaceName: string;
|
|
6
10
|
email: string;
|
|
7
|
-
|
|
8
|
-
|
|
11
|
+
invitedByDisplay?: string;
|
|
12
|
+
expiresAt: string;
|
|
9
13
|
} | {
|
|
10
14
|
status: "expired";
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
workspaceName: string;
|
|
16
|
+
expiresAt: string;
|
|
13
17
|
} | {
|
|
14
18
|
status: "already_used";
|
|
15
|
-
|
|
19
|
+
workspaceName: string;
|
|
16
20
|
} | {
|
|
17
21
|
status: "invalid";
|
|
18
22
|
}>, Error>;
|
|
23
|
+
export {};
|
|
19
24
|
//# sourceMappingURL=preview-invitation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-invitation.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/preview-invitation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"preview-invitation.d.ts","sourceRoot":"","sources":["../../../src/hooks/api/preview-invitation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,KAAK,iBAAiB,EAAyB,MAAM,uBAAuB,CAAC;AACrF,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAGnE,eAAO,MAAM,yBAAyB,GAAI,OAAO,MAAM,gDACX,CAAC;AAE7C,KAAK,6BAA6B,GAAG,iBAAiB,CACpD,iBAAiB,EACjB,KAAK,EACL,iBAAiB,EACjB,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAC7C,CAAC;AAWF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,MAAM,GAAG,6BAA6B,CAQ1F;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS;;;;;;;;;;;;;;;;WAE7D"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { previewInvitationResponseSchema } from '@shipfox/api-workspaces-dto';
|
|
2
|
+
import { checkedApiRequest } from '@shipfox/client-api';
|
|
3
|
+
import { queryOptions, useQuery } from '@tanstack/react-query';
|
|
4
|
+
import { toInvitationPreview } from './invitation-preview-mapper.js';
|
|
3
5
|
export const previewInvitationQueryKey = (token)=>[
|
|
4
6
|
'invitations',
|
|
5
7
|
'preview',
|
|
@@ -9,16 +11,20 @@ async function previewInvitation(token) {
|
|
|
9
11
|
const params = new URLSearchParams({
|
|
10
12
|
token
|
|
11
13
|
});
|
|
12
|
-
|
|
14
|
+
const response = await checkedApiRequest(previewInvitationResponseSchema, `/invitations/preview?${params.toString()}`);
|
|
15
|
+
return toInvitationPreview(response);
|
|
13
16
|
}
|
|
14
|
-
export function
|
|
15
|
-
return
|
|
16
|
-
queryKey: previewInvitationQueryKey(token
|
|
17
|
+
export function previewInvitationQueryOptions(token) {
|
|
18
|
+
return queryOptions({
|
|
19
|
+
queryKey: previewInvitationQueryKey(token),
|
|
17
20
|
queryFn: ()=>previewInvitation(token),
|
|
18
21
|
enabled: Boolean(token),
|
|
19
22
|
retry: false,
|
|
20
23
|
staleTime: 30_000
|
|
21
24
|
});
|
|
22
25
|
}
|
|
26
|
+
export function usePreviewInvitation(token) {
|
|
27
|
+
return useQuery(previewInvitationQueryOptions(token ?? ''));
|
|
28
|
+
}
|
|
23
29
|
|
|
24
30
|
//# sourceMappingURL=preview-invitation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/hooks/api/preview-invitation.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/api/preview-invitation.ts"],"sourcesContent":["import {previewInvitationResponseSchema} from '@shipfox/api-workspaces-dto';\nimport {checkedApiRequest} from '@shipfox/client-api';\nimport {type FetchQueryOptions, queryOptions, useQuery} from '@tanstack/react-query';\nimport type {InvitationPreview} from '#core/invitation-preview.js';\nimport {toInvitationPreview} from './invitation-preview-mapper.js';\n\nexport const previewInvitationQueryKey = (token: string) =>\n ['invitations', 'preview', token] as const;\n\ntype PreviewInvitationQueryOptions = FetchQueryOptions<\n InvitationPreview,\n Error,\n InvitationPreview,\n ReturnType<typeof previewInvitationQueryKey>\n>;\n\nasync function previewInvitation(token: string): Promise<InvitationPreview> {\n const params = new URLSearchParams({token});\n const response = await checkedApiRequest(\n previewInvitationResponseSchema,\n `/invitations/preview?${params.toString()}`,\n );\n return toInvitationPreview(response);\n}\n\nexport function previewInvitationQueryOptions(token: string): PreviewInvitationQueryOptions {\n return queryOptions({\n queryKey: previewInvitationQueryKey(token),\n queryFn: () => previewInvitation(token),\n enabled: Boolean(token),\n retry: false,\n staleTime: 30_000,\n });\n}\n\nexport function usePreviewInvitation(token: string | undefined) {\n return useQuery(previewInvitationQueryOptions(token ?? ''));\n}\n"],"names":["previewInvitationResponseSchema","checkedApiRequest","queryOptions","useQuery","toInvitationPreview","previewInvitationQueryKey","token","previewInvitation","params","URLSearchParams","response","toString","previewInvitationQueryOptions","queryKey","queryFn","enabled","Boolean","retry","staleTime","usePreviewInvitation"],"mappings":"AAAA,SAAQA,+BAA+B,QAAO,8BAA8B;AAC5E,SAAQC,iBAAiB,QAAO,sBAAsB;AACtD,SAAgCC,YAAY,EAAEC,QAAQ,QAAO,wBAAwB;AAErF,SAAQC,mBAAmB,QAAO,iCAAiC;AAEnE,OAAO,MAAMC,4BAA4B,CAACC,QACxC;QAAC;QAAe;QAAWA;KAAM,CAAU;AAS7C,eAAeC,kBAAkBD,KAAa;IAC5C,MAAME,SAAS,IAAIC,gBAAgB;QAACH;IAAK;IACzC,MAAMI,WAAW,MAAMT,kBACrBD,iCACA,CAAC,qBAAqB,EAAEQ,OAAOG,QAAQ,IAAI;IAE7C,OAAOP,oBAAoBM;AAC7B;AAEA,OAAO,SAASE,8BAA8BN,KAAa;IACzD,OAAOJ,aAAa;QAClBW,UAAUR,0BAA0BC;QACpCQ,SAAS,IAAMP,kBAAkBD;QACjCS,SAASC,QAAQV;QACjBW,OAAO;QACPC,WAAW;IACb;AACF;AAEA,OAAO,SAASC,qBAAqBb,KAAyB;IAC5D,OAAOH,SAASS,8BAA8BN,SAAS;AACzD"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
export { type InvitationPreview, pendingInvitation } from '#core/invitation-preview.js';
|
|
1
2
|
export { completeInvitationAcceptance } from './complete-acceptance.js';
|
|
2
3
|
export { useAcceptInvitation } from './hooks/api/accept-invitation.js';
|
|
3
|
-
export { previewInvitationQueryKey, usePreviewInvitation, } from './hooks/api/preview-invitation.js';
|
|
4
|
+
export { previewInvitationQueryKey, previewInvitationQueryOptions, usePreviewInvitation, } from './hooks/api/preview-invitation.js';
|
|
4
5
|
export { InvitationAcceptPage } from './pages/invitation-accept-page.js';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,4BAA4B,EAAC,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,iBAAiB,EAAE,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AACtF,OAAO,EAAC,4BAA4B,EAAC,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAC,mBAAmB,EAAC,MAAM,kCAAkC,CAAC;AACrE,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,oBAAoB,GACrB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
export { pendingInvitation } from '#core/invitation-preview.js';
|
|
1
2
|
export { completeInvitationAcceptance } from './complete-acceptance.js';
|
|
2
3
|
export { useAcceptInvitation } from './hooks/api/accept-invitation.js';
|
|
3
|
-
export { previewInvitationQueryKey, usePreviewInvitation } from './hooks/api/preview-invitation.js';
|
|
4
|
+
export { previewInvitationQueryKey, previewInvitationQueryOptions, usePreviewInvitation } from './hooks/api/preview-invitation.js';
|
|
4
5
|
export { InvitationAcceptPage } from './pages/invitation-accept-page.js';
|
|
5
6
|
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {completeInvitationAcceptance} from './complete-acceptance.js';\nexport {useAcceptInvitation} from './hooks/api/accept-invitation.js';\nexport {\n previewInvitationQueryKey,\n usePreviewInvitation,\n} from './hooks/api/preview-invitation.js';\nexport {InvitationAcceptPage} from './pages/invitation-accept-page.js';\n"],"names":["completeInvitationAcceptance","useAcceptInvitation","previewInvitationQueryKey","usePreviewInvitation","InvitationAcceptPage"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {type InvitationPreview, pendingInvitation} from '#core/invitation-preview.js';\nexport {completeInvitationAcceptance} from './complete-acceptance.js';\nexport {useAcceptInvitation} from './hooks/api/accept-invitation.js';\nexport {\n previewInvitationQueryKey,\n previewInvitationQueryOptions,\n usePreviewInvitation,\n} from './hooks/api/preview-invitation.js';\nexport {InvitationAcceptPage} from './pages/invitation-accept-page.js';\n"],"names":["pendingInvitation","completeInvitationAcceptance","useAcceptInvitation","previewInvitationQueryKey","previewInvitationQueryOptions","usePreviewInvitation","InvitationAcceptPage"],"mappings":"AAAA,SAAgCA,iBAAiB,QAAO,8BAA8B;AACtF,SAAQC,4BAA4B,QAAO,2BAA2B;AACtE,SAAQC,mBAAmB,QAAO,mCAAmC;AACrE,SACEC,yBAAyB,EACzBC,6BAA6B,EAC7BC,oBAAoB,QACf,oCAAoC;AAC3C,SAAQC,oBAAoB,QAAO,oCAAoC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { AuthShell, useAuthState, useRefreshAuth } from '@shipfox/client-
|
|
2
|
+
import { AuthShell, useAuthState, useRefreshAuth } from '@shipfox/client-shell/runtime';
|
|
3
3
|
import { createSingleFlight } from '@shipfox/client-ui';
|
|
4
4
|
import { Button } from '@shipfox/react-ui/button';
|
|
5
5
|
import { Callout } from '@shipfox/react-ui/callout';
|
|
@@ -77,7 +77,7 @@ export function InvitationAcceptPage() {
|
|
|
77
77
|
hasKickedAccept.current = true;
|
|
78
78
|
invitationAccepts.run(token, async ()=>await runAccept({
|
|
79
79
|
token,
|
|
80
|
-
workspaceName: data.
|
|
80
|
+
workspaceName: data.workspaceName
|
|
81
81
|
})).catch(()=>{
|
|
82
82
|
// The mutation surfaces its error via accept.error; the UI re-renders
|
|
83
83
|
// into the auth-match-error state below.
|
|
@@ -166,7 +166,7 @@ export function InvitationAcceptPage() {
|
|
|
166
166
|
type: "error",
|
|
167
167
|
children: [
|
|
168
168
|
"This invitation expired on ",
|
|
169
|
-
formatDate(data.
|
|
169
|
+
formatDate(data.expiresAt),
|
|
170
170
|
". Ask your administrator to send a new one."
|
|
171
171
|
]
|
|
172
172
|
}),
|
|
@@ -180,7 +180,7 @@ export function InvitationAcceptPage() {
|
|
|
180
180
|
notifyOnce(`already-used:${token}`, ()=>toast.info(`This invitation has already been accepted.`));
|
|
181
181
|
return /*#__PURE__*/ _jsxs(AuthShell, {
|
|
182
182
|
title: "Invitation already used",
|
|
183
|
-
description: data.
|
|
183
|
+
description: data.workspaceName,
|
|
184
184
|
children: [
|
|
185
185
|
/*#__PURE__*/ _jsxs(Callout, {
|
|
186
186
|
role: "alert",
|
|
@@ -188,7 +188,7 @@ export function InvitationAcceptPage() {
|
|
|
188
188
|
children: [
|
|
189
189
|
"This invitation has already been accepted.",
|
|
190
190
|
' ',
|
|
191
|
-
auth.isAuthenticated ? `Open your dashboard to access ${data.
|
|
191
|
+
auth.isAuthenticated ? `Open your dashboard to access ${data.workspaceName} if your account is a member.` : `Log in to access ${data.workspaceName}.`
|
|
192
192
|
]
|
|
193
193
|
}),
|
|
194
194
|
auth.isAuthenticated ? null : /*#__PURE__*/ _jsx(Button, {
|
|
@@ -206,13 +206,13 @@ export function InvitationAcceptPage() {
|
|
|
206
206
|
]
|
|
207
207
|
});
|
|
208
208
|
}
|
|
209
|
-
const inviterLine = data.
|
|
209
|
+
const inviterLine = data.invitedByDisplay != null ? `Invited by ${data.invitedByDisplay} to join as ${data.email}.` : `Invited to join as ${data.email}.`;
|
|
210
210
|
if (!auth.isAuthenticated) {
|
|
211
211
|
const redirect = `/invitations/accept?token=${encodeURIComponent(token)}`;
|
|
212
212
|
const signupHref = `/auth/signup?redirect=${encodeURIComponent(redirect)}`;
|
|
213
213
|
const loginHref = `/auth/login?redirect=${encodeURIComponent(redirect)}`;
|
|
214
214
|
return /*#__PURE__*/ _jsxs(AuthShell, {
|
|
215
|
-
title: data.
|
|
215
|
+
title: data.workspaceName,
|
|
216
216
|
description: inviterLine,
|
|
217
217
|
children: [
|
|
218
218
|
/*#__PURE__*/ _jsxs("div", {
|
|
@@ -255,7 +255,7 @@ export function InvitationAcceptPage() {
|
|
|
255
255
|
const redirect = `/invitations/accept?token=${encodeURIComponent(token)}`;
|
|
256
256
|
const logoutHref = `/auth/logout?redirect=${encodeURIComponent(redirect)}`;
|
|
257
257
|
return /*#__PURE__*/ _jsxs(AuthShell, {
|
|
258
|
-
title: data.
|
|
258
|
+
title: data.workspaceName,
|
|
259
259
|
description: inviterLine,
|
|
260
260
|
children: [
|
|
261
261
|
/*#__PURE__*/ _jsxs(Callout, {
|
|
@@ -298,7 +298,7 @@ export function InvitationAcceptPage() {
|
|
|
298
298
|
// result. Show either the pending state or the error state.
|
|
299
299
|
if (accept.isError) {
|
|
300
300
|
return /*#__PURE__*/ _jsxs(AuthShell, {
|
|
301
|
-
title: data.
|
|
301
|
+
title: data.workspaceName,
|
|
302
302
|
description: inviterLine,
|
|
303
303
|
children: [
|
|
304
304
|
/*#__PURE__*/ _jsxs(Callout, {
|
|
@@ -306,7 +306,7 @@ export function InvitationAcceptPage() {
|
|
|
306
306
|
type: "error",
|
|
307
307
|
children: [
|
|
308
308
|
"We couldn't add you to ",
|
|
309
|
-
data.
|
|
309
|
+
data.workspaceName,
|
|
310
310
|
". Try again in a moment."
|
|
311
311
|
]
|
|
312
312
|
}),
|
|
@@ -316,7 +316,7 @@ export function InvitationAcceptPage() {
|
|
|
316
316
|
onClick: ()=>{
|
|
317
317
|
runAccept({
|
|
318
318
|
token,
|
|
319
|
-
workspaceName: data.
|
|
319
|
+
workspaceName: data.workspaceName
|
|
320
320
|
}).catch(()=>{
|
|
321
321
|
// The mutation state drives the rendered error; avoid an
|
|
322
322
|
// unhandled rejection from the click handler.
|
|
@@ -328,7 +328,7 @@ export function InvitationAcceptPage() {
|
|
|
328
328
|
});
|
|
329
329
|
}
|
|
330
330
|
return /*#__PURE__*/ _jsx(AuthShell, {
|
|
331
|
-
title: data.
|
|
331
|
+
title: data.workspaceName,
|
|
332
332
|
description: inviterLine,
|
|
333
333
|
children: /*#__PURE__*/ _jsxs("div", {
|
|
334
334
|
className: "flex flex-col items-center gap-12",
|
|
@@ -340,7 +340,7 @@ export function InvitationAcceptPage() {
|
|
|
340
340
|
className: "text-foreground-neutral-subtle",
|
|
341
341
|
children: [
|
|
342
342
|
"Adding you to ",
|
|
343
|
-
data.
|
|
343
|
+
data.workspaceName,
|
|
344
344
|
"…"
|
|
345
345
|
]
|
|
346
346
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/pages/invitation-accept-page.tsx"],"sourcesContent":["import {AuthShell, useAuthState, useRefreshAuth} from '@shipfox/client-auth';\nimport {createSingleFlight} from '@shipfox/client-ui';\nimport {Button} from '@shipfox/react-ui/button';\nimport {Callout} from '@shipfox/react-ui/callout';\nimport {ShipfoxLoader} from '@shipfox/react-ui/loader';\nimport {toast} from '@shipfox/react-ui/toast';\nimport {Text} from '@shipfox/react-ui/typography';\nimport {formatDate} from '@shipfox/react-ui/utils';\nimport {Link, useNavigate, useSearch} from '@tanstack/react-router';\nimport {useCallback, useEffect, useRef} from 'react';\nimport {completeInvitationAcceptance} from '#complete-acceptance.js';\nimport {useAcceptInvitation} from '#hooks/api/accept-invitation.js';\nimport {usePreviewInvitation} from '#hooks/api/preview-invitation.js';\n\nconst invitationAccepts = createSingleFlight<string, void>();\nconst toastedTerminals = new Set<string>();\nconst TOASTED_TERMINALS_MAX = 32;\n\nexport function InvitationAcceptPage() {\n const search = useSearch({strict: false}) as {token?: unknown};\n const token =\n typeof search.token === 'string' && search.token.length > 0 ? search.token : undefined;\n const navigate = useNavigate();\n const auth = useAuthState();\n const refreshAuth = useRefreshAuth();\n const preview = usePreviewInvitation(token);\n const accept = useAcceptInvitation();\n const hasKickedAccept = useRef(false);\n\n useEffect(() => {\n if (!token) {\n toast.error('This invitation link is missing a token.');\n const timeout = window.setTimeout(() => {\n navigate({to: '/', replace: true});\n }, 2000);\n return () => window.clearTimeout(timeout);\n }\n return undefined;\n }, [navigate, token]);\n\n const completeAccept = useCallback(\n async (workspaceId: string, workspaceName: string) => {\n await completeInvitationAcceptance({\n workspaceId,\n workspaceName,\n refreshAuth,\n navigate,\n });\n },\n [navigate, refreshAuth],\n );\n\n const runAccept = useCallback(\n async (params: {token: string; workspaceName: string}) => {\n const result = await accept.mutateAsync({token: params.token});\n await completeAccept(result.membership.workspace_id, params.workspaceName);\n },\n [accept, completeAccept],\n );\n\n // Auto-accept when authenticated and emails match (also handles already_used\n // for the canonical authenticated path: backend returns already_member=true).\n useEffect(() => {\n if (!token) return;\n if (auth.isLoading) return;\n if (hasKickedAccept.current) return;\n const data = preview.data;\n if (!data) return;\n if (data.status !== 'pending') return;\n if (!auth.isAuthenticated) return;\n\n const authedEmail = auth.user?.email?.toLowerCase();\n if (authedEmail !== data.email.toLowerCase()) return;\n\n hasKickedAccept.current = true;\n invitationAccepts\n .run(token, async () => await runAccept({token, workspaceName: data.workspace_name}))\n .catch(() => {\n // The mutation surfaces its error via accept.error; the UI re-renders\n // into the auth-match-error state below.\n });\n }, [auth.isAuthenticated, auth.isLoading, auth.user?.email, preview.data, runAccept, token]);\n\n if (!token) {\n return (\n <AuthShell title=\"Invalid link\" description=\"This invitation link is incomplete.\">\n <Callout role=\"alert\" type=\"error\">\n This invitation link is missing a token. Ask your administrator to resend it.\n </Callout>\n <Text size=\"sm\" className=\"text-center text-foreground-neutral-muted\" aria-live=\"polite\">\n Redirecting to the dashboard…\n </Text>\n </AuthShell>\n );\n }\n\n if (preview.isLoading) {\n return (\n <AuthShell title=\"Loading invitation\" description=\"One moment please.\">\n <CenteredLoader />\n </AuthShell>\n );\n }\n\n if (preview.isError) {\n return (\n <AuthShell title=\"Couldn't load invitation\" description=\"Try again in a moment.\">\n <Callout role=\"alert\" type=\"error\">\n We couldn't reach the server. Check your connection and retry.\n </Callout>\n <Button className=\"w-full\" onClick={() => preview.refetch()}>\n Try again\n </Button>\n </AuthShell>\n );\n }\n\n const data = preview.data;\n if (!data) {\n return null;\n }\n\n if (data.status === 'invalid') {\n notifyOnce(`invalid:${token}`, () => toast.error('This invitation link is no longer valid.'));\n return (\n <AuthShell title=\"Invalid invitation\" description=\"The link you used didn't work.\">\n <Callout role=\"alert\" type=\"error\">\n This invitation link is not valid. Ask your administrator to send a new one.\n </Callout>\n <GoHomeButton navigate={navigate} />\n </AuthShell>\n );\n }\n\n if (data.status === 'expired') {\n notifyOnce(`expired:${token}`, () => toast.error('This invitation has expired.'));\n return (\n <AuthShell title=\"Invitation expired\" description=\"The link is no longer accepting joins.\">\n <Callout role=\"alert\" type=\"error\">\n This invitation expired on {formatDate(data.expires_at)}. Ask your administrator to send a\n new one.\n </Callout>\n <GoHomeButton navigate={navigate} />\n </AuthShell>\n );\n }\n\n if (data.status === 'already_used') {\n notifyOnce(`already-used:${token}`, () =>\n toast.info(`This invitation has already been accepted.`),\n );\n return (\n <AuthShell title=\"Invitation already used\" description={data.workspace_name}>\n <Callout role=\"alert\" type=\"info\">\n This invitation has already been accepted.{' '}\n {auth.isAuthenticated\n ? `Open your dashboard to access ${data.workspace_name} if your account is a member.`\n : `Log in to access ${data.workspace_name}.`}\n </Callout>\n {auth.isAuthenticated ? null : (\n <Button asChild className=\"w-full\">\n <Link to=\"/auth/login\">Log in</Link>\n </Button>\n )}\n <GoHomeButton navigate={navigate} secondary />\n </AuthShell>\n );\n }\n\n const inviterLine =\n data.invited_by_display != null\n ? `Invited by ${data.invited_by_display} to join as ${data.email}.`\n : `Invited to join as ${data.email}.`;\n\n if (!auth.isAuthenticated) {\n const redirect = `/invitations/accept?token=${encodeURIComponent(token)}`;\n const signupHref = `/auth/signup?redirect=${encodeURIComponent(redirect)}`;\n const loginHref = `/auth/login?redirect=${encodeURIComponent(redirect)}`;\n return (\n <AuthShell title={data.workspace_name} description={inviterLine}>\n <div className=\"flex flex-col gap-16\">\n <Button asChild className=\"w-full\">\n <Link to={signupHref}>Create account</Link>\n </Button>\n <Button asChild className=\"w-full\" variant=\"secondary\">\n <Link to={loginHref}>I already have an account</Link>\n </Button>\n </div>\n <Text size=\"xs\" className=\"text-center text-foreground-neutral-muted\">\n Not {data.email}? Contact your administrator.\n </Text>\n </AuthShell>\n );\n }\n\n const viewerEmail = auth.user?.email?.toLowerCase();\n const inviteeEmail = data.email.toLowerCase();\n if (viewerEmail !== inviteeEmail) {\n const redirect = `/invitations/accept?token=${encodeURIComponent(token)}`;\n const logoutHref = `/auth/logout?redirect=${encodeURIComponent(redirect)}`;\n return (\n <AuthShell title={data.workspace_name} description={inviterLine}>\n <Callout role=\"alert\" type=\"warning\">\n You're signed in as {auth.user?.email}, but this invitation is for {data.email}.\n </Callout>\n <div className=\"flex flex-col gap-16\">\n <Button asChild className=\"w-full\">\n <Link to={logoutHref}>Log out and continue</Link>\n </Button>\n <Button\n className=\"w-full\"\n variant=\"secondary\"\n onClick={() => navigate({to: '/', replace: true})}\n >\n Cancel\n </Button>\n </div>\n </AuthShell>\n );\n }\n\n // Authenticated + matches — auto-accept is in flight or about to render its\n // result. Show either the pending state or the error state.\n if (accept.isError) {\n return (\n <AuthShell title={data.workspace_name} description={inviterLine}>\n <Callout role=\"alert\" type=\"error\">\n We couldn't add you to {data.workspace_name}. Try again in a moment.\n </Callout>\n <Button\n className=\"w-full\"\n isLoading={accept.isPending}\n onClick={() => {\n runAccept({token, workspaceName: data.workspace_name}).catch(() => {\n // The mutation state drives the rendered error; avoid an\n // unhandled rejection from the click handler.\n });\n }}\n >\n Try again\n </Button>\n </AuthShell>\n );\n }\n\n return (\n <AuthShell title={data.workspace_name} description={inviterLine}>\n <div className=\"flex flex-col items-center gap-12\" aria-live=\"polite\">\n <ShipfoxLoader />\n <Text size=\"sm\" className=\"text-foreground-neutral-subtle\">\n Adding you to {data.workspace_name}…\n </Text>\n </div>\n </AuthShell>\n );\n}\n\nfunction CenteredLoader() {\n return (\n <div className=\"flex justify-center py-16\" aria-busy=\"true\">\n <ShipfoxLoader />\n </div>\n );\n}\n\nfunction GoHomeButton({\n navigate,\n secondary,\n}: {\n navigate: ReturnType<typeof useNavigate>;\n secondary?: boolean;\n}) {\n return (\n <Button\n className=\"w-full\"\n variant={secondary ? 'secondary' : 'primary'}\n onClick={() => navigate({to: '/', replace: true})}\n >\n Go to dashboard\n </Button>\n );\n}\n\nfunction notifyOnce(key: string, fn: () => void): void {\n if (toastedTerminals.has(key)) return;\n if (toastedTerminals.size >= TOASTED_TERMINALS_MAX) {\n const oldest = toastedTerminals.values().next().value;\n if (oldest !== undefined) toastedTerminals.delete(oldest);\n }\n toastedTerminals.add(key);\n fn();\n}\n"],"names":["AuthShell","useAuthState","useRefreshAuth","createSingleFlight","Button","Callout","ShipfoxLoader","toast","Text","formatDate","Link","useNavigate","useSearch","useCallback","useEffect","useRef","completeInvitationAcceptance","useAcceptInvitation","usePreviewInvitation","invitationAccepts","toastedTerminals","Set","TOASTED_TERMINALS_MAX","InvitationAcceptPage","search","strict","token","length","undefined","navigate","auth","refreshAuth","preview","accept","hasKickedAccept","error","timeout","window","setTimeout","to","replace","clearTimeout","completeAccept","workspaceId","workspaceName","runAccept","params","result","mutateAsync","membership","workspace_id","isLoading","current","data","status","isAuthenticated","authedEmail","user","email","toLowerCase","run","workspace_name","catch","title","description","role","type","size","className","aria-live","CenteredLoader","isError","onClick","refetch","notifyOnce","GoHomeButton","expires_at","info","asChild","secondary","inviterLine","invited_by_display","redirect","encodeURIComponent","signupHref","loginHref","div","variant","viewerEmail","inviteeEmail","logoutHref","isPending","aria-busy","key","fn","has","oldest","values","next","value","delete","add"],"mappings":";AAAA,SAAQA,SAAS,EAAEC,YAAY,EAAEC,cAAc,QAAO,uBAAuB;AAC7E,SAAQC,kBAAkB,QAAO,qBAAqB;AACtD,SAAQC,MAAM,QAAO,2BAA2B;AAChD,SAAQC,OAAO,QAAO,4BAA4B;AAClD,SAAQC,aAAa,QAAO,2BAA2B;AACvD,SAAQC,KAAK,QAAO,0BAA0B;AAC9C,SAAQC,IAAI,QAAO,+BAA+B;AAClD,SAAQC,UAAU,QAAO,0BAA0B;AACnD,SAAQC,IAAI,EAAEC,WAAW,EAAEC,SAAS,QAAO,yBAAyB;AACpE,SAAQC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAO,QAAQ;AACrD,SAAQC,4BAA4B,QAAO,0BAA0B;AACrE,SAAQC,mBAAmB,QAAO,kCAAkC;AACpE,SAAQC,oBAAoB,QAAO,mCAAmC;AA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AWpE,WAAWR,iBAAiBgF,MAAM,CAACJ;IACpD;IACA5E,iBAAiBiF,GAAG,CAACR;IACrBC;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/pages/invitation-accept-page.tsx"],"sourcesContent":["import {AuthShell, useAuthState, useRefreshAuth} from '@shipfox/client-shell/runtime';\nimport {createSingleFlight} from '@shipfox/client-ui';\nimport {Button} from '@shipfox/react-ui/button';\nimport {Callout} from '@shipfox/react-ui/callout';\nimport {ShipfoxLoader} from '@shipfox/react-ui/loader';\nimport {toast} from '@shipfox/react-ui/toast';\nimport {Text} from '@shipfox/react-ui/typography';\nimport {formatDate} from '@shipfox/react-ui/utils';\nimport {Link, useNavigate, useSearch} from '@tanstack/react-router';\nimport {useCallback, useEffect, useRef} from 'react';\nimport {completeInvitationAcceptance} from '#complete-acceptance.js';\nimport {useAcceptInvitation} from '#hooks/api/accept-invitation.js';\nimport {usePreviewInvitation} from '#hooks/api/preview-invitation.js';\n\nconst invitationAccepts = createSingleFlight<string, void>();\nconst toastedTerminals = new Set<string>();\nconst TOASTED_TERMINALS_MAX = 32;\n\nexport function InvitationAcceptPage() {\n const search = useSearch({strict: false}) as {token?: unknown};\n const token =\n typeof search.token === 'string' && search.token.length > 0 ? search.token : undefined;\n const navigate = useNavigate();\n const auth = useAuthState();\n const refreshAuth = useRefreshAuth();\n const preview = usePreviewInvitation(token);\n const accept = useAcceptInvitation();\n const hasKickedAccept = useRef(false);\n\n useEffect(() => {\n if (!token) {\n toast.error('This invitation link is missing a token.');\n const timeout = window.setTimeout(() => {\n navigate({to: '/', replace: true});\n }, 2000);\n return () => window.clearTimeout(timeout);\n }\n return undefined;\n }, [navigate, token]);\n\n const completeAccept = useCallback(\n async (workspaceId: string, workspaceName: string) => {\n await completeInvitationAcceptance({\n workspaceId,\n workspaceName,\n refreshAuth,\n navigate,\n });\n },\n [navigate, refreshAuth],\n );\n\n const runAccept = useCallback(\n async (params: {token: string; workspaceName: string}) => {\n const result = await accept.mutateAsync({token: params.token});\n await completeAccept(result.membership.workspace_id, params.workspaceName);\n },\n [accept, completeAccept],\n );\n\n // Auto-accept when authenticated and emails match (also handles already_used\n // for the canonical authenticated path: backend returns already_member=true).\n useEffect(() => {\n if (!token) return;\n if (auth.isLoading) return;\n if (hasKickedAccept.current) return;\n const data = preview.data;\n if (!data) return;\n if (data.status !== 'pending') return;\n if (!auth.isAuthenticated) return;\n\n const authedEmail = auth.user?.email?.toLowerCase();\n if (authedEmail !== data.email.toLowerCase()) return;\n\n hasKickedAccept.current = true;\n invitationAccepts\n .run(token, async () => await runAccept({token, workspaceName: data.workspaceName}))\n .catch(() => {\n // The mutation surfaces its error via accept.error; the UI re-renders\n // into the auth-match-error state below.\n });\n }, [auth.isAuthenticated, auth.isLoading, auth.user?.email, preview.data, runAccept, token]);\n\n if (!token) {\n return (\n <AuthShell title=\"Invalid link\" description=\"This invitation link is incomplete.\">\n <Callout role=\"alert\" type=\"error\">\n This invitation link is missing a token. Ask your administrator to resend it.\n </Callout>\n <Text size=\"sm\" className=\"text-center text-foreground-neutral-muted\" aria-live=\"polite\">\n Redirecting to the dashboard…\n </Text>\n </AuthShell>\n );\n }\n\n if (preview.isLoading) {\n return (\n <AuthShell title=\"Loading invitation\" description=\"One moment please.\">\n <CenteredLoader />\n </AuthShell>\n );\n }\n\n if (preview.isError) {\n return (\n <AuthShell title=\"Couldn't load invitation\" description=\"Try again in a moment.\">\n <Callout role=\"alert\" type=\"error\">\n We couldn't reach the server. Check your connection and retry.\n </Callout>\n <Button className=\"w-full\" onClick={() => preview.refetch()}>\n Try again\n </Button>\n </AuthShell>\n );\n }\n\n const data = preview.data;\n if (!data) {\n return null;\n }\n\n if (data.status === 'invalid') {\n notifyOnce(`invalid:${token}`, () => toast.error('This invitation link is no longer valid.'));\n return (\n <AuthShell title=\"Invalid invitation\" description=\"The link you used didn't work.\">\n <Callout role=\"alert\" type=\"error\">\n This invitation link is not valid. Ask your administrator to send a new one.\n </Callout>\n <GoHomeButton navigate={navigate} />\n </AuthShell>\n );\n }\n\n if (data.status === 'expired') {\n notifyOnce(`expired:${token}`, () => toast.error('This invitation has expired.'));\n return (\n <AuthShell title=\"Invitation expired\" description=\"The link is no longer accepting joins.\">\n <Callout role=\"alert\" type=\"error\">\n This invitation expired on {formatDate(data.expiresAt)}. Ask your administrator to send a\n new one.\n </Callout>\n <GoHomeButton navigate={navigate} />\n </AuthShell>\n );\n }\n\n if (data.status === 'already_used') {\n notifyOnce(`already-used:${token}`, () =>\n toast.info(`This invitation has already been accepted.`),\n );\n return (\n <AuthShell title=\"Invitation already used\" description={data.workspaceName}>\n <Callout role=\"alert\" type=\"info\">\n This invitation has already been accepted.{' '}\n {auth.isAuthenticated\n ? `Open your dashboard to access ${data.workspaceName} if your account is a member.`\n : `Log in to access ${data.workspaceName}.`}\n </Callout>\n {auth.isAuthenticated ? null : (\n <Button asChild className=\"w-full\">\n <Link to=\"/auth/login\">Log in</Link>\n </Button>\n )}\n <GoHomeButton navigate={navigate} secondary />\n </AuthShell>\n );\n }\n\n const inviterLine =\n data.invitedByDisplay != null\n ? `Invited by ${data.invitedByDisplay} to join as ${data.email}.`\n : `Invited to join as ${data.email}.`;\n\n if (!auth.isAuthenticated) {\n const redirect = `/invitations/accept?token=${encodeURIComponent(token)}`;\n const signupHref = `/auth/signup?redirect=${encodeURIComponent(redirect)}`;\n const loginHref = `/auth/login?redirect=${encodeURIComponent(redirect)}`;\n return (\n <AuthShell title={data.workspaceName} description={inviterLine}>\n <div className=\"flex flex-col gap-16\">\n <Button asChild className=\"w-full\">\n <Link to={signupHref}>Create account</Link>\n </Button>\n <Button asChild className=\"w-full\" variant=\"secondary\">\n <Link to={loginHref}>I already have an account</Link>\n </Button>\n </div>\n <Text size=\"xs\" className=\"text-center text-foreground-neutral-muted\">\n Not {data.email}? Contact your administrator.\n </Text>\n </AuthShell>\n );\n }\n\n const viewerEmail = auth.user?.email?.toLowerCase();\n const inviteeEmail = data.email.toLowerCase();\n if (viewerEmail !== inviteeEmail) {\n const redirect = `/invitations/accept?token=${encodeURIComponent(token)}`;\n const logoutHref = `/auth/logout?redirect=${encodeURIComponent(redirect)}`;\n return (\n <AuthShell title={data.workspaceName} description={inviterLine}>\n <Callout role=\"alert\" type=\"warning\">\n You're signed in as {auth.user?.email}, but this invitation is for {data.email}.\n </Callout>\n <div className=\"flex flex-col gap-16\">\n <Button asChild className=\"w-full\">\n <Link to={logoutHref}>Log out and continue</Link>\n </Button>\n <Button\n className=\"w-full\"\n variant=\"secondary\"\n onClick={() => navigate({to: '/', replace: true})}\n >\n Cancel\n </Button>\n </div>\n </AuthShell>\n );\n }\n\n // Authenticated + matches — auto-accept is in flight or about to render its\n // result. Show either the pending state or the error state.\n if (accept.isError) {\n return (\n <AuthShell title={data.workspaceName} description={inviterLine}>\n <Callout role=\"alert\" type=\"error\">\n We couldn't add you to {data.workspaceName}. Try again in a moment.\n </Callout>\n <Button\n className=\"w-full\"\n isLoading={accept.isPending}\n onClick={() => {\n runAccept({token, workspaceName: data.workspaceName}).catch(() => {\n // The mutation state drives the rendered error; avoid an\n // unhandled rejection from the click handler.\n });\n }}\n >\n Try again\n </Button>\n </AuthShell>\n );\n }\n\n return (\n <AuthShell title={data.workspaceName} description={inviterLine}>\n <div className=\"flex flex-col items-center gap-12\" aria-live=\"polite\">\n <ShipfoxLoader />\n <Text size=\"sm\" className=\"text-foreground-neutral-subtle\">\n Adding you to {data.workspaceName}…\n </Text>\n </div>\n </AuthShell>\n );\n}\n\nfunction CenteredLoader() {\n return (\n <div className=\"flex justify-center py-16\" aria-busy=\"true\">\n <ShipfoxLoader />\n </div>\n );\n}\n\nfunction GoHomeButton({\n navigate,\n secondary,\n}: {\n navigate: ReturnType<typeof useNavigate>;\n secondary?: boolean;\n}) {\n return (\n <Button\n className=\"w-full\"\n variant={secondary ? 'secondary' : 'primary'}\n onClick={() => navigate({to: '/', replace: true})}\n >\n Go to dashboard\n </Button>\n );\n}\n\nfunction notifyOnce(key: string, fn: () => void): void {\n if (toastedTerminals.has(key)) return;\n if (toastedTerminals.size >= TOASTED_TERMINALS_MAX) {\n const oldest = toastedTerminals.values().next().value;\n if (oldest !== undefined) toastedTerminals.delete(oldest);\n }\n toastedTerminals.add(key);\n fn();\n}\n"],"names":["AuthShell","useAuthState","useRefreshAuth","createSingleFlight","Button","Callout","ShipfoxLoader","toast","Text","formatDate","Link","useNavigate","useSearch","useCallback","useEffect","useRef","completeInvitationAcceptance","useAcceptInvitation","usePreviewInvitation","invitationAccepts","toastedTerminals","Set","TOASTED_TERMINALS_MAX","InvitationAcceptPage","search","strict","token","length","undefined","navigate","auth","refreshAuth","preview","accept","hasKickedAccept","error","timeout","window","setTimeout","to","replace","clearTimeout","completeAccept","workspaceId","workspaceName","runAccept","params","result","mutateAsync","membership","workspace_id","isLoading","current","data","status","isAuthenticated","authedEmail","user","email","toLowerCase","run","catch","title","description","role","type","size","className","aria-live","CenteredLoader","isError","onClick","refetch","notifyOnce","GoHomeButton","expiresAt","info","asChild","secondary","inviterLine","invitedByDisplay","redirect","encodeURIComponent","signupHref","loginHref","div","variant","viewerEmail","inviteeEmail","logoutHref","isPending","aria-busy","key","fn","has","oldest","values","next","value","delete","add"],"mappings":";AAAA,SAAQA,SAAS,EAAEC,YAAY,EAAEC,cAAc,QAAO,gCAAgC;AACtF,SAAQC,kBAAkB,QAAO,qBAAqB;AACtD,SAAQC,MAAM,QAAO,2BAA2B;AAChD,SAAQC,OAAO,QAAO,4BAA4B;AAClD,SAAQC,aAAa,QAAO,2BAA2B;AACvD,SAAQC,KAAK,QAAO,0BAA0B;AAC9C,SAAQC,IAAI,QAAO,+BAA+B;AAClD,SAAQC,UAAU,QAAO,0BAA0B;AACnD,SAAQC,IAAI,EAAEC,WAAW,EAAEC,SAAS,QAAO,yBAAyB;AACpE,SAAQC,WAAW,EAAEC,SAAS,EAAEC,MAAM,QAAO,QAAQ;AACrD,SAAQC,4BAA4B,QAAO,0BAA0B;AACrE,SAAQC,mBAAmB,QAAO,kCAAkC;A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