@onexapis/cli 1.1.36 → 1.1.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/cli.js +5 -1
  2. package/dist/cli.js.map +1 -1
  3. package/dist/cli.mjs +5 -1
  4. package/dist/cli.mjs.map +1 -1
  5. package/dist/preview/preview-app.tsx +13 -5
  6. package/package.json +1 -1
  7. package/templates/default/AUTH_AND_PROFILE.md +167 -0
  8. package/templates/default/LAYOUT.md +195 -0
  9. package/templates/default/bundle-entry.ts +5 -0
  10. package/templates/default/hooks/index.ts +26 -0
  11. package/templates/default/hooks/use-forgot-password-form.ts +90 -0
  12. package/templates/default/hooks/use-login-form.ts +102 -0
  13. package/templates/default/hooks/use-profile-form.ts +255 -0
  14. package/templates/default/hooks/use-register-form.ts +154 -0
  15. package/templates/default/hooks/use-verify-code-form.ts +224 -0
  16. package/templates/default/index.ts +21 -1
  17. package/templates/default/pages/forgot-password.ts +41 -0
  18. package/templates/default/pages/login.ts +41 -0
  19. package/templates/default/pages/profile.ts +39 -0
  20. package/templates/default/pages/register.ts +41 -0
  21. package/templates/default/pages/verify-code.ts +41 -0
  22. package/templates/default/sections/auth-forgot-password/auth-forgot-password-default.tsx +192 -0
  23. package/templates/default/sections/auth-forgot-password/auth-forgot-password.schema.ts +150 -0
  24. package/templates/default/sections/auth-forgot-password/index.ts +14 -0
  25. package/templates/default/sections/auth-login/auth-login-default.tsx +238 -0
  26. package/templates/default/sections/auth-login/auth-login.schema.ts +171 -0
  27. package/templates/default/sections/auth-login/index.ts +14 -0
  28. package/templates/default/sections/auth-register/auth-register-default.tsx +327 -0
  29. package/templates/default/sections/auth-register/auth-register.schema.ts +188 -0
  30. package/templates/default/sections/auth-register/index.ts +14 -0
  31. package/templates/default/sections/auth-verify-code/auth-verify-code-default.tsx +209 -0
  32. package/templates/default/sections/auth-verify-code/auth-verify-code.schema.ts +150 -0
  33. package/templates/default/sections/auth-verify-code/index.ts +14 -0
  34. package/templates/default/sections/footer/footer-default.tsx +214 -0
  35. package/templates/default/sections/footer/footer.schema.ts +170 -0
  36. package/templates/default/sections/footer/index.ts +14 -0
  37. package/templates/default/sections/header/header-default.tsx +322 -0
  38. package/templates/default/sections/header/header.schema.ts +168 -0
  39. package/templates/default/sections/header/index.ts +14 -0
  40. package/templates/default/sections/profile/index.ts +14 -0
  41. package/templates/default/sections/profile/profile-default.tsx +522 -0
  42. package/templates/default/sections/profile/profile.schema.ts +228 -0
  43. package/templates/default/sections-registry.ts +28 -0
  44. package/templates/default/theme.layout.ts +53 -2
@@ -0,0 +1,255 @@
1
+ /**
2
+ * Profile Form Hook
3
+ * Manages profile form state, dirty tracking, and submission via useAuth
4
+ */
5
+
6
+ "use client";
7
+
8
+ import { useState, useEffect, useCallback, useRef } from "react";
9
+ import { useAuth } from "@onexapis/core/hooks";
10
+
11
+ export interface ProfileFormData {
12
+ name: string;
13
+ email: string;
14
+ phone: string;
15
+ address: string;
16
+ }
17
+
18
+ export interface ChangePasswordData {
19
+ currentPassword: string;
20
+ newPassword: string;
21
+ confirmPassword: string;
22
+ }
23
+
24
+ export interface UseProfileFormReturn {
25
+ // User state
26
+ isAuthenticated: boolean;
27
+ isLoading: boolean;
28
+
29
+ // Form state
30
+ formData: ProfileFormData;
31
+ handleFieldChange: (field: keyof ProfileFormData, value: string) => void;
32
+ isDirty: boolean;
33
+ isSubmitting: boolean;
34
+ submitError: string | null;
35
+ handleSubmit: (e?: React.FormEvent) => Promise<void>;
36
+
37
+ // Change password
38
+ passwordData: ChangePasswordData;
39
+ handlePasswordFieldChange: (
40
+ field: keyof ChangePasswordData,
41
+ value: string
42
+ ) => void;
43
+ showCurrentPassword: boolean;
44
+ showNewPassword: boolean;
45
+ showConfirmPassword: boolean;
46
+ toggleCurrentPassword: () => void;
47
+ toggleNewPassword: () => void;
48
+ toggleConfirmPassword: () => void;
49
+ passwordErrors: Record<string, string>;
50
+ isChangingPassword: boolean;
51
+ showPasswordForm: boolean;
52
+ setShowPasswordForm: (show: boolean) => void;
53
+ handlePasswordSubmit: (e?: React.FormEvent) => Promise<void>;
54
+
55
+ // Logout
56
+ handleLogout: () => Promise<void>;
57
+ }
58
+
59
+ export function useProfileForm(): UseProfileFormReturn {
60
+ const {
61
+ user,
62
+ isAuthenticated,
63
+ isLoading,
64
+ updateProfile,
65
+ changePassword,
66
+ logout,
67
+ initialize,
68
+ } = useAuth();
69
+
70
+ const [formData, setFormData] = useState<ProfileFormData>({
71
+ name: "",
72
+ email: "",
73
+ phone: "",
74
+ address: "",
75
+ });
76
+ const [isSubmitting, setIsSubmitting] = useState(false);
77
+ const [submitError, setSubmitError] = useState<string | null>(null);
78
+ const initialDataRef = useRef<ProfileFormData | null>(null);
79
+
80
+ // Password form
81
+ const [passwordData, setPasswordData] = useState<ChangePasswordData>({
82
+ currentPassword: "",
83
+ newPassword: "",
84
+ confirmPassword: "",
85
+ });
86
+ const [showCurrentPassword, setShowCurrentPassword] = useState(false);
87
+ const [showNewPassword, setShowNewPassword] = useState(false);
88
+ const [showConfirmPassword, setShowConfirmPassword] = useState(false);
89
+ const [passwordErrors, setPasswordErrors] = useState<Record<string, string>>(
90
+ {}
91
+ );
92
+ const [isChangingPassword, setIsChangingPassword] = useState(false);
93
+ const [showPasswordForm, setShowPasswordForm] = useState(false);
94
+
95
+ // Initialize auth on mount
96
+ useEffect(() => {
97
+ initialize();
98
+ }, [initialize]);
99
+
100
+ // Populate form from user data
101
+ useEffect(() => {
102
+ if (user) {
103
+ const data: ProfileFormData = {
104
+ name: user.name || "",
105
+ email: user.email || "",
106
+ phone: user.phone_number || "",
107
+ address: user.address || "",
108
+ };
109
+ setFormData(data);
110
+ initialDataRef.current = data;
111
+ }
112
+ }, [user]);
113
+
114
+ const handleFieldChange = useCallback(
115
+ (field: keyof ProfileFormData, value: string) => {
116
+ setFormData((prev) => ({ ...prev, [field]: value }));
117
+ setSubmitError(null);
118
+ },
119
+ []
120
+ );
121
+
122
+ const isDirty =
123
+ initialDataRef.current !== null &&
124
+ (formData.name !== initialDataRef.current.name ||
125
+ formData.phone !== initialDataRef.current.phone ||
126
+ formData.address !== initialDataRef.current.address);
127
+
128
+ const handleSubmit = useCallback(
129
+ async (e?: React.FormEvent) => {
130
+ e?.preventDefault();
131
+ if (!isDirty) return;
132
+
133
+ setIsSubmitting(true);
134
+ setSubmitError(null);
135
+ try {
136
+ await updateProfile({
137
+ name: formData.name,
138
+ phone_number: formData.phone,
139
+ address: formData.address,
140
+ });
141
+ // Update initial data ref to new values
142
+ initialDataRef.current = { ...formData };
143
+ } catch (error) {
144
+ const message =
145
+ error instanceof Error ? error.message : "Failed to update profile";
146
+ setSubmitError(message);
147
+ } finally {
148
+ setIsSubmitting(false);
149
+ }
150
+ },
151
+ [isDirty, formData, updateProfile]
152
+ );
153
+
154
+ // Password handlers
155
+ const handlePasswordFieldChange = useCallback(
156
+ (field: keyof ChangePasswordData, value: string) => {
157
+ setPasswordData((prev) => ({ ...prev, [field]: value }));
158
+ if (passwordErrors[field]) {
159
+ setPasswordErrors((prev) => ({ ...prev, [field]: "" }));
160
+ }
161
+ },
162
+ [passwordErrors]
163
+ );
164
+
165
+ const validatePassword = useCallback((): boolean => {
166
+ const errors: Record<string, string> = {};
167
+
168
+ if (!passwordData.currentPassword) {
169
+ errors.currentPassword = "Please enter your current password";
170
+ }
171
+ if (!passwordData.newPassword) {
172
+ errors.newPassword = "Please enter a new password";
173
+ } else if (passwordData.newPassword.length < 8) {
174
+ errors.newPassword = "Password must be at least 8 characters";
175
+ } else if (
176
+ !/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)/.test(passwordData.newPassword)
177
+ ) {
178
+ errors.newPassword =
179
+ "Password must contain uppercase, lowercase, and a number";
180
+ } else if (passwordData.newPassword === passwordData.currentPassword) {
181
+ errors.newPassword =
182
+ "New password must be different from current password";
183
+ }
184
+ if (!passwordData.confirmPassword) {
185
+ errors.confirmPassword = "Please confirm your new password";
186
+ } else if (passwordData.newPassword !== passwordData.confirmPassword) {
187
+ errors.confirmPassword = "Passwords do not match";
188
+ }
189
+
190
+ setPasswordErrors(errors);
191
+ return Object.keys(errors).length === 0;
192
+ }, [passwordData]);
193
+
194
+ const handlePasswordSubmit = useCallback(
195
+ async (e?: React.FormEvent) => {
196
+ e?.preventDefault();
197
+ if (!validatePassword()) return;
198
+
199
+ setIsChangingPassword(true);
200
+ try {
201
+ await changePassword({
202
+ oldPassword: passwordData.currentPassword,
203
+ newPassword: passwordData.newPassword,
204
+ });
205
+ // Reset form on success
206
+ setPasswordData({
207
+ currentPassword: "",
208
+ newPassword: "",
209
+ confirmPassword: "",
210
+ });
211
+ setShowPasswordForm(false);
212
+ setPasswordErrors({});
213
+ } catch (error) {
214
+ const message =
215
+ error instanceof Error ? error.message : "Failed to change password";
216
+ setPasswordErrors({ form: message });
217
+ } finally {
218
+ setIsChangingPassword(false);
219
+ }
220
+ },
221
+ [validatePassword, changePassword, passwordData]
222
+ );
223
+
224
+ const handleLogout = useCallback(async () => {
225
+ await logout();
226
+ if (typeof window !== "undefined") {
227
+ window.location.href = "/login";
228
+ }
229
+ }, [logout]);
230
+
231
+ return {
232
+ isAuthenticated,
233
+ isLoading,
234
+ formData,
235
+ handleFieldChange,
236
+ isDirty,
237
+ isSubmitting,
238
+ submitError,
239
+ handleSubmit,
240
+ passwordData,
241
+ handlePasswordFieldChange,
242
+ showCurrentPassword,
243
+ showNewPassword,
244
+ showConfirmPassword,
245
+ toggleCurrentPassword: () => setShowCurrentPassword((p) => !p),
246
+ toggleNewPassword: () => setShowNewPassword((p) => !p),
247
+ toggleConfirmPassword: () => setShowConfirmPassword((p) => !p),
248
+ passwordErrors,
249
+ isChangingPassword,
250
+ showPasswordForm,
251
+ setShowPasswordForm,
252
+ handlePasswordSubmit,
253
+ handleLogout,
254
+ };
255
+ }
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Register Form Hook
3
+ * Manages form state, validation, and submission via useAuth
4
+ */
5
+
6
+ "use client";
7
+
8
+ import { useState, useCallback } from "react";
9
+ import { useAuth } from "@onexapis/core/hooks";
10
+
11
+ export interface RegisterFormData {
12
+ email: string;
13
+ username: string;
14
+ password: string;
15
+ confirmPassword: string;
16
+ }
17
+
18
+ export interface UseRegisterFormReturn {
19
+ formData: RegisterFormData;
20
+ errors: Record<string, string>;
21
+ showPassword: boolean;
22
+ showConfirmPassword: boolean;
23
+ isPending: boolean;
24
+ handleInputChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
25
+ handleSubmit: (e: React.FormEvent) => void;
26
+ toggleShowPassword: () => void;
27
+ toggleShowConfirmPassword: () => void;
28
+ clearError: (field: string) => void;
29
+ }
30
+
31
+ export function useRegisterForm(): UseRegisterFormReturn {
32
+ const [formData, setFormData] = useState<RegisterFormData>({
33
+ email: "",
34
+ username: "",
35
+ password: "",
36
+ confirmPassword: "",
37
+ });
38
+ const [errors, setErrors] = useState<Record<string, string>>({});
39
+ const [showPassword, setShowPassword] = useState(false);
40
+ const [showConfirmPassword, setShowConfirmPassword] = useState(false);
41
+ const [isPending, setIsPending] = useState(false);
42
+
43
+ const { signup } = useAuth();
44
+
45
+ const handleInputChange = useCallback(
46
+ (e: React.ChangeEvent<HTMLInputElement>) => {
47
+ const { name, value } = e.target;
48
+ setFormData((prev) => ({ ...prev, [name]: value }));
49
+ if (errors[name]) {
50
+ setErrors((prev) => ({ ...prev, [name]: "" }));
51
+ }
52
+ },
53
+ [errors]
54
+ );
55
+
56
+ const validateForm = useCallback((): boolean => {
57
+ const newErrors: Record<string, string> = {};
58
+
59
+ if (!formData.email) {
60
+ newErrors.email = "Please enter your email";
61
+ } else if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) {
62
+ newErrors.email = "Invalid email format";
63
+ }
64
+
65
+ if (!formData.username) {
66
+ newErrors.username = "Please enter a username";
67
+ } else if (formData.username.length < 3) {
68
+ newErrors.username = "Username must be at least 3 characters";
69
+ } else if (!/^[a-zA-Z0-9_]+$/.test(formData.username)) {
70
+ newErrors.username =
71
+ "Username can only contain letters, numbers, and underscores";
72
+ }
73
+
74
+ if (!formData.password) {
75
+ newErrors.password = "Please enter a password";
76
+ } else if (formData.password.length < 8) {
77
+ newErrors.password = "Password must be at least 8 characters";
78
+ } else if (!/(?=.*[a-z])(?=.*[A-Z])(?=.*\d)/.test(formData.password)) {
79
+ newErrors.password =
80
+ "Password must contain uppercase, lowercase, and a number";
81
+ }
82
+
83
+ if (!formData.confirmPassword) {
84
+ newErrors.confirmPassword = "Please confirm your password";
85
+ } else if (formData.password !== formData.confirmPassword) {
86
+ newErrors.confirmPassword = "Passwords do not match";
87
+ }
88
+
89
+ setErrors(newErrors);
90
+ return Object.keys(newErrors).length === 0;
91
+ }, [formData]);
92
+
93
+ const handleSubmit = useCallback(
94
+ async (e: React.FormEvent) => {
95
+ e.preventDefault();
96
+ if (!validateForm()) return;
97
+
98
+ setIsPending(true);
99
+ try {
100
+ await signup({
101
+ email: formData.email,
102
+ username: formData.username,
103
+ password: formData.password,
104
+ name: formData.username,
105
+ });
106
+ // Store email for verify-code page
107
+ if (typeof window !== "undefined") {
108
+ const expiryTimestamp = Date.now() + 60 * 1000;
109
+ localStorage.setItem(
110
+ `resend_countdown_${formData.username}`,
111
+ expiryTimestamp.toString()
112
+ );
113
+ localStorage.setItem(
114
+ `register_email_${formData.username}`,
115
+ formData.email
116
+ );
117
+ window.location.href = `/verify-code?username=${encodeURIComponent(formData.username)}`;
118
+ }
119
+ } catch (error) {
120
+ const message =
121
+ error instanceof Error ? error.message : "Registration failed";
122
+ setErrors({ form: message });
123
+ } finally {
124
+ setIsPending(false);
125
+ }
126
+ },
127
+ [validateForm, signup, formData]
128
+ );
129
+
130
+ const toggleShowPassword = useCallback(() => {
131
+ setShowPassword((prev) => !prev);
132
+ }, []);
133
+
134
+ const toggleShowConfirmPassword = useCallback(() => {
135
+ setShowConfirmPassword((prev) => !prev);
136
+ }, []);
137
+
138
+ const clearError = useCallback((field: string) => {
139
+ setErrors((prev) => ({ ...prev, [field]: "" }));
140
+ }, []);
141
+
142
+ return {
143
+ formData,
144
+ errors,
145
+ showPassword,
146
+ showConfirmPassword,
147
+ isPending,
148
+ handleInputChange,
149
+ handleSubmit,
150
+ toggleShowPassword,
151
+ toggleShowConfirmPassword,
152
+ clearError,
153
+ };
154
+ }
@@ -0,0 +1,224 @@
1
+ /**
2
+ * Verify Code Form Hook
3
+ * Manages OTP input state, countdown timer, and submission via useAuth
4
+ */
5
+
6
+ "use client";
7
+
8
+ import { useState, useRef, useEffect, useCallback } from "react";
9
+ import { useAuth } from "@onexapis/core/hooks";
10
+
11
+ export interface UseVerifyCodeFormReturn {
12
+ code: string[];
13
+ error: string | null;
14
+ countdown: number;
15
+ email: string;
16
+ username: string;
17
+ isVerifying: boolean;
18
+ isResending: boolean;
19
+ isLoading: boolean;
20
+ inputRefs: React.MutableRefObject<(HTMLInputElement | null)[]>;
21
+ handleCodeChange: (index: number, value: string) => void;
22
+ handleKeyDown: (
23
+ index: number,
24
+ e: React.KeyboardEvent<HTMLInputElement>
25
+ ) => void;
26
+ handlePaste: (e: React.ClipboardEvent) => void;
27
+ handleSubmit: (e: React.FormEvent) => void;
28
+ handleResend: () => void;
29
+ setError: (error: string | null) => void;
30
+ }
31
+
32
+ export function useVerifyCodeForm(): UseVerifyCodeFormReturn {
33
+ const [code, setCode] = useState<string[]>(["", "", "", "", "", ""]);
34
+ const [error, setError] = useState<string | null>(null);
35
+ const [countdown, setCountdown] = useState(0);
36
+ const [email, setEmail] = useState("");
37
+ const [username, setUsername] = useState("");
38
+ const [isVerifying, setIsVerifying] = useState(false);
39
+ const [isResending, setIsResending] = useState(false);
40
+ const inputRefs = useRef<(HTMLInputElement | null)[]>([]);
41
+
42
+ const { verifyCode, verifyCodeReset, resendCode } = useAuth();
43
+
44
+ // Extract username from URL search params
45
+ useEffect(() => {
46
+ if (typeof window !== "undefined") {
47
+ const params = new URLSearchParams(window.location.search);
48
+ const u = params.get("username") || "";
49
+ setUsername(u);
50
+
51
+ if (u) {
52
+ const storedEmail = localStorage.getItem(`register_email_${u}`);
53
+ if (storedEmail) setEmail(storedEmail);
54
+
55
+ const storedValue = localStorage.getItem(`resend_countdown_${u}`);
56
+ if (storedValue) {
57
+ const expiryTimestamp = parseInt(storedValue, 10);
58
+ const remaining = Math.max(
59
+ 0,
60
+ Math.floor((expiryTimestamp - Date.now()) / 1000)
61
+ );
62
+ if (remaining > 0) setCountdown(remaining);
63
+ }
64
+ }
65
+ }
66
+ }, []);
67
+
68
+ // Countdown timer
69
+ useEffect(() => {
70
+ if (countdown > 0) {
71
+ const timer = setInterval(() => {
72
+ setCountdown((prev) => prev - 1);
73
+ }, 1000);
74
+ return () => clearInterval(timer);
75
+ }
76
+ }, [countdown]);
77
+
78
+ const handleSubmitCode = useCallback(
79
+ async (fullCode: string) => {
80
+ if (!username) {
81
+ setError("Account information not found");
82
+ return;
83
+ }
84
+
85
+ setIsVerifying(true);
86
+ setError(null);
87
+ try {
88
+ const params = new URLSearchParams(window.location.search);
89
+ const mode = params.get("mode");
90
+
91
+ if (mode === "reset") {
92
+ const result = await verifyCodeReset({ username, code: fullCode });
93
+ // Clean up and redirect to reset-password
94
+ localStorage.removeItem(`register_email_${username}`);
95
+ localStorage.removeItem(`resend_countdown_${username}`);
96
+ const session = result?.session;
97
+ window.location.href = session
98
+ ? `/reset-password?session=${encodeURIComponent(session)}`
99
+ : "/reset-password";
100
+ } else {
101
+ await verifyCode({ username, code: fullCode });
102
+ // Clean up and redirect to login
103
+ localStorage.removeItem(`register_email_${username}`);
104
+ localStorage.removeItem(`resend_countdown_${username}`);
105
+ window.location.href = "/login";
106
+ }
107
+ } catch (err) {
108
+ const message =
109
+ err instanceof Error ? err.message : "Verification failed";
110
+ setError(message);
111
+ } finally {
112
+ setIsVerifying(false);
113
+ }
114
+ },
115
+ [username, verifyCode, verifyCodeReset]
116
+ );
117
+
118
+ const handleCodeChange = useCallback(
119
+ (index: number, value: string) => {
120
+ const digit = value.replace(/\D/g, "").slice(-1);
121
+ const newCode = [...code];
122
+ newCode[index] = digit;
123
+ setCode(newCode);
124
+ setError(null);
125
+
126
+ if (digit && index < 5) {
127
+ inputRefs.current[index + 1]?.focus();
128
+ }
129
+
130
+ if (digit && index === 5) {
131
+ const fullCode = newCode.join("");
132
+ if (fullCode.length === 6) {
133
+ handleSubmitCode(fullCode);
134
+ }
135
+ }
136
+ },
137
+ [code, handleSubmitCode]
138
+ );
139
+
140
+ const handleKeyDown = useCallback(
141
+ (index: number, e: React.KeyboardEvent<HTMLInputElement>) => {
142
+ if (e.key === "Backspace" && !code[index] && index > 0) {
143
+ inputRefs.current[index - 1]?.focus();
144
+ }
145
+ },
146
+ [code]
147
+ );
148
+
149
+ const handlePaste = useCallback(
150
+ (e: React.ClipboardEvent) => {
151
+ e.preventDefault();
152
+ const pastedData = e.clipboardData.getData("text");
153
+ const digits = pastedData.replace(/\D/g, "").slice(0, 6);
154
+
155
+ if (digits.length > 0) {
156
+ const newCode = [...code];
157
+ for (let i = 0; i < 6; i++) {
158
+ newCode[i] = digits[i] || "";
159
+ }
160
+ setCode(newCode);
161
+
162
+ const lastIndex = Math.min(digits.length - 1, 5);
163
+ inputRefs.current[lastIndex]?.focus();
164
+
165
+ if (digits.length === 6) {
166
+ handleSubmitCode(digits);
167
+ }
168
+ }
169
+ },
170
+ [code, handleSubmitCode]
171
+ );
172
+
173
+ const handleSubmit = useCallback(
174
+ (e: React.FormEvent) => {
175
+ e.preventDefault();
176
+ const fullCode = code.join("");
177
+ if (fullCode.length !== 6) {
178
+ setError("Please enter the full 6-digit code");
179
+ return;
180
+ }
181
+ handleSubmitCode(fullCode);
182
+ },
183
+ [code, handleSubmitCode]
184
+ );
185
+
186
+ const handleResend = useCallback(async () => {
187
+ if (countdown > 0 || !username) return;
188
+
189
+ setIsResending(true);
190
+ try {
191
+ await resendCode({ username });
192
+ const expiryTimestamp = Date.now() + 60 * 1000;
193
+ localStorage.setItem(
194
+ `resend_countdown_${username}`,
195
+ expiryTimestamp.toString()
196
+ );
197
+ setCountdown(60);
198
+ } catch (err) {
199
+ const message =
200
+ err instanceof Error ? err.message : "Failed to resend code";
201
+ setError(message);
202
+ } finally {
203
+ setIsResending(false);
204
+ }
205
+ }, [countdown, username, resendCode]);
206
+
207
+ return {
208
+ code,
209
+ error,
210
+ countdown,
211
+ email,
212
+ username,
213
+ isVerifying,
214
+ isResending,
215
+ isLoading: isVerifying || isResending,
216
+ inputRefs,
217
+ handleCodeChange,
218
+ handleKeyDown,
219
+ handlePaste,
220
+ handleSubmit,
221
+ handleResend,
222
+ setError,
223
+ };
224
+ }
@@ -14,13 +14,33 @@ export { default as layoutConfig, simpleLayoutConfig } from "./theme.layout";
14
14
  export { default as homePageConfig } from "./pages/home";
15
15
  export { default as aboutPageConfig } from "./pages/about";
16
16
  export { default as showcasePageConfig } from "./pages/showcase";
17
+ export { default as loginPageConfig } from "./pages/login";
18
+ export { default as registerPageConfig } from "./pages/register";
19
+ export { default as forgotPasswordPageConfig } from "./pages/forgot-password";
20
+ export { default as verifyCodePageConfig } from "./pages/verify-code";
21
+ export { default as profilePageConfig } from "./pages/profile";
17
22
 
18
23
  // Page map for dynamic access
19
24
  export const pages = {
20
25
  home: () => import("./pages/home").then((m) => m.default),
21
26
  about: () => import("./pages/about").then((m) => m.default),
22
27
  showcase: () => import("./pages/showcase").then((m) => m.default),
28
+ login: () => import("./pages/login").then((m) => m.default),
29
+ register: () => import("./pages/register").then((m) => m.default),
30
+ "forgot-password": () =>
31
+ import("./pages/forgot-password").then((m) => m.default),
32
+ "verify-code": () => import("./pages/verify-code").then((m) => m.default),
33
+ profile: () => import("./pages/profile").then((m) => m.default),
23
34
  };
24
35
 
25
36
  // Page slugs (for discovery)
26
- export const pageList = ["home", "about", "showcase"] as const;
37
+ export const pageList = [
38
+ "home",
39
+ "about",
40
+ "showcase",
41
+ "login",
42
+ "register",
43
+ "forgot-password",
44
+ "verify-code",
45
+ "profile",
46
+ ] as const;
@@ -0,0 +1,41 @@
1
+ /**
2
+ * My Simple Theme - Forgot Password Page Configuration
3
+ */
4
+
5
+ import type { PageConfig } from "@onexapis/core/types";
6
+
7
+ export const forgotPasswordPageConfig: Omit<
8
+ PageConfig,
9
+ "id" | "createdAt" | "updatedAt"
10
+ > = {
11
+ title: "Forgot Password",
12
+ handle: "forgot-password",
13
+ path: "/forgot-password",
14
+ type: "auth",
15
+ renderMode: "sections",
16
+ themeId: "my-simple",
17
+ editable: true,
18
+ published: true,
19
+ hideHeader: true,
20
+ hideFooter: true,
21
+
22
+ seo: {
23
+ title: "Forgot Password",
24
+ description: "Reset your password",
25
+ },
26
+
27
+ sections: [
28
+ {
29
+ id: "auth-forgot-password-1",
30
+ type: "my-simple-auth-forgot-password",
31
+ template: "default",
32
+ order: 0,
33
+ enabled: true,
34
+ settings: {},
35
+ components: [],
36
+ blocks: [],
37
+ },
38
+ ],
39
+ };
40
+
41
+ export default forgotPasswordPageConfig;