@payez/next-mvp 3.3.0 → 3.4.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.
@@ -44,7 +44,11 @@ function UserAvatarMenu({ basePath = '', showProfile = true, showSettings = true
44
44
  if (!session?.user) {
45
45
  return null;
46
46
  }
47
- const userInitial = session.user.email?.charAt(0).toUpperCase() || 'U';
47
+ // Derive display initial from name or email ignore anon/internal IDs
48
+ const userName = session.user?.name;
49
+ const userEmail = session.user.email;
50
+ const displaySource = userName || userEmail;
51
+ const userInitial = displaySource?.charAt(0).toUpperCase() || '?';
48
52
  const handleNavigation = (path) => {
49
53
  setIsOpen(false);
50
54
  router.push(path);
@@ -69,7 +73,7 @@ function UserAvatarMenu({ basePath = '', showProfile = true, showSettings = true
69
73
  router.push(item.href);
70
74
  }
71
75
  };
72
- return ((0, jsx_runtime_1.jsxs)("div", { ref: menuRef, className: "relative", children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => setIsOpen(!isOpen), className: "flex items-center justify-center h-10 w-10 rounded-full bg-[#349AD5] text-white font-semibold text-lg hover:bg-[#2980b9] transition-colors focus:outline-none focus:ring-2 focus:ring-[#349AD5] focus:ring-offset-2 dark:focus:ring-offset-slate-900", "aria-label": "User menu", "aria-expanded": isOpen, "aria-haspopup": "true", children: userInitial }), isOpen && ((0, jsx_runtime_1.jsxs)("div", { className: "absolute right-0 mt-2 w-56 rounded-md shadow-lg z-50\r\n bg-white dark:bg-slate-900\r\n border border-gray-200 dark:border-slate-700", role: "menu", "aria-orientation": "vertical", children: [(0, jsx_runtime_1.jsx)("div", { className: "px-4 py-3 border-b border-gray-200 dark:border-slate-700", children: (0, jsx_runtime_1.jsx)("p", { className: "text-sm text-gray-500 dark:text-slate-400 truncate", children: session.user.email }) }), (0, jsx_runtime_1.jsxs)("div", { className: "py-1", children: [showProfile && ((0, jsx_runtime_1.jsx)(MenuItem, { icon: (0, jsx_runtime_1.jsx)(lucide_react_1.User, { className: "h-4 w-4" }), label: "Profile", onClick: () => handleNavigation(`${basePath}/profile`) })), showSettings && ((0, jsx_runtime_1.jsx)(MenuItem, { icon: (0, jsx_runtime_1.jsx)(lucide_react_1.Settings, { className: "h-4 w-4" }), label: "Settings", onClick: () => handleNavigation(`${basePath}/settings`) })), showSecurity && ((0, jsx_runtime_1.jsx)(MenuItem, { icon: (0, jsx_runtime_1.jsx)(lucide_react_1.Shield, { className: "h-4 w-4" }), label: "Security", onClick: () => handleNavigation(`${basePath}/security`) })), customItems?.map((item, index) => ((0, jsx_runtime_1.jsx)(MenuItem, { icon: item.icon, label: item.label, onClick: () => handleItemClick(item) }, index)))] }), (0, jsx_runtime_1.jsx)("div", { className: "border-t border-gray-200 dark:border-slate-700 py-1", children: (0, jsx_runtime_1.jsx)(MenuItem, { icon: (0, jsx_runtime_1.jsx)(lucide_react_1.LogOut, { className: "h-4 w-4" }), label: "Sign Out", onClick: handleSignOut, variant: "danger" }) })] }))] }));
76
+ return ((0, jsx_runtime_1.jsxs)("div", { ref: menuRef, className: "relative", children: [(0, jsx_runtime_1.jsx)("button", { onClick: () => setIsOpen(!isOpen), className: "flex items-center justify-center h-10 w-10 rounded-full bg-[#349AD5] text-white font-semibold text-lg hover:bg-[#2980b9] transition-colors focus:outline-none focus:ring-2 focus:ring-[#349AD5] focus:ring-offset-2 dark:focus:ring-offset-slate-900", "aria-label": "User menu", "aria-expanded": isOpen, "aria-haspopup": "true", children: userInitial }), isOpen && ((0, jsx_runtime_1.jsxs)("div", { className: "absolute right-0 mt-2 w-56 rounded-md shadow-lg z-50\r\n bg-white dark:bg-slate-900\r\n border border-gray-200 dark:border-slate-700", role: "menu", "aria-orientation": "vertical", children: [(0, jsx_runtime_1.jsxs)("div", { className: "px-4 py-3 border-b border-gray-200 dark:border-slate-700", children: [userName && ((0, jsx_runtime_1.jsx)("p", { className: "text-sm font-medium text-gray-700 dark:text-slate-200 truncate", children: userName })), userEmail && ((0, jsx_runtime_1.jsx)("p", { className: "text-sm text-gray-500 dark:text-slate-400 truncate", children: userEmail })), !userName && !userEmail && ((0, jsx_runtime_1.jsx)("p", { className: "text-sm text-gray-500 dark:text-slate-400", children: "Signed in" }))] }), (0, jsx_runtime_1.jsxs)("div", { className: "py-1", children: [showProfile && ((0, jsx_runtime_1.jsx)(MenuItem, { icon: (0, jsx_runtime_1.jsx)(lucide_react_1.User, { className: "h-4 w-4" }), label: "Profile", onClick: () => handleNavigation(`${basePath}/profile`) })), showSettings && ((0, jsx_runtime_1.jsx)(MenuItem, { icon: (0, jsx_runtime_1.jsx)(lucide_react_1.Settings, { className: "h-4 w-4" }), label: "Settings", onClick: () => handleNavigation(`${basePath}/settings`) })), showSecurity && ((0, jsx_runtime_1.jsx)(MenuItem, { icon: (0, jsx_runtime_1.jsx)(lucide_react_1.Shield, { className: "h-4 w-4" }), label: "Security", onClick: () => handleNavigation(`${basePath}/security`) })), customItems?.map((item, index) => ((0, jsx_runtime_1.jsx)(MenuItem, { icon: item.icon, label: item.label, onClick: () => handleItemClick(item) }, index)))] }), (0, jsx_runtime_1.jsx)("div", { className: "border-t border-gray-200 dark:border-slate-700 py-1", children: (0, jsx_runtime_1.jsx)(MenuItem, { icon: (0, jsx_runtime_1.jsx)(lucide_react_1.LogOut, { className: "h-4 w-4" }), label: "Sign Out", onClick: handleSignOut, variant: "danger" }) })] }))] }));
73
77
  }
74
78
  function MenuItem({ icon, label, onClick, variant = 'default' }) {
75
79
  const baseClasses = "flex items-center w-full px-4 py-2 text-sm cursor-pointer transition-colors";
@@ -34,6 +34,10 @@ export declare function createSession(data: SessionData): Promise<string>;
34
34
  * @returns The session data, or null if not found.
35
35
  */
36
36
  export declare function getSession(sessionToken: string): Promise<SessionData | null>;
37
+ /**
38
+ * Refresh session TTL without reading/writing data (sliding window expiry).
39
+ */
40
+ export declare function touchSession(token: string): Promise<void>;
37
41
  /**
38
42
  * Retrieves a session along with a version identifier for optimistic locking.
39
43
  * @param sessionToken The session token to look up.
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.generateSessionToken = generateSessionToken;
16
16
  exports.createSession = createSession;
17
17
  exports.getSession = getSession;
18
+ exports.touchSession = touchSession;
18
19
  exports.getSessionWithVersion = getSessionWithVersion;
19
20
  exports.isAccessTokenFresh = isAccessTokenFresh;
20
21
  exports.deleteSession = deleteSession;
@@ -95,6 +96,13 @@ async function getSession(sessionToken) {
95
96
  return null;
96
97
  }
97
98
  }
99
+ /**
100
+ * Refresh session TTL without reading/writing data (sliding window expiry).
101
+ */
102
+ async function touchSession(token) {
103
+ const key = getSessionKey(token);
104
+ await redis_1.default.expire(key, SESSION_TTL);
105
+ }
98
106
  /**
99
107
  * Retrieves a session along with a version identifier for optimistic locking.
100
108
  * @param sessionToken The session token to look up.
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ interface ComingSoonPageProps {
3
+ homeUrl?: string;
4
+ /** Override logo — pass a React node (e.g. inline SVG or themed <img>) */
5
+ logo?: React.ReactNode;
6
+ }
7
+ export default function ComingSoonPage(props: ComingSoonPageProps): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ 'use client';
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.default = ComingSoonPage;
8
+ const jsx_runtime_1 = require("react/jsx-runtime");
9
+ const react_1 = require("react");
10
+ const link_1 = __importDefault(require("next/link"));
11
+ const useTheme_1 = require("../../theme/useTheme");
12
+ function ComingSoonContent({ homeUrl = '/', logo }) {
13
+ const branding = (0, useTheme_1.useBranding)();
14
+ const colors = (0, useTheme_1.useColors)();
15
+ const fallbackLogo = branding.logo?.dark || branding.logo?.light;
16
+ const logoAlt = branding.logo?.alt || branding.appName || 'App Logo';
17
+ const logoHeight = branding.logo?.height || 48;
18
+ return ((0, jsx_runtime_1.jsx)("div", { className: "min-h-screen flex items-center justify-center p-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "max-w-md w-full text-center rounded-xl p-8 shadow-lg border", style: {
19
+ backgroundColor: 'var(--bg-card, #ffffff)',
20
+ borderColor: 'var(--border-default, #e5e7eb)',
21
+ }, children: [(0, jsx_runtime_1.jsx)("div", { className: "mb-6 flex justify-center", children: logo || (fallbackLogo && ((0, jsx_runtime_1.jsx)("img", { src: fallbackLogo, alt: logoAlt, style: { height: logoHeight } }))) }), (0, jsx_runtime_1.jsx)("h1", { className: "text-2xl font-bold mb-2", style: { color: 'var(--text-primary, #111827)' }, children: branding.appName || 'Our App' }), (0, jsx_runtime_1.jsx)("span", { className: "inline-flex items-center px-3 py-1 text-xs font-medium rounded-full lowercase tracking-wide border mb-4", style: {
22
+ borderColor: colors.primary || '#3b82f6',
23
+ color: colors.primary || '#3b82f6',
24
+ }, children: "coming soon" }), (0, jsx_runtime_1.jsx)("p", { className: "mb-6", style: { color: 'var(--text-secondary, #6b7280)' }, children: "We're currently in beta and access is limited to approved users. Check back soon \u2014 we're working hard to open the doors!" }), (0, jsx_runtime_1.jsx)(link_1.default, { href: homeUrl, className: "inline-block w-full font-medium py-3 px-4 rounded-lg transition-colors text-white", style: { backgroundColor: colors.primary || '#3b82f6' }, children: "Go to Home" })] }) }));
25
+ }
26
+ function ComingSoonPage(props) {
27
+ return ((0, jsx_runtime_1.jsx)(react_1.Suspense, { children: (0, jsx_runtime_1.jsx)(ComingSoonContent, { ...props }) }));
28
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payez/next-mvp",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "sideEffects": false,
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -816,6 +816,11 @@
816
816
  "types": "./dist/pages/client-admin/index.d.ts",
817
817
  "require": "./dist/pages/client-admin/index.js",
818
818
  "default": "./dist/pages/client-admin/index.js"
819
+ },
820
+ "./pages/coming-soon": {
821
+ "types": "./dist/pages/coming-soon/page.d.ts",
822
+ "require": "./dist/pages/coming-soon/page.js",
823
+ "default": "./dist/pages/coming-soon/page.js"
819
824
  }
820
825
  },
821
826
  "peerDependencies": {
@@ -83,7 +83,11 @@ export function UserAvatarMenu({
83
83
  return null;
84
84
  }
85
85
 
86
- const userInitial = session.user.email?.charAt(0).toUpperCase() || 'U';
86
+ // Derive display initial from name or email ignore anon/internal IDs
87
+ const userName = (session.user as any)?.name;
88
+ const userEmail = session.user.email;
89
+ const displaySource = userName || userEmail;
90
+ const userInitial = displaySource?.charAt(0).toUpperCase() || '?';
87
91
 
88
92
  const handleNavigation = (path: string) => {
89
93
  setIsOpen(false);
@@ -132,11 +136,23 @@ export function UserAvatarMenu({
132
136
  role="menu"
133
137
  aria-orientation="vertical"
134
138
  >
135
- {/* User email label */}
139
+ {/* User identity label */}
136
140
  <div className="px-4 py-3 border-b border-gray-200 dark:border-slate-700">
137
- <p className="text-sm text-gray-500 dark:text-slate-400 truncate">
138
- {session.user.email}
139
- </p>
141
+ {userName && (
142
+ <p className="text-sm font-medium text-gray-700 dark:text-slate-200 truncate">
143
+ {userName}
144
+ </p>
145
+ )}
146
+ {userEmail && (
147
+ <p className="text-sm text-gray-500 dark:text-slate-400 truncate">
148
+ {userEmail}
149
+ </p>
150
+ )}
151
+ {!userName && !userEmail && (
152
+ <p className="text-sm text-gray-500 dark:text-slate-400">
153
+ Signed in
154
+ </p>
155
+ )}
140
156
  </div>
141
157
 
142
158
  {/* Menu items */}
@@ -87,6 +87,14 @@ export async function getSession(sessionToken: string): Promise<SessionData | nu
87
87
  }
88
88
  }
89
89
 
90
+ /**
91
+ * Refresh session TTL without reading/writing data (sliding window expiry).
92
+ */
93
+ export async function touchSession(token: string): Promise<void> {
94
+ const key = getSessionKey(token);
95
+ await redis.expire(key, SESSION_TTL);
96
+ }
97
+
90
98
  /**
91
99
  * Retrieves a session along with a version identifier for optimistic locking.
92
100
  * @param sessionToken The session token to look up.
@@ -0,0 +1,83 @@
1
+ 'use client';
2
+
3
+ import React, { Suspense } from 'react';
4
+ import Link from 'next/link';
5
+ import { useBranding, useColors } from '../../theme/useTheme';
6
+
7
+ interface ComingSoonPageProps {
8
+ homeUrl?: string;
9
+ /** Override logo — pass a React node (e.g. inline SVG or themed <img>) */
10
+ logo?: React.ReactNode;
11
+ }
12
+
13
+ function ComingSoonContent({ homeUrl = '/', logo }: ComingSoonPageProps) {
14
+ const branding = useBranding();
15
+ const colors = useColors();
16
+
17
+ const fallbackLogo = branding.logo?.dark || branding.logo?.light;
18
+ const logoAlt = branding.logo?.alt || branding.appName || 'App Logo';
19
+ const logoHeight = branding.logo?.height || 48;
20
+
21
+ return (
22
+ <div className="min-h-screen flex items-center justify-center p-4">
23
+ <div
24
+ className="max-w-md w-full text-center rounded-xl p-8 shadow-lg border"
25
+ style={{
26
+ backgroundColor: 'var(--bg-card, #ffffff)',
27
+ borderColor: 'var(--border-default, #e5e7eb)',
28
+ }}
29
+ >
30
+ <div className="mb-6 flex justify-center">
31
+ {logo || (fallbackLogo && (
32
+ <img
33
+ src={fallbackLogo}
34
+ alt={logoAlt}
35
+ style={{ height: logoHeight }}
36
+ />
37
+ ))}
38
+ </div>
39
+
40
+ <h1
41
+ className="text-2xl font-bold mb-2"
42
+ style={{ color: 'var(--text-primary, #111827)' }}
43
+ >
44
+ {branding.appName || 'Our App'}
45
+ </h1>
46
+
47
+ <span
48
+ className="inline-flex items-center px-3 py-1 text-xs font-medium rounded-full lowercase tracking-wide border mb-4"
49
+ style={{
50
+ borderColor: colors.primary || '#3b82f6',
51
+ color: colors.primary || '#3b82f6',
52
+ }}
53
+ >
54
+ coming soon
55
+ </span>
56
+
57
+ <p
58
+ className="mb-6"
59
+ style={{ color: 'var(--text-secondary, #6b7280)' }}
60
+ >
61
+ We&apos;re currently in beta and access is limited to approved users.
62
+ Check back soon &mdash; we&apos;re working hard to open the doors!
63
+ </p>
64
+
65
+ <Link
66
+ href={homeUrl}
67
+ className="inline-block w-full font-medium py-3 px-4 rounded-lg transition-colors text-white"
68
+ style={{ backgroundColor: colors.primary || '#3b82f6' }}
69
+ >
70
+ Go to Home
71
+ </Link>
72
+ </div>
73
+ </div>
74
+ );
75
+ }
76
+
77
+ export default function ComingSoonPage(props: ComingSoonPageProps) {
78
+ return (
79
+ <Suspense>
80
+ <ComingSoonContent {...props} />
81
+ </Suspense>
82
+ );
83
+ }