@slyxup/ui 0.2.7 → 0.2.9
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/README.md +4 -1
- package/dist/components/SignIn/SignIn.d.ts.map +1 -1
- package/dist/components/SignIn/SignIn.js +2 -1
- package/dist/components/SignIn/SignIn.js.map +1 -1
- package/dist/components/SignUp/SignUp.d.ts.map +1 -1
- package/dist/components/SignUp/SignUp.js +2 -1
- package/dist/components/SignUp/SignUp.js.map +1 -1
- package/dist/components/SocialButtons/SocialButtons.d.ts.map +1 -1
- package/dist/components/SocialButtons/SocialButtons.js +2 -1
- package/dist/components/SocialButtons/SocialButtons.js.map +1 -1
- package/dist/components/UserButton/UserButton.d.ts +5 -1
- package/dist/components/UserButton/UserButton.d.ts.map +1 -1
- package/dist/components/UserButton/UserButton.js +6 -2
- package/dist/components/UserButton/UserButton.js.map +1 -1
- package/dist/components/UserProfile/UserProfile.d.ts.map +1 -1
- package/dist/components/UserProfile/UserProfile.js +248 -27
- package/dist/components/UserProfile/UserProfile.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/styles.d.ts +1 -1
- package/dist/styles.d.ts.map +1 -1
- package/dist/styles.js +269 -0
- package/dist/styles.js.map +1 -1
- package/package.json +9 -9
- package/src/components/SignIn/SignIn.tsx +2 -1
- package/src/components/SignUp/SignUp.tsx +2 -1
- package/src/components/SocialButtons/SocialButtons.tsx +2 -1
- package/src/components/UserButton/UserButton.tsx +12 -2
- package/src/components/UserProfile/UserProfile.tsx +556 -61
- package/src/index.ts +12 -1
- package/src/styles.ts +269 -0
- package/.turbo/turbo-build.log +0 -4
- package/LICENSE +0 -21
package/README.md
CHANGED
|
@@ -99,7 +99,10 @@ Requires the endpoints shipped in the auth worker (`POST /v1/user/password`, `GE
|
|
|
99
99
|
### `<SocialButtons />`
|
|
100
100
|
|
|
101
101
|
```tsx
|
|
102
|
-
<SocialButtons providers={['google', 'github']}
|
|
102
|
+
<SocialButtons providers={['google', 'github']} />
|
|
103
|
+
{/* Default basePath is `${client.apiUrl}/v1/oauth` from the provider client.
|
|
104
|
+
Only override if you need a custom auth URL: */}
|
|
105
|
+
<SocialButtons providers={['google']} basePath="https://auth.example.com/v1/oauth" />
|
|
103
106
|
```
|
|
104
107
|
|
|
105
108
|
Redirects to the hosted OAuth flow.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../../src/components/SignIn/SignIn.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,wBAAwB;IACxB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,4DAA4D;IAC5D,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AAED,2CAA2C;AAC3C,wBAAgB,MAAM,CAAC,EACrB,MAAa,EACb,SAAS,EACT,aAAa,EACb,qBAAqB,GACtB,EAAE,WAAW,+
|
|
1
|
+
{"version":3,"file":"SignIn.d.ts","sourceRoot":"","sources":["../../../src/components/SignIn/SignIn.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,wBAAwB;IACxB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,4DAA4D;IAC5D,qBAAqB,CAAC,EAAE,MAAM,IAAI,CAAC;CACpC;AAED,2CAA2C;AAC3C,wBAAgB,MAAM,CAAC,EACrB,MAAa,EACb,SAAS,EACT,aAAa,EACb,qBAAqB,GACtB,EAAE,WAAW,+BAsJb"}
|
|
@@ -37,7 +37,8 @@ export function SignIn({ social = true, onSuccess, onSignUpClick, onForgotPasswo
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
function oauth(provider) {
|
|
40
|
-
window.location.href
|
|
40
|
+
const redirect = encodeURIComponent(window.location.href);
|
|
41
|
+
window.location.href = `${client.apiUrl}/v1/oauth/${provider}?redirect_url=${redirect}`;
|
|
41
42
|
}
|
|
42
43
|
const missingKey = !client.publishableKey ||
|
|
43
44
|
client.publishableKey === 'pk_test_missing' ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignIn.js","sourceRoot":"","sources":["../../../src/components/SignIn/SignIn.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAa5C,2CAA2C;AAC3C,MAAM,UAAU,MAAM,CAAC,EACrB,MAAM,GAAG,IAAI,EACb,SAAS,EACT,aAAa,EACb,qBAAqB,GACT;IACZ,YAAY,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAGjC,CAAC;IACF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAA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5C,QAAQ,SACR,IACE,EACN,kBAAQ,SAAS,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,IAAI,aACrD,IAAI,IAAI,eAAM,SAAS,EAAC,aAAa,iBAAa,MAAM,GAAG,EAC3D,IAAI,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,IAC1B,IACJ,EAEN,aAAa,IAAI,CAChB,aAAG,SAAS,EAAC,YAAY,uCACK,GAAG,EAC/B,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,UAAU,EAAC,OAAO,EAAE,aAAa,wBAExD,IACP,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignUp.d.ts","sourceRoot":"","sources":["../../../src/components/SignUp/SignUp.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,2CAA2C;AAC3C,wBAAgB,MAAM,CAAC,EACrB,MAAa,EACb,SAAS,EACT,aAAa,GACd,EAAE,WAAW,+
|
|
1
|
+
{"version":3,"file":"SignUp.d.ts","sourceRoot":"","sources":["../../../src/components/SignUp/SignUp.tsx"],"names":[],"mappings":"AAMA,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,2CAA2C;AAC3C,wBAAgB,MAAM,CAAC,EACrB,MAAa,EACb,SAAS,EACT,aAAa,GACd,EAAE,WAAW,+BA4Jb"}
|
|
@@ -38,7 +38,8 @@ export function SignUp({ social = true, onSuccess, onSignInClick, }) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
function oauth(provider) {
|
|
41
|
-
window.location.href
|
|
41
|
+
const redirect = encodeURIComponent(window.location.href);
|
|
42
|
+
window.location.href = `${client.apiUrl}/v1/oauth/${provider}?redirect_url=${redirect}`;
|
|
42
43
|
}
|
|
43
44
|
const missingKey = !client.publishableKey ||
|
|
44
45
|
client.publishableKey === 'pk_test_missing' ||
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SignUp.js","sourceRoot":"","sources":["../../../src/components/SignUp/SignUp.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAkB,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAQ5C,2CAA2C;AAC3C,MAAM,UAAU,MAAM,CAAC,EACrB,MAAM,GAAG,IAAI,EACb,SAAS,EACT,aAAa,GACD;IACZ,YAAY,EAAE,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAGjC,CAAC;IACF,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC/C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC7C,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAgB,IAAI,CAAC,CAAC;IACxD,MAAM,OAA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OAAO,EAAC,qBAAqB,yBAElD,EACR,gBACE,EAAE,EAAC,qBAAqB,EACxB,SAAS,EAAC,WAAW,EACrB,IAAI,EAAC,UAAU,EACf,YAAY,EAAC,cAAc,EAC3B,WAAW,EAAC,uBAAuB,EACnC,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAC5C,QAAQ,QACR,SAAS,EAAE,CAAC,GACZ,EACF,YAAG,SAAS,EAAC,UAAU,qEAEnB,IACA,EACN,kBAAQ,SAAS,EAAC,SAAS,EAAC,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,IAAI,aACrD,IAAI,IAAI,eAAM,SAAS,EAAC,aAAa,iBAAa,MAAM,GAAG,EAC3D,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,gBAAgB,IACvC,IACJ,EAEN,aAAa,IAAI,CAChB,aAAG,SAAS,EAAC,YAAY,yCACE,GAAG,EAC5B,iBAAQ,IAAI,EAAC,QAAQ,EAAC,SAAS,EAAC,UAAU,EAAC,OAAO,EAAE,aAAa,wBAExD,IACP,CACL,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SocialButtons.d.ts","sourceRoot":"","sources":["../../../src/components/SocialButtons/SocialButtons.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;IACvC,mFAAmF;IACnF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAOD,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,EAC5B,SAAgC,EAChC,QAAQ,GACT,EAAE,kBAAkB,+
|
|
1
|
+
{"version":3,"file":"SocialButtons.d.ts","sourceRoot":"","sources":["../../../src/components/SocialButtons/SocialButtons.tsx"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,+CAA+C;IAC/C,SAAS,CAAC,EAAE,KAAK,CAAC,QAAQ,GAAG,QAAQ,CAAC,CAAC;IACvC,mFAAmF;IACnF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAOD,4DAA4D;AAC5D,wBAAgB,aAAa,CAAC,EAC5B,SAAgC,EAChC,QAAQ,GACT,EAAE,kBAAkB,+BA0BpB"}
|
|
@@ -14,7 +14,8 @@ export function SocialButtons({ providers = ['google', 'github'], basePath, }) {
|
|
|
14
14
|
return (_jsx("div", { className: "slx-social", children: providers.map((p) => {
|
|
15
15
|
const { label, Icon } = META[p];
|
|
16
16
|
return (_jsxs("button", { type: "button", className: "slx-social-btn", onClick: () => {
|
|
17
|
-
window.location.href
|
|
17
|
+
const redirect = encodeURIComponent(window.location.href);
|
|
18
|
+
window.location.href = `${base}/${p}?redirect_url=${redirect}`;
|
|
18
19
|
}, children: [_jsx(Icon, {}), " ", label] }, p));
|
|
19
20
|
}) }));
|
|
20
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SocialButtons.js","sourceRoot":"","sources":["../../../src/components/SocialButtons/SocialButtons.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAS5C,MAAM,IAAI,GAAG;IACX,MAAM,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,IAAI,EAAE,UAAU,EAAE;IAC3D,MAAM,EAAE,EAAE,KAAK,EAAE,sBAAsB,EAAE,IAAI,EAAE,UAAU,EAAE;CACnD,CAAC;AAEX,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,EAC5B,SAAS,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAChC,QA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WAAW,CAAC;IAC5D,OAAO,CACL,cAAK,SAAS,EAAC,YAAY,YACxB,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;YACnB,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YAChC,OAAO,CACL,kBAEE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,gBAAgB,EAC1B,OAAO,EAAE,GAAG,EAAE;oBACZ,MAAM,QAAQ,GAAG,kBAAkB,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;oBAC1D,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC,iBAAiB,QAAQ,EAAE,CAAC;gBACjE,CAAC,aAED,KAAC,IAAI,KAAG,OAAE,KAAK,KARV,CAAC,CASC,CACV,CAAC;QACJ,CAAC,CAAC,GACE,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
export interface UserButtonProps {
|
|
2
|
+
/** Called when "Profile settings" is clicked. Use to open <UserProfile />. */
|
|
3
|
+
onProfileClick?: () => void;
|
|
4
|
+
}
|
|
1
5
|
/** Avatar + dropdown with profile actions and sign out. */
|
|
2
|
-
export declare function UserButton(): import("react").JSX.Element;
|
|
6
|
+
export declare function UserButton({ onProfileClick }: UserButtonProps): import("react").JSX.Element;
|
|
3
7
|
//# sourceMappingURL=UserButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserButton.d.ts","sourceRoot":"","sources":["../../../src/components/UserButton/UserButton.tsx"],"names":[],"mappings":"AASA,2DAA2D;AAC3D,wBAAgB,UAAU,
|
|
1
|
+
{"version":3,"file":"UserButton.d.ts","sourceRoot":"","sources":["../../../src/components/UserButton/UserButton.tsx"],"names":[],"mappings":"AASA,MAAM,WAAW,eAAe;IAC9B,8EAA8E;IAC9E,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED,2DAA2D;AAC3D,wBAAgB,UAAU,CAAC,EAAE,cAAc,EAAE,EAAE,eAAe,+BAqF7D"}
|
|
@@ -8,7 +8,7 @@ function initials(name, email) {
|
|
|
8
8
|
return email.slice(0, 1).toUpperCase();
|
|
9
9
|
}
|
|
10
10
|
/** Avatar + dropdown with profile actions and sign out. */
|
|
11
|
-
export function UserButton() {
|
|
11
|
+
export function UserButton({ onProfileClick }) {
|
|
12
12
|
injectStyles();
|
|
13
13
|
const { isLoaded, user } = useUser();
|
|
14
14
|
const { signOut } = useAuth();
|
|
@@ -34,12 +34,16 @@ export function UserButton() {
|
|
|
34
34
|
return _jsx("div", { className: "slx-userbtn-avatar", "aria-hidden": "true" });
|
|
35
35
|
const email = user?.email ?? '';
|
|
36
36
|
const name = user?.firstName;
|
|
37
|
+
function handleProfileClick() {
|
|
38
|
+
setOpen(false);
|
|
39
|
+
onProfileClick?.();
|
|
40
|
+
}
|
|
37
41
|
async function onSignOut() {
|
|
38
42
|
await signOut();
|
|
39
43
|
setOpen(false);
|
|
40
44
|
}
|
|
41
45
|
return (_jsxs("div", { className: "slx-userbtn-wrap", ref: wrapRef, children: [_jsx("button", { type: "button", className: "slx-userbtn-avatar", onClick: () => setOpen((o) => !o), "aria-haspopup": "menu", "aria-expanded": open, "aria-label": "Account menu", children: user?.avatarUrl ? (_jsx("img", { src: user.avatarUrl, alt: "" })) : (initials(name, email || '?')) }), open && (_jsxs("div", { className: "slx-menu", role: "menu", children: [_jsxs("div", { className: "slx-menu-header", children: [_jsx("p", { className: "slx-menu-name", children: name
|
|
42
46
|
? `${name}${user?.lastName ? ` ${user.lastName}` : ''}`
|
|
43
|
-
: email.split('@')[0] }), _jsx("p", { className: "slx-menu-email", children: email })] }), _jsx("button", { type: "button", className: "slx-menu-item", role: "menuitem", onClick:
|
|
47
|
+
: email.split('@')[0] }), _jsx("p", { className: "slx-menu-email", children: email })] }), _jsx("button", { type: "button", className: "slx-menu-item", role: "menuitem", onClick: handleProfileClick, children: "Profile settings" }), _jsx("button", { type: "button", className: "slx-menu-item slx-menu-item-danger", role: "menuitem", onClick: onSignOut, children: "Sign out" })] }))] }));
|
|
44
48
|
}
|
|
45
49
|
//# sourceMappingURL=UserButton.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserButton.js","sourceRoot":"","sources":["../../../src/components/UserButton/UserButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,SAAS,QAAQ,CAAC,IAA+B,EAAE,KAAa;IAC9D,IAAI,IAAI,EAAE,IAAI,EAAE;QAAE,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/D,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;AACzC,CAAC;
|
|
1
|
+
{"version":3,"file":"UserButton.js","sourceRoot":"","sources":["../../../src/components/UserButton/UserButton.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,SAAS,QAAQ,CAAC,IAA+B,EAAE,KAAa;IAC9D,IAAI,IAAI,EAAE,IAAI,EAAE;QAAE,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IAC/D,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE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AAI,EAAC,QAAQ,EACb,SAAS,EAAC,oCAAoC,EAC9C,IAAI,EAAC,UAAU,EACf,OAAO,EAAE,SAAS,yBAGX,IACL,CACP,IACG,CACP,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserProfile.d.ts","sourceRoot":"","sources":["../../../src/components/UserProfile/UserProfile.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;
|
|
1
|
+
{"version":3,"file":"UserProfile.d.ts","sourceRoot":"","sources":["../../../src/components/UserProfile/UserProfile.tsx"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,gFAAgF;IAChF,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAqFD,wBAAgB,WAAW,CAAC,EAC1B,KAAY,EACZ,OAAO,EACP,SAAS,GACV,EAAE,gBAAgB,sCAi5BlB"}
|
|
@@ -3,12 +3,21 @@ import { useAuth, useUser } from '@slyxup/react';
|
|
|
3
3
|
import { useCallback, useEffect, useState } from 'react';
|
|
4
4
|
import { injectStyles } from '../../styles';
|
|
5
5
|
function initials(user) {
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const f = user.firstName?.trim();
|
|
7
|
+
const l = user.lastName?.trim();
|
|
8
|
+
if (f && l)
|
|
9
|
+
return (f[0] + l[0]).toUpperCase();
|
|
10
|
+
if (f)
|
|
11
|
+
return f.slice(0, 1).toUpperCase();
|
|
12
|
+
if (l)
|
|
13
|
+
return l.slice(0, 1).toUpperCase();
|
|
9
14
|
return user.email.slice(0, 1).toUpperCase();
|
|
10
15
|
}
|
|
11
|
-
|
|
16
|
+
function displayName(user) {
|
|
17
|
+
const parts = [user.firstName?.trim(), user.lastName?.trim()].filter(Boolean);
|
|
18
|
+
const name = parts.join(' ');
|
|
19
|
+
return name || user.email;
|
|
20
|
+
}
|
|
12
21
|
function deviceLabel(ua) {
|
|
13
22
|
if (!ua)
|
|
14
23
|
return 'Unknown device';
|
|
@@ -44,6 +53,17 @@ function formatDate(iso) {
|
|
|
44
53
|
year: 'numeric',
|
|
45
54
|
});
|
|
46
55
|
}
|
|
56
|
+
function formatCurrency(amount, currency) {
|
|
57
|
+
try {
|
|
58
|
+
return new Intl.NumberFormat(undefined, {
|
|
59
|
+
style: 'currency',
|
|
60
|
+
currency: currency.toUpperCase(),
|
|
61
|
+
}).format(amount / 100);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
return `${(amount / 100).toFixed(2)} ${currency.toUpperCase()}`;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
47
67
|
export function UserProfile({ modal = true, onClose, onDeleted, }) {
|
|
48
68
|
injectStyles();
|
|
49
69
|
const { isLoaded, user, reload } = useUser();
|
|
@@ -69,17 +89,26 @@ export function UserProfile({ modal = true, onClose, onDeleted, }) {
|
|
|
69
89
|
const [sessionsLoading, setSessionsLoading] = useState(true);
|
|
70
90
|
const [revokingId, setRevokingId] = useState(null);
|
|
71
91
|
const [othersRevoking, setOthersRevoking] = useState(false);
|
|
92
|
+
// ── Billing state ──
|
|
93
|
+
const [billingLoading, setBillingLoading] = useState(true);
|
|
94
|
+
const [subscription, setSubscription] = useState(null);
|
|
95
|
+
const [invoices, setInvoices] = useState([]);
|
|
96
|
+
const [plans, setPlans] = useState([]);
|
|
97
|
+
const [plansLoading, setPlansLoading] = useState(false);
|
|
98
|
+
const [checkoutId, setCheckoutId] = useState(null);
|
|
72
99
|
// ── Danger zone state ──
|
|
73
100
|
const [confirmText, setConfirmText] = useState('');
|
|
74
101
|
const [deleteBusy, setDeleteBusy] = useState(false);
|
|
75
102
|
const [deleteError, setDeleteError] = useState(null);
|
|
103
|
+
// Sync form fields when user loads/updates (ensures firstName/lastName show correctly
|
|
104
|
+
// after SlyxUpProvider fetches client.users.me()). Guard against stale overwrites.
|
|
76
105
|
useEffect(() => {
|
|
77
106
|
if (user) {
|
|
78
107
|
setFirstName(user.firstName ?? '');
|
|
79
108
|
setLastName(user.lastName ?? '');
|
|
80
109
|
setAvatarUrl(user.avatarUrl ?? '');
|
|
81
110
|
}
|
|
82
|
-
}, [user]);
|
|
111
|
+
}, [user?.firstName, user?.lastName, user?.avatarUrl]);
|
|
83
112
|
useEffect(() => {
|
|
84
113
|
function onKey(e) {
|
|
85
114
|
if (e.key === 'Escape' && modal)
|
|
@@ -101,10 +130,131 @@ export function UserProfile({ modal = true, onClose, onDeleted, }) {
|
|
|
101
130
|
setSessionsLoading(false);
|
|
102
131
|
}
|
|
103
132
|
}, [client]);
|
|
133
|
+
const loadBilling = useCallback(async () => {
|
|
134
|
+
setBillingLoading(true);
|
|
135
|
+
setPlansLoading(true);
|
|
136
|
+
try {
|
|
137
|
+
const rawApiUrl = client.apiUrl ?? 'https://auth.slyxup.online';
|
|
138
|
+
const billingUrl = rawApiUrl.replace('auth.slyxup.online', 'billing.slyxup.online');
|
|
139
|
+
const token = client?._token
|
|
140
|
+
?? client?.getToken?.();
|
|
141
|
+
const headers = {
|
|
142
|
+
'Content-Type': 'application/json',
|
|
143
|
+
};
|
|
144
|
+
if (token)
|
|
145
|
+
headers.Authorization = `Bearer ${token}`;
|
|
146
|
+
// Also forward publishable key if available (helps billing resolve project)
|
|
147
|
+
const pubKey = client?.publishableKey;
|
|
148
|
+
if (pubKey && pubKey !== 'pk_test_missing')
|
|
149
|
+
headers['X-Publishable-Key'] = pubKey;
|
|
150
|
+
// Derive projectId for plans: prefer user.projectId, then try subscription's projectId, fallback none
|
|
151
|
+
const projectId = user?.projectId ?? null;
|
|
152
|
+
// Fetch subscription + invoices (new /v1/billing/* with fallback to legacy /v1/*)
|
|
153
|
+
async function fetchJson(url) {
|
|
154
|
+
const res = await fetch(url, { headers, credentials: 'include' });
|
|
155
|
+
if (!res.ok)
|
|
156
|
+
throw new Error(String(res.status));
|
|
157
|
+
return res.json();
|
|
158
|
+
}
|
|
159
|
+
// Subscription
|
|
160
|
+
let subData = null;
|
|
161
|
+
for (const path of [
|
|
162
|
+
`${billingUrl}/v1/billing/subscription${projectId ? `?projectId=${projectId}` : ''}`,
|
|
163
|
+
`${billingUrl}/v1/subscription`,
|
|
164
|
+
]) {
|
|
165
|
+
try {
|
|
166
|
+
const j = await fetchJson(path);
|
|
167
|
+
if (j && j.ok !== false) {
|
|
168
|
+
subData = j;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
catch {
|
|
173
|
+
// try next path
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (subData) {
|
|
177
|
+
const sd = subData;
|
|
178
|
+
let sub = null;
|
|
179
|
+
if (sd.subscription !== undefined)
|
|
180
|
+
sub = sd.subscription;
|
|
181
|
+
else if (Array.isArray(sd.subscriptions) && sd.subscriptions.length > 0)
|
|
182
|
+
sub = sd.subscriptions[0];
|
|
183
|
+
if (sub) {
|
|
184
|
+
setSubscription({
|
|
185
|
+
id: String(sub.id ?? ''),
|
|
186
|
+
status: String(sub.status ?? 'active'),
|
|
187
|
+
planId: sub.planId ?? sub.plan_id ?? null,
|
|
188
|
+
planName: sub.planName ?? sub.plan_name ?? sub.name ?? null,
|
|
189
|
+
currentPeriodEnd: sub.currentPeriodEnd ?? sub.current_period_end ?? sub.currentPeriod_end ?? null,
|
|
190
|
+
cancelAtPeriodEnd: Boolean(sub.cancelAtPeriodEnd ?? sub.cancel_at_period_end ?? false),
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
setSubscription(null);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
else {
|
|
198
|
+
setSubscription(null);
|
|
199
|
+
}
|
|
200
|
+
// Invoices
|
|
201
|
+
for (const path of [`${billingUrl}/v1/billing/invoices`, `${billingUrl}/v1/invoices`]) {
|
|
202
|
+
try {
|
|
203
|
+
const invJ = (await fetchJson(path));
|
|
204
|
+
if (invJ?.ok !== false && Array.isArray(invJ.invoices)) {
|
|
205
|
+
setInvoices(invJ.invoices.map((inv) => ({
|
|
206
|
+
id: String(inv.id),
|
|
207
|
+
amount: Number(inv.amount ?? 0),
|
|
208
|
+
currency: String(inv.currency ?? 'USD'),
|
|
209
|
+
status: String(inv.status ?? 'pending'),
|
|
210
|
+
billedAt: inv.billedAt ?? inv.billed_at ?? null,
|
|
211
|
+
})));
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
catch {
|
|
216
|
+
// try next
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
// Plans (needs projectId — if missing, try without and degrade gracefully)
|
|
220
|
+
const planPaths = [];
|
|
221
|
+
if (projectId)
|
|
222
|
+
planPaths.push(`${billingUrl}/v1/billing/plans?projectId=${projectId}`);
|
|
223
|
+
// Also try without projectId as last resort (will 400 but we catch)
|
|
224
|
+
planPaths.push(`${billingUrl}/v1/billing/plans?projectId=${projectId ?? ''}`);
|
|
225
|
+
planPaths.push(`${billingUrl}/v1/plans`);
|
|
226
|
+
let gotPlans = false;
|
|
227
|
+
for (const p of planPaths) {
|
|
228
|
+
try {
|
|
229
|
+
const pj = (await fetchJson(p));
|
|
230
|
+
if (pj?.ok !== false && Array.isArray(pj.plans)) {
|
|
231
|
+
setPlans(pj.plans);
|
|
232
|
+
gotPlans = true;
|
|
233
|
+
break;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch {
|
|
237
|
+
// continue
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
if (!gotPlans)
|
|
241
|
+
setPlans([]);
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
// Billing unavailable — show empty state, keep plans empty
|
|
245
|
+
setPlans([]);
|
|
246
|
+
}
|
|
247
|
+
finally {
|
|
248
|
+
setBillingLoading(false);
|
|
249
|
+
setPlansLoading(false);
|
|
250
|
+
}
|
|
251
|
+
}, [client, user]);
|
|
104
252
|
useEffect(() => {
|
|
105
253
|
if (tab === 'security')
|
|
106
254
|
void loadSessions();
|
|
107
|
-
|
|
255
|
+
if (tab === 'billing')
|
|
256
|
+
void loadBilling();
|
|
257
|
+
}, [tab, loadSessions, loadBilling]);
|
|
108
258
|
async function onProfileSubmit(e) {
|
|
109
259
|
e.preventDefault();
|
|
110
260
|
setBusy(true);
|
|
@@ -195,35 +345,103 @@ export function UserProfile({ modal = true, onClose, onDeleted, }) {
|
|
|
195
345
|
setDeleteBusy(false);
|
|
196
346
|
}
|
|
197
347
|
}
|
|
348
|
+
async function handleCheckout(planId) {
|
|
349
|
+
setCheckoutId(planId);
|
|
350
|
+
try {
|
|
351
|
+
const rawApiUrl = client.apiUrl ?? 'https://auth.slyxup.online';
|
|
352
|
+
const billingUrl = rawApiUrl.replace('auth.slyxup.online', 'billing.slyxup.online');
|
|
353
|
+
const token = client?._token
|
|
354
|
+
?? client?.getToken?.();
|
|
355
|
+
const headers = { 'Content-Type': 'application/json' };
|
|
356
|
+
if (token)
|
|
357
|
+
headers.Authorization = `Bearer ${token}`;
|
|
358
|
+
const pubKey = client?.publishableKey;
|
|
359
|
+
if (pubKey && pubKey !== 'pk_test_missing')
|
|
360
|
+
headers['X-Publishable-Key'] = pubKey;
|
|
361
|
+
const res = await fetch(`${billingUrl}/v1/billing/checkout`, {
|
|
362
|
+
method: 'POST',
|
|
363
|
+
headers,
|
|
364
|
+
credentials: 'include',
|
|
365
|
+
body: JSON.stringify({ planId }),
|
|
366
|
+
});
|
|
367
|
+
const data = (await res.json().catch(() => ({})));
|
|
368
|
+
if (res.ok && typeof data.checkoutUrl === 'string' && data.checkoutUrl) {
|
|
369
|
+
window.location.href = data.checkoutUrl;
|
|
370
|
+
return;
|
|
371
|
+
}
|
|
372
|
+
if (!res.ok)
|
|
373
|
+
throw new Error(typeof data.error === 'string' ? data.error : `Checkout failed (${res.status})`);
|
|
374
|
+
}
|
|
375
|
+
catch (err) {
|
|
376
|
+
// Fallback: if billing checkout isn't configured, just log. Parent can handle via window redirect.
|
|
377
|
+
console.error('[SlyxUp] checkout failed', err);
|
|
378
|
+
}
|
|
379
|
+
finally {
|
|
380
|
+
setCheckoutId(null);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
198
383
|
if (!isLoaded)
|
|
199
384
|
return _jsx("div", { className: "slx-card", "aria-busy": "true" });
|
|
200
385
|
if (!user)
|
|
201
386
|
return null;
|
|
202
387
|
const emailVerified = user.emailVerified;
|
|
203
|
-
const
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
: '
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
388
|
+
const name = displayName(user);
|
|
389
|
+
// Resolve current plan name via plans lookup if subscription has planId but no planName
|
|
390
|
+
const currentPlan = subscription
|
|
391
|
+
? plans.find((p) => p.id === subscription.planId) ?? null
|
|
392
|
+
: null;
|
|
393
|
+
const resolvedPlanName = subscription?.planName ?? currentPlan?.name ?? null;
|
|
394
|
+
const bodyInner = (_jsxs(_Fragment, { children: [_jsxs("div", { className: "slx-profile-head", children: [_jsx("h2", { className: "slx-profile-title", children: "Account settings" }), modal && (_jsx("button", { type: "button", className: "slx-profile-close", onClick: (e) => {
|
|
395
|
+
e.stopPropagation();
|
|
396
|
+
onClose?.();
|
|
397
|
+
}, "aria-label": "Close account settings", children: "\u2715" }))] }), _jsxs("div", { className: "slx-profile-body", children: [_jsxs("nav", { className: "slx-profile-nav", "aria-label": "Settings sections", children: [_jsxs("button", { type: "button", className: `slx-profile-nav-btn${tab === 'profile' ? ' on' : ''}`, onClick: () => setTab('profile'), "aria-current": tab === 'profile' ? 'page' : undefined, children: [_jsx(ProfileIcon, {}), " Profile"] }), _jsxs("button", { type: "button", className: `slx-profile-nav-btn${tab === 'security' ? ' on' : ''}`, onClick: () => setTab('security'), "aria-current": tab === 'security' ? 'page' : undefined, children: [_jsx(ShieldIcon, {}), " Security"] }), _jsxs("button", { type: "button", className: `slx-profile-nav-btn${tab === 'billing' ? ' on' : ''}`, onClick: () => setTab('billing'), "aria-current": tab === 'billing' ? 'page' : undefined, children: [_jsx(CreditCardIcon, {}), " Billing"] })] }), _jsxs("div", { className: "slx-profile-content", children: [tab === 'profile' && (_jsxs(_Fragment, { children: [_jsxs("section", { className: "slx-profile-sec", children: [_jsxs("div", { className: "slx-avatar-row", children: [_jsx("div", { className: "slx-avatar-lg", "aria-hidden": "true", children: user.avatarUrl ? _jsx("img", { src: user.avatarUrl, alt: "" }) : initials(user) }), _jsxs("div", { style: { minWidth: 0 }, children: [_jsx("p", { className: "slx-row-value", style: { margin: 0, wordBreak: 'break-word' }, children: name }), _jsx("p", { className: "slx-row-label", style: { wordBreak: 'break-all' }, children: user.email })] })] }), saved && (_jsx("p", { className: "slx-error-text", style: { color: 'var(--slx-success)' }, children: "Profile saved." })), _jsxs("form", { onSubmit: onProfileSubmit, children: [_jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-up-first", children: "First name" }), _jsx("input", { id: "slx-up-first", className: "slx-input", type: "text", autoComplete: "given-name", value: firstName, onChange: (e) => setFirstName(e.target.value) })] }), _jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-up-last", children: "Last name" }), _jsx("input", { id: "slx-up-last", className: "slx-input", type: "text", autoComplete: "family-name", value: lastName, onChange: (e) => setLastName(e.target.value) })] }), _jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-up-avatar", children: "Avatar URL" }), _jsx("input", { id: "slx-up-avatar", className: "slx-input", type: "url", placeholder: "https://\u2026", value: avatarUrl, onChange: (e) => setAvatarUrl(e.target.value) }), _jsx("p", { className: "slx-hint", children: "Paste a public image URL for your avatar." })] }), _jsx("button", { className: "slx-btn", type: "submit", disabled: busy, children: busy ? 'Saving…' : 'Save changes' })] })] }), _jsxs("section", { className: "slx-profile-sec", children: [_jsx("h3", { className: "slx-sec-title", children: "Email" }), _jsxs("div", { className: "slx-row", style: { flexWrap: 'wrap', gap: 8 }, children: [_jsxs("div", { style: { minWidth: 0 }, children: [_jsx("p", { className: "slx-row-value", style: { wordBreak: 'break-all' }, children: user.email }), _jsx("p", { className: "slx-row-label", children: "Primary email" })] }), emailVerified ? (_jsx("span", { className: "slx-badge slx-badge-ok", children: "Verified" })) : (_jsxs("span", { style: {
|
|
398
|
+
display: 'inline-flex',
|
|
399
|
+
alignItems: 'center',
|
|
400
|
+
gap: 8,
|
|
401
|
+
flexWrap: 'wrap',
|
|
402
|
+
}, children: [_jsx("span", { className: "slx-badge slx-badge-warn", children: "Unverified" }), _jsx("button", { type: "button", className: "slx-link", onClick: onResendVerification, disabled: resending, children: resending ? 'Sending…' : resent ? 'Sent ✓' : 'Resend' })] }))] })] })] })), tab === 'security' && (_jsxs(_Fragment, { children: [_jsxs("section", { className: "slx-profile-sec", children: [_jsx("h3", { className: "slx-sec-title", children: "Change password" }), pwSaved && (_jsx("p", { className: "slx-error-text", style: { color: 'var(--slx-success)' }, children: "Password updated." })), pwError && _jsx("p", { className: "slx-error-text", children: pwError }), _jsxs("form", { onSubmit: onPasswordSubmit, children: [_jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-pw-current", children: "Current password" }), _jsx("input", { id: "slx-pw-current", className: "slx-input", type: "password", autoComplete: "current-password", value: currentPassword, onChange: (e) => setCurrentPassword(e.target.value), required: true })] }), _jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-pw-new", children: "New password" }), _jsx("input", { id: "slx-pw-new", className: "slx-input", type: "password", autoComplete: "new-password", minLength: 8, value: newPassword, onChange: (e) => setNewPassword(e.target.value), required: true }), _jsx("p", { className: "slx-hint", children: "At least 8 characters." })] }), _jsxs("div", { className: "slx-field", children: [_jsx("label", { className: "slx-label", htmlFor: "slx-pw-confirm", children: "Confirm new password" }), _jsx("input", { id: "slx-pw-confirm", className: "slx-input", type: "password", autoComplete: "new-password", value: confirmPassword, onChange: (e) => setConfirmPassword(e.target.value), required: true })] }), _jsx("button", { className: "slx-btn", type: "submit", disabled: pwBusy, children: pwBusy ? 'Updating…' : 'Update password' })] })] }), _jsxs("section", { className: "slx-profile-sec", children: [_jsx("h3", { className: "slx-sec-title", children: "Active sessions" }), sessionsLoading ? (_jsx("p", { className: "slx-hint", children: "Loading sessions\u2026" })) : sessions.length === 0 ? (_jsx("p", { className: "slx-hint", children: "No active sessions." })) : (_jsxs(_Fragment, { children: [sessions.map((s) => (_jsxs("div", { className: "slx-session", children: [_jsxs("div", { className: "slx-session-meta", children: [_jsxs("p", { className: "slx-session-device", children: [deviceLabel(s.userAgent), s.isCurrent && _jsx("span", { className: "slx-badge slx-badge-accent", children: "This device" })] }), _jsx("p", { className: "slx-session-sub", children: [s.ipAddress, `created ${formatDate(s.createdAt)}`, `expires ${formatDate(s.expiresAt)}`]
|
|
403
|
+
.filter(Boolean)
|
|
404
|
+
.join(' · ') })] }), !s.isCurrent && (_jsx("button", { type: "button", className: "slx-btn-danger-outline", onClick: () => onRevoke(s.id), disabled: revokingId === s.id, children: revokingId === s.id ? '…' : 'Revoke' }))] }, s.id))), sessions.some((s) => !s.isCurrent) && (_jsx("button", { type: "button", className: "slx-btn-danger-outline", style: { width: '100%', marginTop: 4 }, onClick: onRevokeOthers, disabled: othersRevoking, children: othersRevoking ? 'Signing out…' : 'Sign out other devices' }))] }))] }), _jsxs("section", { className: "slx-danger-zone", children: [_jsx("p", { className: "slx-danger-title", children: "Danger zone" }), _jsx("p", { className: "slx-danger-desc", children: "Permanently deletes your account and all associated data. Active sessions are revoked immediately. This cannot be undone." }), deleteError && _jsx("p", { className: "slx-error-text", children: deleteError }), _jsxs("div", { className: "slx-field", children: [_jsxs("label", { className: "slx-label", htmlFor: "slx-del-confirm", children: ["Type ", _jsx("strong", { children: "DELETE" }), " to confirm"] }), _jsx("input", { id: "slx-del-confirm", className: "slx-input", type: "text", value: confirmText, onChange: (e) => setConfirmText(e.target.value), placeholder: "DELETE" })] }), _jsx("button", { type: "button", className: "slx-btn", style: {
|
|
405
|
+
background: 'var(--slx-danger)',
|
|
406
|
+
borderColor: 'var(--slx-danger)',
|
|
407
|
+
}, onClick: onDeleteAccount, disabled: confirmText !== 'DELETE' || deleteBusy, children: deleteBusy ? 'Deleting…' : 'Delete my account forever' })] })] })), tab === 'billing' &&
|
|
408
|
+
(billingLoading ? (_jsx("section", { className: "slx-profile-sec", children: _jsx("p", { className: "slx-hint", children: "Loading billing information\u2026" }) })) : !subscription ? (_jsxs(_Fragment, { children: [_jsxs("section", { className: "slx-profile-sec", children: [_jsx("h3", { className: "slx-sec-title", children: "Subscription" }), _jsxs("div", { className: "slx-billing-card", children: [_jsx("p", { className: "slx-billing-plan", children: "No active subscription" }), _jsx("p", { className: "slx-billing-detail", children: "You don't have a subscription yet. Choose a plan to get started." })] })] }), _jsxs("section", { className: "slx-profile-sec", children: [_jsx("h3", { className: "slx-sec-title", children: "Available plans" }), plansLoading ? (_jsx("p", { className: "slx-hint", children: "Loading plans\u2026" })) : plans.length === 0 ? (_jsxs("div", { className: "slx-billing-card", style: { textAlign: 'center' }, children: [_jsx("p", { className: "slx-billing-detail", children: "No plans configured for this project yet." }), _jsx("p", { className: "slx-hint", style: { marginTop: 6 }, children: "Ask your admin to create a plan in billing." })] })) : (_jsx("div", { className: "slx-billing-plans", children: plans.map((plan) => (_jsxs("div", { className: `slx-plan-card${plan.isPopular ? ' popular' : ''}`, children: [plan.isPopular && _jsx("span", { className: "slx-plan-badge", children: "POPULAR" }), _jsx("p", { className: "slx-plan-name", children: plan.name }), _jsxs("p", { style: { margin: '2px 0 0' }, children: [_jsx("span", { className: "slx-plan-price", children: formatCurrency(plan.amount, plan.currency) }), _jsxs("span", { className: "slx-plan-interval", children: ["/", plan.interval] })] }), plan.trialDays ? (_jsxs("p", { className: "slx-billing-detail", style: { color: 'var(--slx-accent)', marginTop: 4 }, children: [plan.trialDays, " day free trial"] })) : (_jsx("p", { className: "slx-billing-detail", style: { visibility: 'hidden', marginTop: 4 }, children: "\u00A0" })), _jsx("ul", { className: "slx-plan-features", children: (plan.features ?? []).map((f) => (_jsx("li", { children: f }, f))) }), _jsx("button", { type: "button", className: "slx-btn slx-plan-cta", onClick: () => handleCheckout(plan.id), disabled: checkoutId === plan.id, children: checkoutId === plan.id ? 'Redirecting…' : 'Choose plan' })] }, plan.id))) }))] }), invoices.length > 0 && (_jsxs("section", { className: "slx-profile-sec", children: [_jsx("h3", { className: "slx-sec-title", children: "Invoices" }), invoices.map((inv) => (_jsxs("div", { className: "slx-invoice-row", children: [_jsx("span", { className: "slx-invoice-date", children: inv.billedAt ? formatDate(inv.billedAt) : '—' }), _jsx("span", { className: "slx-invoice-amount", children: formatCurrency(inv.amount, inv.currency) }), _jsx("span", { className: `slx-badge ${inv.status === 'paid' ? 'slx-badge-ok' : inv.status === 'overdue' ? 'slx-badge-warn' : 'slx-badge-accent'}`, children: inv.status })] }, inv.id)))] }))] })) : (_jsxs(_Fragment, { children: [_jsxs("section", { className: "slx-profile-sec", children: [_jsx("h3", { className: "slx-sec-title", children: "Current plan" }), _jsxs("div", { className: "slx-billing-card", children: [_jsxs("div", { style: {
|
|
409
|
+
display: 'flex',
|
|
410
|
+
justifyContent: 'space-between',
|
|
411
|
+
alignItems: 'flex-start',
|
|
412
|
+
gap: 12,
|
|
413
|
+
flexWrap: 'wrap',
|
|
414
|
+
}, children: [_jsxs("div", { style: { minWidth: 0 }, children: [_jsx("p", { className: "slx-billing-plan", children: resolvedPlanName ?? 'Subscription' }), _jsxs("p", { className: "slx-billing-detail", children: ["Status:", ' ', _jsx("span", { className: `slx-billing-status slx-billing-status-${subscription.status}`, children: subscription.status })] }), subscription.currentPeriodEnd && (_jsx("p", { className: "slx-billing-detail", children: subscription.cancelAtPeriodEnd
|
|
415
|
+
? `Cancels ${formatDate(subscription.currentPeriodEnd)}`
|
|
416
|
+
: `Renews ${formatDate(subscription.currentPeriodEnd)}` })), subscription.cancelAtPeriodEnd && (_jsx("p", { className: "slx-billing-detail", style: { color: 'var(--slx-danger)', fontWeight: 600 }, children: "Scheduled to cancel at period end" }))] }), currentPlan && (_jsxs("span", { className: "slx-badge slx-badge-accent", style: { flexShrink: 0 }, children: [formatCurrency(currentPlan.amount, currentPlan.currency), "/", currentPlan.interval] }))] }), currentPlan?.features && currentPlan.features.length > 0 && (_jsx("ul", { className: "slx-plan-features", style: { margin: '12px 0 0' }, children: currentPlan.features.map((f) => (_jsx("li", { children: f }, f))) })), _jsx("div", { className: "slx-billing-actions", children: _jsx("button", { type: "button", className: "slx-btn-secondary", onClick: () => void loadBilling(), children: "Refresh" }) })] })] }), plansLoading ? (_jsx("section", { className: "slx-profile-sec", children: _jsx("p", { className: "slx-hint", children: "Loading available plans\u2026" }) })) : plans.length > 0 ? (_jsxs("section", { className: "slx-profile-sec", children: [_jsx("h3", { className: "slx-sec-title", children: "Available plans" }), _jsx("p", { className: "slx-hint", style: { marginBottom: 8 }, children: "Switch plans anytime. Changes apply at the next billing cycle." }), _jsx("div", { className: "slx-billing-plans", children: plans.map((plan) => {
|
|
417
|
+
const isCurrent = subscription.planId
|
|
418
|
+
? subscription.planId === plan.id
|
|
419
|
+
: resolvedPlanName === plan.name;
|
|
420
|
+
const currentAmount = currentPlan?.amount ?? 0;
|
|
421
|
+
const isUpgrade = plan.amount > currentAmount;
|
|
422
|
+
const isDowngrade = plan.amount < currentAmount && !isCurrent;
|
|
423
|
+
return (_jsxs("div", { className: `slx-plan-card${plan.isPopular ? ' popular' : ''}`, style: isCurrent ? { opacity: 0.92 } : undefined, children: [plan.isPopular && !isCurrent && _jsx("span", { className: "slx-plan-badge", children: "POPULAR" }), isCurrent && _jsx("span", { className: "slx-plan-badge", style: { background: 'var(--slx-success)' }, children: "CURRENT" }), _jsx("p", { className: "slx-plan-name", children: plan.name }), _jsxs("p", { style: { margin: '2px 0 0' }, children: [_jsx("span", { className: "slx-plan-price", children: formatCurrency(plan.amount, plan.currency) }), _jsxs("span", { className: "slx-plan-interval", children: ["/", plan.interval] })] }), plan.trialDays ? (_jsxs("p", { className: "slx-billing-detail", style: { color: 'var(--slx-accent)', marginTop: 4 }, children: [plan.trialDays, " day trial"] })) : (_jsx("p", { className: "slx-billing-detail", style: { visibility: 'hidden', marginTop: 4 }, children: "\u00A0" })), _jsx("ul", { className: "slx-plan-features", children: (plan.features ?? []).map((f) => (_jsx("li", { children: f }, f))) }), _jsx("button", { type: "button", className: isCurrent ? 'slx-btn-secondary slx-plan-cta' : 'slx-btn slx-plan-cta', disabled: isCurrent || checkoutId === plan.id, onClick: () => handleCheckout(plan.id), children: isCurrent
|
|
424
|
+
? 'Current plan'
|
|
425
|
+
: checkoutId === plan.id
|
|
426
|
+
? 'Redirecting…'
|
|
427
|
+
: isUpgrade
|
|
428
|
+
? 'Upgrade'
|
|
429
|
+
: isDowngrade
|
|
430
|
+
? 'Downgrade'
|
|
431
|
+
: 'Switch plan' })] }, plan.id));
|
|
432
|
+
}) })] })) : null, invoices.length > 0 && (_jsxs("section", { className: "slx-profile-sec", children: [_jsx("h3", { className: "slx-sec-title", children: "Invoices" }), invoices.map((inv) => (_jsxs("div", { className: "slx-invoice-row", children: [_jsx("span", { className: "slx-invoice-date", children: inv.billedAt ? formatDate(inv.billedAt) : '—' }), _jsx("span", { className: "slx-invoice-amount", children: formatCurrency(inv.amount, inv.currency) }), _jsx("span", { className: `slx-badge ${inv.status === 'paid' ? 'slx-badge-ok' : inv.status === 'overdue' ? 'slx-badge-warn' : 'slx-badge-accent'}`, children: inv.status })] }, inv.id)))] }))] })))] })] })] }));
|
|
433
|
+
if (!modal) {
|
|
434
|
+
return (_jsx("div", { className: "slx-profile-modal", style: { maxHeight: 'none' }, children: bodyInner }));
|
|
435
|
+
}
|
|
436
|
+
// Modal overlay — click on backdrop closes, click inside modal does not.
|
|
437
|
+
// Use onMouseDown + onClick for desktop + mobile reliability; close button also works via stopPropagation.
|
|
223
438
|
return (_jsx("div", { className: "slx-overlay", onMouseDown: (e) => {
|
|
224
439
|
if (e.target === e.currentTarget)
|
|
225
440
|
onClose?.();
|
|
226
|
-
},
|
|
441
|
+
}, onClick: (e) => {
|
|
442
|
+
if (e.target === e.currentTarget)
|
|
443
|
+
onClose?.();
|
|
444
|
+
}, role: "presentation", children: _jsx("div", { role: "dialog", "aria-modal": "true", "aria-label": "Account settings", className: "slx-profile-modal", onMouseDown: (e) => e.stopPropagation(), onClick: (e) => e.stopPropagation(), children: bodyInner }) }));
|
|
227
445
|
}
|
|
228
446
|
function ProfileIcon() {
|
|
229
447
|
return (_jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": "true", children: [_jsx("circle", { cx: "12", cy: "8", r: "4" }), _jsx("path", { d: "M5 21c0-3.9 3.1-7 7-7s7 3.1 7 7" })] }));
|
|
@@ -231,4 +449,7 @@ function ProfileIcon() {
|
|
|
231
449
|
function ShieldIcon() {
|
|
232
450
|
return (_jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("path", { d: "M12 22s8-3.6 8-10V5l-8-3-8 3v7c0 6.4 8 10 8 10z" }), _jsx("path", { d: "m9 12 2 2 4-4" })] }));
|
|
233
451
|
}
|
|
452
|
+
function CreditCardIcon() {
|
|
453
|
+
return (_jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: [_jsx("rect", { x: "1", y: "4", width: "22", height: "16", rx: "2", ry: "2" }), _jsx("line", { x1: "1", y1: "10", x2: "23", y2: "10" })] }));
|
|
454
|
+
}
|
|
234
455
|
//# sourceMappingURL=UserProfile.js.map
|