@forgewp/compiler 0.4.2 → 0.4.4

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 (144) hide show
  1. package/README.md +70 -3
  2. package/bin/add.js +30 -15
  3. package/bin/analyze.js +66 -1
  4. package/bin/cli.js +149 -70
  5. package/bin/doctor.js +21 -12
  6. package/bin/export.js +69 -20
  7. package/bin/fresh.js +6 -1
  8. package/bin/i18n-extract.js +3 -10
  9. package/bin/i18n-translate.js +15 -24
  10. package/bin/make-block.js +24 -0
  11. package/bin/make-editable.js +166 -0
  12. package/bin/make-form.js +131 -0
  13. package/bin/make-island.js +11 -0
  14. package/bin/make-loop.js +147 -0
  15. package/bin/make-mail.js +27 -0
  16. package/bin/make-page.js +83 -0
  17. package/bin/make-post-type.js +68 -29
  18. package/bin/make-sandbox.js +609 -0
  19. package/bin/make-section.js +221 -0
  20. package/bin/make-shell.js +375 -0
  21. package/bin/repair.js +14 -26
  22. package/bin/seed.js +119 -0
  23. package/bin/sync-routes.js +107 -85
  24. package/lib/adapters/html-adapter.js +13 -3
  25. package/lib/adapters/stub-adapter.js +10 -2
  26. package/lib/add-component.js +153 -92
  27. package/lib/asset-loader.js +333 -1
  28. package/lib/assets/asset-graph.js +432 -0
  29. package/lib/assets/asset-pipeline.js +125 -0
  30. package/lib/assets/diagnostics-report.js +345 -0
  31. package/lib/assets/external-fetcher.js +173 -0
  32. package/lib/assets/font-orchestrator.js +348 -0
  33. package/lib/assets/font-usage-scanner.js +242 -0
  34. package/lib/assets/image-optimizer.js +229 -0
  35. package/lib/assets/index.js +51 -0
  36. package/lib/assets/preload-generator.js +70 -0
  37. package/lib/assets/public-url.js +153 -0
  38. package/lib/block-authoring-help.js +11 -0
  39. package/lib/blocks/ast-parser.js +67 -0
  40. package/lib/blocks/discover-blocks.js +146 -0
  41. package/lib/blocks/editor-scope.js +733 -0
  42. package/lib/blocks/editor-transpiler.js +1229 -0
  43. package/lib/blocks/index.js +2838 -0
  44. package/lib/blocks/php-transpiler.js +4928 -0
  45. package/lib/blocks/scanner.js +1487 -0
  46. package/lib/blocks/shared-utils.js +290 -0
  47. package/lib/blocks/source-sanitize.js +1449 -0
  48. package/lib/blueprints.js +77 -5
  49. package/lib/build-assets.js +38 -33
  50. package/lib/collect-page-template-routes.js +102 -0
  51. package/lib/collect-static-routes.js +175 -0
  52. package/lib/diagnostics.js +58 -33
  53. package/lib/export-theme.js +84 -5
  54. package/lib/extract-template-content.js +90 -0
  55. package/lib/forms-preview.js +42 -0
  56. package/lib/functions/cpt-routing.js +69 -0
  57. package/lib/functions/forms.js +2461 -0
  58. package/lib/functions/hydration-enqueuer.js +400 -0
  59. package/lib/functions/index.js +1623 -0
  60. package/lib/functions/load-menus.js +112 -0
  61. package/lib/functions/load-translations.js +148 -0
  62. package/lib/functions/rest-endpoints.js +2923 -0
  63. package/lib/functions/routing.js +765 -0
  64. package/lib/functions/seed-mock-data.js +392 -0
  65. package/lib/functions/seed-products.js +481 -0
  66. package/lib/functions/settings-page.js +273 -0
  67. package/lib/functions/theme-setup.js +494 -0
  68. package/lib/generate-theme.js +2076 -303
  69. package/lib/hydration/editable-schemas.js +332 -0
  70. package/lib/hydration/enter-hidden-initial.js +65 -0
  71. package/lib/hydration/form-schemas.js +227 -0
  72. package/lib/hydration/index.js +12 -0
  73. package/lib/hydration/is-interactive.js +951 -0
  74. package/lib/hydration/island-split.js +1231 -0
  75. package/lib/hydration/islands-scanner.js +599 -0
  76. package/lib/hydration/resolve-island-chunk.js +103 -0
  77. package/lib/hydration/resolve-island-component.js +52 -0
  78. package/lib/hydration/rollup-inputs.js +81 -0
  79. package/lib/hydration/root-class-extractor.js +220 -0
  80. package/lib/hydration/scan-app-providers.js +154 -0
  81. package/lib/hydration/static-lint.js +382 -0
  82. package/lib/hydration/transform.js +257 -0
  83. package/lib/hydration/uses-block-area.js +49 -0
  84. package/lib/hydration/utils.js +119 -0
  85. package/lib/i18n/translation-cache.js +141 -0
  86. package/lib/icon-registry.js +72 -0
  87. package/lib/index.d.ts +324 -8
  88. package/lib/index.js +3 -2
  89. package/lib/load-config.js +338 -144
  90. package/lib/mail-templates.js +37 -0
  91. package/lib/markup-processor.js +483 -92
  92. package/lib/node-runtime.js +7 -0
  93. package/lib/page-config-plugin.js +84 -0
  94. package/lib/php-builders.js +383 -42
  95. package/lib/react-adapter.js +1053 -246
  96. package/lib/registration-metadata.js +11 -0
  97. package/lib/render-theme.mts +1410 -543
  98. package/lib/route-layout.js +76 -0
  99. package/lib/template-discovery.js +58 -0
  100. package/lib/theme-compatibility.js +32 -0
  101. package/lib/validate-export.js +51 -2
  102. package/lib/validate.js +27 -5
  103. package/lib/virtual-plugin.js +319 -0
  104. package/lib/walkthrough.md +26 -0
  105. package/package.json +17 -5
  106. package/templates/PresetsStyle.tsx +1 -1
  107. package/templates/auth/cms/email-logs.json +9 -0
  108. package/templates/auth/cms/menus.json +11 -0
  109. package/templates/auth/cms/mock-data.json +123 -0
  110. package/templates/auth/cms/roles.json +7 -0
  111. package/templates/auth/cms/sessions.json +1 -0
  112. package/templates/auth/cms/site-settings.json +28 -0
  113. package/templates/auth/cms/translations.json +4 -0
  114. package/templates/auth/cms/users.json +46 -0
  115. package/templates/auth/components/dashboard-view-wrapper.tsx +168 -0
  116. package/templates/auth/components/forgot-password-form-wrapper.tsx +141 -0
  117. package/templates/auth/components/login-form-wrapper.tsx +300 -0
  118. package/templates/auth/components/reset-password-form-wrapper.tsx +190 -0
  119. package/templates/auth/components/signup-form-wrapper.tsx +257 -0
  120. package/templates/auth/components/verify-email-view-wrapper.tsx +265 -0
  121. package/templates/auth/pages/DashboardPage.tsx +12 -0
  122. package/templates/auth/pages/ForgotPasswordPage.tsx +11 -0
  123. package/templates/auth/pages/LoginPage.tsx +11 -0
  124. package/templates/auth/pages/ResetPasswordPage.tsx +11 -0
  125. package/templates/auth/pages/SignUpPage.tsx +11 -0
  126. package/templates/auth/pages/VerifyEmailPage.tsx +11 -0
  127. package/templates/auth/ui/button.tsx +57 -0
  128. package/templates/auth/ui/card.tsx +76 -0
  129. package/templates/auth/ui/field.tsx +242 -0
  130. package/templates/auth/ui/input.tsx +22 -0
  131. package/templates/auth/ui/label.tsx +24 -0
  132. package/templates/auth/ui/separator.tsx +31 -0
  133. package/templates/forgewp-config.ts +70 -3
  134. package/templates/menus.json +12 -10
  135. package/templates/mock-data.json +122 -433
  136. package/templates/products.json +5 -0
  137. package/templates/roles.json +7 -0
  138. package/templates/sessions.json +1 -0
  139. package/templates/users.json +38 -0
  140. package/templates/wordpress.tsx +1835 -1297
  141. package/bin/make-template.js +0 -145
  142. package/lib/block-compiler.js +0 -552
  143. package/lib/functions-builder.js +0 -2044
  144. package/lib/hydration-scanner.js +0 -821
@@ -0,0 +1,300 @@
1
+ import * as React from 'react';
2
+ import { useWpAuth, useWpUser } from '@forgewp/auth';
3
+ import { useWpPageLink, useLocation } from '@forgewp/react';
4
+ import { cn } from '@/lib/utils';
5
+ import { Button } from '@/components/ui/button';
6
+ import {
7
+ Card,
8
+ CardContent,
9
+ CardDescription,
10
+ CardHeader,
11
+ CardTitle,
12
+ } from '@/components/ui/card';
13
+ import {
14
+ Field,
15
+ FieldGroup,
16
+ FieldLabel,
17
+ FieldDescription,
18
+ } from '@/components/ui/field';
19
+ import { Input } from '@/components/ui/input';
20
+ import { AlertTriangleIcon, MailIcon, CheckCircle2Icon, RefreshCwIcon } from 'lucide-react';
21
+
22
+ export default function LoginFormWrapper({
23
+ className,
24
+ ...props
25
+ }: React.ComponentProps<'div'>) {
26
+ const { login, error, loginField, initializing, resendVerificationEmail } = useWpAuth();
27
+ const user = useWpUser();
28
+ const [_, setLocation] = useLocation();
29
+
30
+ const [username, setUsername] = React.useState('');
31
+ const [password, setPassword] = React.useState('');
32
+ const [localError, setLocalError] = React.useState<string | null>(null);
33
+ const [unverifiedNotice, setUnverifiedNotice] = React.useState<string | null>(null);
34
+ const [submitting, setSubmitting] = React.useState(false);
35
+
36
+ const [resendStatus, setResendStatus] = React.useState<'idle' | 'sending' | 'success' | 'failed'>('idle');
37
+ const [resendErrorMessage, setResendErrorMessage] = React.useState<string | null>(null);
38
+ const [resendCooldown, setResendCooldown] = React.useState(0);
39
+ const cooldownTimerRef = React.useRef<any>(null);
40
+
41
+ const forgotPasswordUrl = useWpPageLink('forgot-password-page', '/forgot-password');
42
+ const signUpUrl = useWpPageLink('sign-up-page', '/signup');
43
+ const dashboardUrl = useWpPageLink('account-page', '/account');
44
+
45
+ React.useEffect(() => {
46
+ return () => {
47
+ if (cooldownTimerRef.current) {
48
+ clearInterval(cooldownTimerRef.current);
49
+ }
50
+ };
51
+ }, []);
52
+
53
+ React.useEffect(() => {
54
+ if (user) {
55
+ setLocation(dashboardUrl);
56
+ }
57
+ }, [user, setLocation, dashboardUrl]);
58
+
59
+ React.useEffect(() => {
60
+ const activeErr = localError || error;
61
+ if (activeErr && /verif/i.test(activeErr)) {
62
+ setUnverifiedNotice(activeErr);
63
+ }
64
+ }, [localError, error]);
65
+
66
+ const handleResendVerification = async () => {
67
+ const input = username.trim();
68
+ if (!input) {
69
+ setResendErrorMessage('Please enter your username or email in the login field first.');
70
+ setResendStatus('failed');
71
+ return;
72
+ }
73
+
74
+ setResendStatus('sending');
75
+ setResendErrorMessage(null);
76
+ try {
77
+ const ok = await resendVerificationEmail(input);
78
+ if (ok) {
79
+ setResendStatus('success');
80
+ // Ensure unverifiedNotice stays active so the box never collapses
81
+ if (!unverifiedNotice) {
82
+ setUnverifiedNotice('Please verify your email address before logging in.');
83
+ }
84
+ // 60-second cooldown before they can request again
85
+ setResendCooldown(60);
86
+ if (cooldownTimerRef.current) {
87
+ clearInterval(cooldownTimerRef.current);
88
+ }
89
+ cooldownTimerRef.current = setInterval(() => {
90
+ setResendCooldown((prev: number) => {
91
+ if (prev <= 1) {
92
+ clearInterval(cooldownTimerRef.current);
93
+ cooldownTimerRef.current = null;
94
+ return 0;
95
+ }
96
+ return prev - 1;
97
+ });
98
+ }, 1000);
99
+ } else {
100
+ setResendStatus('failed');
101
+ setResendErrorMessage(error || 'Failed to resend verification email.');
102
+ }
103
+ } catch (err: any) {
104
+ setResendStatus('failed');
105
+ setResendErrorMessage(err.message || 'An unexpected error occurred.');
106
+ }
107
+ };
108
+
109
+ const handleSubmit = async (e: React.FormEvent) => {
110
+ e.preventDefault();
111
+ setLocalError(null);
112
+ setUnverifiedNotice(null);
113
+ setResendStatus('idle');
114
+ setResendErrorMessage(null);
115
+
116
+ const trimmedUsername = username.trim();
117
+ const trimmedPassword = password.trim();
118
+
119
+ if (!trimmedUsername || !trimmedPassword) {
120
+ setLocalError('Please enter both username/email and password.');
121
+ return;
122
+ }
123
+
124
+ setSubmitting(true);
125
+ try {
126
+ await login(trimmedUsername, trimmedPassword, dashboardUrl);
127
+ } catch (err: any) {
128
+ const msg = err.message || 'Login failed. Please try again.';
129
+ setLocalError(msg);
130
+ if (/verif/i.test(msg)) {
131
+ setUnverifiedNotice(msg);
132
+ }
133
+ } finally {
134
+ setSubmitting(false);
135
+ }
136
+ };
137
+
138
+ if (initializing || user) {
139
+ return (
140
+ <div className='flex flex-col items-center justify-center p-8 min-h-[300px]'>
141
+ <div className='w-12 h-12 border-4 border-primary border-t-transparent rounded-full animate-spin'></div>
142
+ <p className='text-slate-500 font-mono text-sm mt-4'>
143
+ Checking session...
144
+ </p>
145
+ </div>
146
+ );
147
+ }
148
+
149
+ const activeRawError = localError || error;
150
+ const isUnverified = Boolean(unverifiedNotice || (activeRawError && /verif/i.test(activeRawError)));
151
+ const displayedError = unverifiedNotice || activeRawError;
152
+
153
+ return (
154
+ <div
155
+ className={cn('flex flex-col gap-6', className)}
156
+ {...props}
157
+ >
158
+ <Card>
159
+ <CardHeader>
160
+ <CardTitle>Login to your account</CardTitle>
161
+ <CardDescription>
162
+ Enter your username or email below to login to your account
163
+ </CardDescription>
164
+ </CardHeader>
165
+ <CardContent>
166
+ <form onSubmit={handleSubmit}>
167
+ <FieldGroup>
168
+ {isUnverified ? (
169
+ resendStatus === 'success' ? (
170
+ <div className="bg-emerald-50 text-emerald-950 border border-emerald-200/80 text-sm p-4 rounded-lg flex flex-col gap-3 shadow-xs">
171
+ <div className="flex items-start gap-3">
172
+ <div className="p-1.5 bg-emerald-100 rounded-md text-emerald-700 shrink-0">
173
+ <CheckCircle2Icon className="h-4 w-4" />
174
+ </div>
175
+ <div className="flex flex-col gap-1 flex-1">
176
+ <span className="font-semibold text-emerald-950 text-sm">Verification Link Sent</span>
177
+ <p className="text-emerald-800 text-xs leading-relaxed">
178
+ A fresh verification link has been sent to your email. Please check your inbox (and spam folder).
179
+ </p>
180
+ </div>
181
+ </div>
182
+
183
+ <div className="flex items-center gap-1.5 flex-wrap text-xs text-emerald-900 pt-2.5 border-t border-emerald-200/60">
184
+ <span>Didn&apos;t receive it?</span>
185
+ {resendCooldown > 0 ? (
186
+ <span className="text-emerald-700/90 font-medium">
187
+ Resend available in {resendCooldown}s
188
+ </span>
189
+ ) : (
190
+ <button
191
+ type="button"
192
+ onClick={handleResendVerification}
193
+ className="font-semibold underline underline-offset-2 hover:text-emerald-950 cursor-pointer inline-flex items-center gap-1 transition-colors"
194
+ >
195
+ Resend verification email
196
+ </button>
197
+ )}
198
+ </div>
199
+ </div>
200
+ ) : (
201
+ <div className="bg-amber-50 text-amber-950 border border-amber-200/80 text-sm p-4 rounded-lg flex flex-col gap-3 shadow-xs">
202
+ <div className="flex items-start gap-3">
203
+ <div className="p-1.5 bg-amber-100 rounded-md text-amber-700 shrink-0">
204
+ <MailIcon className="h-4 w-4" />
205
+ </div>
206
+ <div className="flex flex-col gap-1 flex-1">
207
+ <span className="font-semibold text-amber-950 text-sm">Email Verification Required</span>
208
+ <p className="text-amber-800 text-xs leading-relaxed">
209
+ {displayedError || 'Please verify your email address before logging in.'}
210
+ </p>
211
+ </div>
212
+ </div>
213
+
214
+ <div className="flex flex-col gap-2 pt-2.5 border-t border-amber-200/60">
215
+ <div className="flex items-center gap-1.5 flex-wrap text-xs text-amber-900">
216
+ <span>Need a new link sent to your inbox?</span>
217
+ {resendCooldown > 0 ? (
218
+ <span className="text-amber-800/80 font-medium">
219
+ Resend available in {resendCooldown}s
220
+ </span>
221
+ ) : (
222
+ <button
223
+ type="button"
224
+ disabled={resendStatus === 'sending'}
225
+ onClick={handleResendVerification}
226
+ className="font-semibold underline underline-offset-2 hover:text-amber-950 disabled:opacity-50 cursor-pointer inline-flex items-center gap-1 transition-colors"
227
+ >
228
+ {resendStatus === 'sending' ? (
229
+ <><RefreshCwIcon className="h-3 w-3 animate-spin inline" /> Sending...</>
230
+ ) : (
231
+ 'Resend verification email'
232
+ )}
233
+ </button>
234
+ )}
235
+ </div>
236
+ {resendStatus === 'failed' && resendErrorMessage && (
237
+ <span className="text-red-600 text-xs font-medium bg-red-50 p-2 rounded border border-red-100">
238
+ {resendErrorMessage}
239
+ </span>
240
+ )}
241
+ </div>
242
+ </div>
243
+ )
244
+ ) : activeRawError ? (
245
+ <div className="bg-red-50 text-red-700 border border-red-200 text-sm p-3.5 rounded-lg flex items-start gap-2.5 shadow-xs">
246
+ <AlertTriangleIcon className="h-4 w-4 shrink-0 text-red-600 mt-0.5" />
247
+ <span className="font-medium text-xs leading-relaxed">{activeRawError}</span>
248
+ </div>
249
+ ) : null}
250
+ <Field>
251
+ <FieldLabel htmlFor='username'>
252
+ {loginField === 'usernameOnly' ? 'Username' : loginField === 'emailOnly' ? 'Email Address' : 'Username or Email'}
253
+ </FieldLabel>
254
+ <Input
255
+ id='username'
256
+ type='text'
257
+ placeholder={loginField === 'usernameOnly' ? 'username' : loginField === 'emailOnly' ? 'user@example.com' : 'admin / subscriber'}
258
+ value={username}
259
+ onChange={(e) => setUsername(e.target.value)}
260
+ disabled={submitting}
261
+ required
262
+ autoComplete="username"
263
+ />
264
+ </Field>
265
+ <Field>
266
+ <div className='flex items-center'>
267
+ <FieldLabel htmlFor='password'>Password</FieldLabel>
268
+ <a
269
+ href={forgotPasswordUrl}
270
+ className='ml-auto inline-block text-sm underline-offset-4 hover:underline'
271
+ >
272
+ Forgot your password?
273
+ </a>
274
+ </div>
275
+ <Input
276
+ id='password'
277
+ type='password'
278
+ placeholder='••••••••'
279
+ value={password}
280
+ onChange={(e) => setPassword(e.target.value)}
281
+ disabled={submitting}
282
+ required
283
+ autoComplete="current-password"
284
+ />
285
+ </Field>
286
+ <Field>
287
+ <Button type='submit' disabled={submitting} className="w-full cursor-pointer">
288
+ {submitting ? 'Logging in...' : 'Login'}
289
+ </Button>
290
+ <FieldDescription className='text-center'>
291
+ Don&apos;t have an account? <a href={signUpUrl} className="underline">Sign up</a>
292
+ </FieldDescription>
293
+ </Field>
294
+ </FieldGroup>
295
+ </form>
296
+ </CardContent>
297
+ </Card>
298
+ </div>
299
+ );
300
+ }
@@ -0,0 +1,190 @@
1
+ import * as React from 'react';
2
+ import { useWpAuth, useWpUser } from '@forgewp/auth';
3
+ import { useWpPageLink, useLocation } from '@forgewp/react';
4
+ import { Button } from '@/components/ui/button';
5
+ import {
6
+ Card,
7
+ CardContent,
8
+ CardDescription,
9
+ CardHeader,
10
+ CardTitle,
11
+ CardFooter,
12
+ } from '@/components/ui/card';
13
+ import {
14
+ Field,
15
+ FieldGroup,
16
+ FieldLabel,
17
+ } from '@/components/ui/field';
18
+ import { Input } from '@/components/ui/input';
19
+ import { AlertTriangleIcon, ArrowLeftIcon } from 'lucide-react';
20
+
21
+ export default function ResetPasswordFormWrapper() {
22
+ const { resetPassword, error, initializing } = useWpAuth();
23
+ const user = useWpUser();
24
+ const [_, setLocation] = useLocation();
25
+ const loginUrl = useWpPageLink('login-page', '/login');
26
+ const dashboardUrl = useWpPageLink('account-page', '/account');
27
+
28
+ React.useEffect(() => {
29
+ if (user) {
30
+ setLocation(dashboardUrl);
31
+ }
32
+ }, [user, setLocation, dashboardUrl]);
33
+
34
+ const [key, setKey] = React.useState('');
35
+ const [login, setLogin] = React.useState('');
36
+ const [password, setPassword] = React.useState('');
37
+ const [confirmPassword, setConfirmPassword] = React.useState('');
38
+ const [success, setSuccess] = React.useState(false);
39
+ const [localError, setLocalError] = React.useState<string | null>(null);
40
+ const [missingParams, setMissingParams] = React.useState(false);
41
+ const [submitting, setSubmitting] = React.useState(false);
42
+
43
+ React.useEffect(() => {
44
+ const searchParams = new URLSearchParams(window.location.search);
45
+ const keyParam = searchParams.get('key');
46
+ const loginParam = searchParams.get('login');
47
+
48
+ if (!keyParam || !loginParam) {
49
+ setMissingParams(true);
50
+ } else {
51
+ setKey(keyParam);
52
+ setLogin(loginParam);
53
+ }
54
+ }, []);
55
+
56
+ const handleSubmit = async (e: React.FormEvent) => {
57
+ e.preventDefault();
58
+ setLocalError(null);
59
+
60
+ const trimmedPassword = password.trim();
61
+ const trimmedConfirmPassword = confirmPassword.trim();
62
+
63
+ if (!trimmedPassword) {
64
+ setLocalError('Please enter a new password.');
65
+ return;
66
+ }
67
+
68
+ if (trimmedPassword !== trimmedConfirmPassword) {
69
+ setLocalError('Passwords do not match.');
70
+ return;
71
+ }
72
+
73
+ if (trimmedPassword.length < 6) {
74
+ setLocalError('Password must be at least 6 characters long.');
75
+ return;
76
+ }
77
+
78
+ setSubmitting(true);
79
+ try {
80
+ const ok = await resetPassword(login, key, trimmedPassword);
81
+ if (ok) {
82
+ setSuccess(true);
83
+ setTimeout(() => {
84
+ setLocation(loginUrl);
85
+ }, 3000);
86
+ }
87
+ } catch (err: any) {
88
+ setLocalError(err.message || 'An unexpected error occurred.');
89
+ } finally {
90
+ setSubmitting(false);
91
+ }
92
+ };
93
+
94
+ if (initializing) {
95
+ return (
96
+ <div className='flex flex-col items-center justify-center p-8 min-h-[300px]'>
97
+ <div className='w-12 h-12 border-4 border-primary border-t-transparent rounded-full animate-spin'></div>
98
+ <p className='text-slate-500 font-mono text-sm mt-4'>
99
+ Checking session...
100
+ </p>
101
+ </div>
102
+ );
103
+ }
104
+
105
+ return (
106
+ <Card>
107
+ <CardHeader>
108
+ <CardTitle>
109
+ {success
110
+ ? 'Password Reset Complete'
111
+ : missingParams
112
+ ? 'Invalid Reset Link'
113
+ : 'Reset Your Password'}
114
+ </CardTitle>
115
+ <CardDescription>
116
+ {success
117
+ ? 'Your password has been successfully updated.'
118
+ : missingParams
119
+ ? 'This password reset link is invalid or incomplete.'
120
+ : `Choose a new secure password for ${login}.`}
121
+ </CardDescription>
122
+ </CardHeader>
123
+
124
+ <CardContent className="px-8 py-4">
125
+ {success ? (
126
+ <p className="text-green-600 font-medium text-center text-sm leading-relaxed">
127
+ Redirecting you to the sign in page in 3 seconds...
128
+ </p>
129
+ ) : missingParams ? (
130
+ <div className="text-zinc-600 text-sm leading-relaxed text-center">
131
+ <p className="mb-4">
132
+ The password reset link is missing required verification parameters. Please request a new link.
133
+ </p>
134
+ </div>
135
+ ) : (
136
+ <form onSubmit={handleSubmit}>
137
+ <FieldGroup>
138
+ {(localError || error) && (
139
+ <div className="bg-red-50 text-red-600 border border-red-200 text-sm p-3 rounded-md font-medium flex items-start gap-2">
140
+ <AlertTriangleIcon className="h-4 w-4 shrink-0 mt-0.5" />
141
+ <span>{localError || error}</span>
142
+ </div>
143
+ )}
144
+ <Field>
145
+ <FieldLabel htmlFor="password">New Password</FieldLabel>
146
+ <Input
147
+ id="password"
148
+ type="password"
149
+ placeholder="••••••••"
150
+ value={password}
151
+ onChange={(e) => setPassword(e.target.value)}
152
+ disabled={submitting}
153
+ required
154
+ />
155
+ </Field>
156
+ <Field>
157
+ <FieldLabel htmlFor="confirmPassword">Confirm Password</FieldLabel>
158
+ <Input
159
+ id="confirmPassword"
160
+ type="password"
161
+ placeholder="••••••••"
162
+ value={confirmPassword}
163
+ onChange={(e) => setConfirmPassword(e.target.value)}
164
+ disabled={submitting}
165
+ required
166
+ />
167
+ </Field>
168
+ <Field>
169
+ <Button type="submit" disabled={submitting} className="w-full cursor-pointer">
170
+ {submitting ? 'Resetting password...' : 'Update Password'}
171
+ </Button>
172
+ </Field>
173
+ </FieldGroup>
174
+ </form>
175
+ )}
176
+ </CardContent>
177
+
178
+ <CardFooter className="px-8 pb-8 pt-4 flex flex-col gap-2">
179
+ <Button
180
+ variant="outline"
181
+ className="w-full cursor-pointer hover:bg-zinc-50 border-zinc-200 flex items-center justify-center gap-2"
182
+ onClick={() => setLocation(loginUrl)}
183
+ >
184
+ <ArrowLeftIcon className="h-4 w-4" />
185
+ Return to Sign In
186
+ </Button>
187
+ </CardFooter>
188
+ </Card>
189
+ );
190
+ }