@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.
- package/README.md +70 -3
- package/bin/add.js +30 -15
- package/bin/analyze.js +66 -1
- package/bin/cli.js +149 -70
- package/bin/doctor.js +21 -12
- package/bin/export.js +69 -20
- package/bin/fresh.js +6 -1
- package/bin/i18n-extract.js +3 -10
- package/bin/i18n-translate.js +15 -24
- package/bin/make-block.js +24 -0
- package/bin/make-editable.js +166 -0
- package/bin/make-form.js +131 -0
- package/bin/make-island.js +11 -0
- package/bin/make-loop.js +147 -0
- package/bin/make-mail.js +27 -0
- package/bin/make-page.js +83 -0
- package/bin/make-post-type.js +68 -29
- package/bin/make-sandbox.js +609 -0
- package/bin/make-section.js +221 -0
- package/bin/make-shell.js +375 -0
- package/bin/repair.js +14 -26
- package/bin/seed.js +119 -0
- package/bin/sync-routes.js +107 -85
- package/lib/adapters/html-adapter.js +13 -3
- package/lib/adapters/stub-adapter.js +10 -2
- package/lib/add-component.js +153 -92
- package/lib/asset-loader.js +333 -1
- package/lib/assets/asset-graph.js +432 -0
- package/lib/assets/asset-pipeline.js +125 -0
- package/lib/assets/diagnostics-report.js +345 -0
- package/lib/assets/external-fetcher.js +173 -0
- package/lib/assets/font-orchestrator.js +348 -0
- package/lib/assets/font-usage-scanner.js +242 -0
- package/lib/assets/image-optimizer.js +229 -0
- package/lib/assets/index.js +51 -0
- package/lib/assets/preload-generator.js +70 -0
- package/lib/assets/public-url.js +153 -0
- package/lib/block-authoring-help.js +11 -0
- package/lib/blocks/ast-parser.js +67 -0
- package/lib/blocks/discover-blocks.js +146 -0
- package/lib/blocks/editor-scope.js +733 -0
- package/lib/blocks/editor-transpiler.js +1229 -0
- package/lib/blocks/index.js +2838 -0
- package/lib/blocks/php-transpiler.js +4928 -0
- package/lib/blocks/scanner.js +1487 -0
- package/lib/blocks/shared-utils.js +290 -0
- package/lib/blocks/source-sanitize.js +1449 -0
- package/lib/blueprints.js +77 -5
- package/lib/build-assets.js +38 -33
- package/lib/collect-page-template-routes.js +102 -0
- package/lib/collect-static-routes.js +175 -0
- package/lib/diagnostics.js +58 -33
- package/lib/export-theme.js +84 -5
- package/lib/extract-template-content.js +90 -0
- package/lib/forms-preview.js +42 -0
- package/lib/functions/cpt-routing.js +69 -0
- package/lib/functions/forms.js +2461 -0
- package/lib/functions/hydration-enqueuer.js +400 -0
- package/lib/functions/index.js +1623 -0
- package/lib/functions/load-menus.js +112 -0
- package/lib/functions/load-translations.js +148 -0
- package/lib/functions/rest-endpoints.js +2923 -0
- package/lib/functions/routing.js +765 -0
- package/lib/functions/seed-mock-data.js +392 -0
- package/lib/functions/seed-products.js +481 -0
- package/lib/functions/settings-page.js +273 -0
- package/lib/functions/theme-setup.js +494 -0
- package/lib/generate-theme.js +2076 -303
- package/lib/hydration/editable-schemas.js +332 -0
- package/lib/hydration/enter-hidden-initial.js +65 -0
- package/lib/hydration/form-schemas.js +227 -0
- package/lib/hydration/index.js +12 -0
- package/lib/hydration/is-interactive.js +951 -0
- package/lib/hydration/island-split.js +1231 -0
- package/lib/hydration/islands-scanner.js +599 -0
- package/lib/hydration/resolve-island-chunk.js +103 -0
- package/lib/hydration/resolve-island-component.js +52 -0
- package/lib/hydration/rollup-inputs.js +81 -0
- package/lib/hydration/root-class-extractor.js +220 -0
- package/lib/hydration/scan-app-providers.js +154 -0
- package/lib/hydration/static-lint.js +382 -0
- package/lib/hydration/transform.js +257 -0
- package/lib/hydration/uses-block-area.js +49 -0
- package/lib/hydration/utils.js +119 -0
- package/lib/i18n/translation-cache.js +141 -0
- package/lib/icon-registry.js +72 -0
- package/lib/index.d.ts +324 -8
- package/lib/index.js +3 -2
- package/lib/load-config.js +338 -144
- package/lib/mail-templates.js +37 -0
- package/lib/markup-processor.js +483 -92
- package/lib/node-runtime.js +7 -0
- package/lib/page-config-plugin.js +84 -0
- package/lib/php-builders.js +383 -42
- package/lib/react-adapter.js +1053 -246
- package/lib/registration-metadata.js +11 -0
- package/lib/render-theme.mts +1410 -543
- package/lib/route-layout.js +76 -0
- package/lib/template-discovery.js +58 -0
- package/lib/theme-compatibility.js +32 -0
- package/lib/validate-export.js +51 -2
- package/lib/validate.js +27 -5
- package/lib/virtual-plugin.js +319 -0
- package/lib/walkthrough.md +26 -0
- package/package.json +17 -5
- package/templates/PresetsStyle.tsx +1 -1
- package/templates/auth/cms/email-logs.json +9 -0
- package/templates/auth/cms/menus.json +11 -0
- package/templates/auth/cms/mock-data.json +123 -0
- package/templates/auth/cms/roles.json +7 -0
- package/templates/auth/cms/sessions.json +1 -0
- package/templates/auth/cms/site-settings.json +28 -0
- package/templates/auth/cms/translations.json +4 -0
- package/templates/auth/cms/users.json +46 -0
- package/templates/auth/components/dashboard-view-wrapper.tsx +168 -0
- package/templates/auth/components/forgot-password-form-wrapper.tsx +141 -0
- package/templates/auth/components/login-form-wrapper.tsx +300 -0
- package/templates/auth/components/reset-password-form-wrapper.tsx +190 -0
- package/templates/auth/components/signup-form-wrapper.tsx +257 -0
- package/templates/auth/components/verify-email-view-wrapper.tsx +265 -0
- package/templates/auth/pages/DashboardPage.tsx +12 -0
- package/templates/auth/pages/ForgotPasswordPage.tsx +11 -0
- package/templates/auth/pages/LoginPage.tsx +11 -0
- package/templates/auth/pages/ResetPasswordPage.tsx +11 -0
- package/templates/auth/pages/SignUpPage.tsx +11 -0
- package/templates/auth/pages/VerifyEmailPage.tsx +11 -0
- package/templates/auth/ui/button.tsx +57 -0
- package/templates/auth/ui/card.tsx +76 -0
- package/templates/auth/ui/field.tsx +242 -0
- package/templates/auth/ui/input.tsx +22 -0
- package/templates/auth/ui/label.tsx +24 -0
- package/templates/auth/ui/separator.tsx +31 -0
- package/templates/forgewp-config.ts +70 -3
- package/templates/menus.json +12 -10
- package/templates/mock-data.json +122 -433
- package/templates/products.json +5 -0
- package/templates/roles.json +7 -0
- package/templates/sessions.json +1 -0
- package/templates/users.json +38 -0
- package/templates/wordpress.tsx +1835 -1297
- package/bin/make-template.js +0 -145
- package/lib/block-compiler.js +0 -552
- package/lib/functions-builder.js +0 -2044
- package/lib/hydration-scanner.js +0 -821
|
@@ -0,0 +1,257 @@
|
|
|
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
|
+
} from '@/components/ui/card';
|
|
12
|
+
import {
|
|
13
|
+
Field,
|
|
14
|
+
FieldDescription,
|
|
15
|
+
FieldGroup,
|
|
16
|
+
FieldLabel,
|
|
17
|
+
FieldError,
|
|
18
|
+
} from '@/components/ui/field';
|
|
19
|
+
import { Input } from '@/components/ui/input';
|
|
20
|
+
import { AlertTriangleIcon } from 'lucide-react';
|
|
21
|
+
|
|
22
|
+
export default function SignupFormWrapper({ ...props }: React.ComponentProps<typeof Card>) {
|
|
23
|
+
const { register, error, emailVerificationEnabled, initializing } = useWpAuth();
|
|
24
|
+
const user = useWpUser();
|
|
25
|
+
const [_, setLocation] = useLocation();
|
|
26
|
+
|
|
27
|
+
const [username, setUsername] = React.useState('');
|
|
28
|
+
const [email, setEmail] = React.useState('');
|
|
29
|
+
const [password, setPassword] = React.useState('');
|
|
30
|
+
const [confirmPassword, setConfirmPassword] = React.useState('');
|
|
31
|
+
const [submitting, setSubmitting] = React.useState(false);
|
|
32
|
+
|
|
33
|
+
const loginUrl = useWpPageLink('login-page', '/login');
|
|
34
|
+
const dashboardUrl = useWpPageLink('account-page', '/account');
|
|
35
|
+
const verifyEmailUrl = useWpPageLink('verify-email-page', '/verify-email');
|
|
36
|
+
|
|
37
|
+
const [errors, setErrors] = React.useState<{
|
|
38
|
+
username?: string;
|
|
39
|
+
email?: string;
|
|
40
|
+
password?: string;
|
|
41
|
+
confirmPassword?: string;
|
|
42
|
+
general?: string;
|
|
43
|
+
}>({});
|
|
44
|
+
|
|
45
|
+
const errorContainerRef = React.useRef<HTMLDivElement>(null);
|
|
46
|
+
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
if (user) {
|
|
49
|
+
setLocation(dashboardUrl);
|
|
50
|
+
}
|
|
51
|
+
}, [user, setLocation, dashboardUrl]);
|
|
52
|
+
|
|
53
|
+
// Smooth scroll to top error if a general or backend error occurs
|
|
54
|
+
React.useEffect(() => {
|
|
55
|
+
if (errors.general || error) {
|
|
56
|
+
errorContainerRef.current?.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
57
|
+
}
|
|
58
|
+
}, [errors.general, error]);
|
|
59
|
+
|
|
60
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
setErrors({});
|
|
63
|
+
|
|
64
|
+
const trimmedUsername = username.trim();
|
|
65
|
+
const trimmedEmail = email.trim();
|
|
66
|
+
const trimmedPassword = password.trim();
|
|
67
|
+
const trimmedConfirm = confirmPassword.trim();
|
|
68
|
+
|
|
69
|
+
const newErrors: typeof errors = {};
|
|
70
|
+
|
|
71
|
+
if (!trimmedUsername) {
|
|
72
|
+
newErrors.username = 'Username is required.';
|
|
73
|
+
}
|
|
74
|
+
if (!trimmedEmail) {
|
|
75
|
+
newErrors.email = 'Email address is required.';
|
|
76
|
+
}
|
|
77
|
+
if (!trimmedPassword) {
|
|
78
|
+
newErrors.password = 'Password is required.';
|
|
79
|
+
} else if (trimmedPassword.length < 8) {
|
|
80
|
+
newErrors.password = 'Password must be at least 8 characters long.';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (trimmedPassword && trimmedPassword !== trimmedConfirm) {
|
|
84
|
+
newErrors.confirmPassword = 'Passwords do not match.';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (Object.keys(newErrors).length > 0) {
|
|
88
|
+
setErrors(newErrors);
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
setSubmitting(true);
|
|
93
|
+
try {
|
|
94
|
+
const ok = await register(trimmedUsername, trimmedEmail, trimmedPassword);
|
|
95
|
+
if (ok) {
|
|
96
|
+
if (typeof window !== 'undefined') {
|
|
97
|
+
const redirectDest = emailVerificationEnabled
|
|
98
|
+
? `${verifyEmailUrl}?registered=true&email=${encodeURIComponent(trimmedEmail)}`
|
|
99
|
+
: dashboardUrl;
|
|
100
|
+
setLocation(redirectDest);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
} catch (err: any) {
|
|
104
|
+
const msg = err.message || '';
|
|
105
|
+
if (msg.toLowerCase().includes('username')) {
|
|
106
|
+
setErrors({ username: msg });
|
|
107
|
+
} else if (msg.toLowerCase().includes('email')) {
|
|
108
|
+
setErrors({ email: msg });
|
|
109
|
+
} else {
|
|
110
|
+
setErrors({ general: msg || 'Registration failed. Please try again.' });
|
|
111
|
+
}
|
|
112
|
+
} finally {
|
|
113
|
+
setSubmitting(false);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
if (initializing || user) {
|
|
118
|
+
return (
|
|
119
|
+
<div className='flex flex-col items-center justify-center p-8 min-h-[300px]'>
|
|
120
|
+
<div className='w-12 h-12 border-4 border-primary border-t-transparent rounded-full animate-spin'></div>
|
|
121
|
+
<p className='text-slate-500 font-mono text-sm mt-4'>
|
|
122
|
+
Checking session...
|
|
123
|
+
</p>
|
|
124
|
+
</div>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return (
|
|
129
|
+
<Card {...props}>
|
|
130
|
+
<CardHeader>
|
|
131
|
+
<CardTitle>Create an account</CardTitle>
|
|
132
|
+
<CardDescription>
|
|
133
|
+
Enter your information below to create your account
|
|
134
|
+
</CardDescription>
|
|
135
|
+
</CardHeader>
|
|
136
|
+
<CardContent>
|
|
137
|
+
<form onSubmit={handleSubmit}>
|
|
138
|
+
<FieldGroup>
|
|
139
|
+
{(errors.general || error) && (
|
|
140
|
+
<div
|
|
141
|
+
ref={errorContainerRef}
|
|
142
|
+
className='bg-red-50 text-red-600 border border-red-200 text-sm p-3 rounded-md font-medium flex items-start gap-2'
|
|
143
|
+
>
|
|
144
|
+
<AlertTriangleIcon className='h-4 w-4 shrink-0 mt-0.5' />
|
|
145
|
+
<span>{errors.general || error}</span>
|
|
146
|
+
</div>
|
|
147
|
+
)}
|
|
148
|
+
<Field data-invalid={!!errors.username}>
|
|
149
|
+
<FieldLabel htmlFor='username'>Username</FieldLabel>
|
|
150
|
+
<Input
|
|
151
|
+
id='username'
|
|
152
|
+
type='text'
|
|
153
|
+
placeholder='johndoe'
|
|
154
|
+
value={username}
|
|
155
|
+
onChange={(e) => setUsername(e.target.value)}
|
|
156
|
+
disabled={submitting}
|
|
157
|
+
required
|
|
158
|
+
autoComplete="username"
|
|
159
|
+
/>
|
|
160
|
+
{errors.username && (
|
|
161
|
+
<FieldError className='text-red-500'>
|
|
162
|
+
{errors.username}
|
|
163
|
+
</FieldError>
|
|
164
|
+
)}
|
|
165
|
+
</Field>
|
|
166
|
+
<Field data-invalid={!!errors.email}>
|
|
167
|
+
<FieldLabel htmlFor='email'>Email</FieldLabel>
|
|
168
|
+
<Input
|
|
169
|
+
id='email'
|
|
170
|
+
type='email'
|
|
171
|
+
placeholder='m@example.com'
|
|
172
|
+
value={email}
|
|
173
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
174
|
+
disabled={submitting}
|
|
175
|
+
required
|
|
176
|
+
autoComplete="email"
|
|
177
|
+
/>
|
|
178
|
+
{errors.email ? (
|
|
179
|
+
<FieldError className='text-red-500'>{errors.email}</FieldError>
|
|
180
|
+
) : (
|
|
181
|
+
<FieldDescription>
|
|
182
|
+
We will use this email for account verification and updates.
|
|
183
|
+
</FieldDescription>
|
|
184
|
+
)}
|
|
185
|
+
</Field>
|
|
186
|
+
<Field data-invalid={!!errors.password}>
|
|
187
|
+
<FieldLabel htmlFor='password'>Password</FieldLabel>
|
|
188
|
+
<Input
|
|
189
|
+
id='password'
|
|
190
|
+
type='password'
|
|
191
|
+
placeholder='••••••••'
|
|
192
|
+
value={password}
|
|
193
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
194
|
+
disabled={submitting}
|
|
195
|
+
required
|
|
196
|
+
autoComplete="new-password"
|
|
197
|
+
/>
|
|
198
|
+
{errors.password ? (
|
|
199
|
+
<FieldError className='text-red-500'>
|
|
200
|
+
{errors.password}
|
|
201
|
+
</FieldError>
|
|
202
|
+
) : (
|
|
203
|
+
<FieldDescription>
|
|
204
|
+
Must be at least 8 characters long.
|
|
205
|
+
</FieldDescription>
|
|
206
|
+
)}
|
|
207
|
+
</Field>
|
|
208
|
+
<Field data-invalid={!!errors.confirmPassword}>
|
|
209
|
+
<FieldLabel htmlFor='confirm-password'>
|
|
210
|
+
Confirm Password
|
|
211
|
+
</FieldLabel>
|
|
212
|
+
<Input
|
|
213
|
+
id='confirm-password'
|
|
214
|
+
type='password'
|
|
215
|
+
placeholder='••••••••'
|
|
216
|
+
value={confirmPassword}
|
|
217
|
+
onChange={(e) => setConfirmPassword(e.target.value)}
|
|
218
|
+
disabled={submitting}
|
|
219
|
+
required
|
|
220
|
+
autoComplete="new-password"
|
|
221
|
+
/>
|
|
222
|
+
{errors.confirmPassword ? (
|
|
223
|
+
<FieldError className='text-red-500'>
|
|
224
|
+
{errors.confirmPassword}
|
|
225
|
+
</FieldError>
|
|
226
|
+
) : (
|
|
227
|
+
<FieldDescription>
|
|
228
|
+
Please confirm your password.
|
|
229
|
+
</FieldDescription>
|
|
230
|
+
)}
|
|
231
|
+
</Field>
|
|
232
|
+
<FieldGroup>
|
|
233
|
+
<Field>
|
|
234
|
+
<Button
|
|
235
|
+
type='submit'
|
|
236
|
+
disabled={submitting}
|
|
237
|
+
className='w-full cursor-pointer'
|
|
238
|
+
>
|
|
239
|
+
{submitting ? 'Creating Account...' : 'Create Account'}
|
|
240
|
+
</Button>
|
|
241
|
+
<FieldDescription className='text-center'>
|
|
242
|
+
Already have an account?{' '}
|
|
243
|
+
<a
|
|
244
|
+
href={loginUrl}
|
|
245
|
+
className='underline'
|
|
246
|
+
>
|
|
247
|
+
Sign in
|
|
248
|
+
</a>
|
|
249
|
+
</FieldDescription>
|
|
250
|
+
</Field>
|
|
251
|
+
</FieldGroup>
|
|
252
|
+
</FieldGroup>
|
|
253
|
+
</form>
|
|
254
|
+
</CardContent>
|
|
255
|
+
</Card>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useWpAuth } 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 { MailOpenIcon, CheckCircle2Icon, AlertTriangleIcon, Loader2Icon } from 'lucide-react';
|
|
14
|
+
|
|
15
|
+
export default function VerifyEmailViewWrapper() {
|
|
16
|
+
const { verifyEmail, logout, error, initializing, resendVerificationEmail } = useWpAuth();
|
|
17
|
+
const [_, setLocation] = useLocation();
|
|
18
|
+
const loginUrl = useWpPageLink('login-page', '/login');
|
|
19
|
+
const dashboardUrl = useWpPageLink('account-page', '/account');
|
|
20
|
+
|
|
21
|
+
const [status, setStatus] = React.useState<'pending' | 'verifying' | 'success' | 'failed'>('pending');
|
|
22
|
+
const [errorMessage, setErrorMessage] = React.useState<string | null>(null);
|
|
23
|
+
const hasRunRef = React.useRef(false);
|
|
24
|
+
|
|
25
|
+
const [resendEmail, setResendEmail] = React.useState('');
|
|
26
|
+
const [resendStatus, setResendStatus] = React.useState<'idle' | 'sending' | 'success' | 'failed'>('idle');
|
|
27
|
+
const [resendErrorMessage, setResendErrorMessage] = React.useState<string | null>(null);
|
|
28
|
+
const [showResendForm, setShowResendForm] = React.useState(false);
|
|
29
|
+
|
|
30
|
+
const handleResend = async (e?: React.FormEvent) => {
|
|
31
|
+
if (e) e.preventDefault();
|
|
32
|
+
setResendStatus('sending');
|
|
33
|
+
setResendErrorMessage(null);
|
|
34
|
+
try {
|
|
35
|
+
const ok = await resendVerificationEmail(resendEmail);
|
|
36
|
+
if (ok) {
|
|
37
|
+
setResendStatus('success');
|
|
38
|
+
} else {
|
|
39
|
+
setResendStatus('failed');
|
|
40
|
+
setResendErrorMessage(error || 'Failed to resend verification email.');
|
|
41
|
+
}
|
|
42
|
+
} catch (err: any) {
|
|
43
|
+
setResendStatus('failed');
|
|
44
|
+
setResendErrorMessage(err.message || 'An unexpected error occurred.');
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
React.useEffect(() => {
|
|
49
|
+
const searchParams = new URLSearchParams(window.location.search);
|
|
50
|
+
const userIdStr = searchParams.get('userId');
|
|
51
|
+
const token = searchParams.get('token');
|
|
52
|
+
const emailParam = searchParams.get('email');
|
|
53
|
+
|
|
54
|
+
if (emailParam) {
|
|
55
|
+
setResendEmail(emailParam);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (userIdStr && token) {
|
|
59
|
+
if (hasRunRef.current) return;
|
|
60
|
+
hasRunRef.current = true;
|
|
61
|
+
|
|
62
|
+
setStatus('verifying');
|
|
63
|
+
const userId = parseInt(userIdStr, 10);
|
|
64
|
+
verifyEmail(userId, token)
|
|
65
|
+
.then((ok) => {
|
|
66
|
+
if (ok) {
|
|
67
|
+
setStatus('success');
|
|
68
|
+
setTimeout(() => {
|
|
69
|
+
setLocation(dashboardUrl);
|
|
70
|
+
}, 2500);
|
|
71
|
+
} else {
|
|
72
|
+
setStatus('failed');
|
|
73
|
+
setErrorMessage('Verification failed. The token may be expired or invalid.');
|
|
74
|
+
}
|
|
75
|
+
})
|
|
76
|
+
.catch((err) => {
|
|
77
|
+
setStatus('failed');
|
|
78
|
+
setErrorMessage(err.message || 'An unexpected error occurred.');
|
|
79
|
+
});
|
|
80
|
+
} else {
|
|
81
|
+
setStatus('pending');
|
|
82
|
+
}
|
|
83
|
+
}, [verifyEmail, setLocation, dashboardUrl]);
|
|
84
|
+
|
|
85
|
+
if (initializing) {
|
|
86
|
+
return (
|
|
87
|
+
<div className='flex flex-col items-center justify-center p-8 min-h-[300px]'>
|
|
88
|
+
<div className='w-12 h-12 border-4 border-primary border-t-transparent rounded-full animate-spin'></div>
|
|
89
|
+
<p className='text-slate-500 font-mono text-sm mt-4'>
|
|
90
|
+
Checking session...
|
|
91
|
+
</p>
|
|
92
|
+
</div>
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<Card>
|
|
98
|
+
<CardHeader className="text-center">
|
|
99
|
+
<div className="flex justify-center mb-4">
|
|
100
|
+
{status === 'pending' && (
|
|
101
|
+
<div className="p-3 bg-blue-50 text-blue-600 rounded-full">
|
|
102
|
+
<MailOpenIcon className="h-10 w-10 animate-pulse" />
|
|
103
|
+
</div>
|
|
104
|
+
)}
|
|
105
|
+
{status === 'verifying' && (
|
|
106
|
+
<div className="p-3 bg-zinc-100 text-zinc-600 rounded-full">
|
|
107
|
+
<Loader2Icon className="h-10 w-10 animate-spin" />
|
|
108
|
+
</div>
|
|
109
|
+
)}
|
|
110
|
+
{status === 'success' && (
|
|
111
|
+
<div className="p-3 bg-green-50 text-green-600 rounded-full">
|
|
112
|
+
<CheckCircle2Icon className="h-10 w-10" />
|
|
113
|
+
</div>
|
|
114
|
+
)}
|
|
115
|
+
{status === 'failed' && (
|
|
116
|
+
<div className="p-3 bg-red-50 text-red-600 rounded-full">
|
|
117
|
+
<AlertTriangleIcon className="h-10 w-10" />
|
|
118
|
+
</div>
|
|
119
|
+
)}
|
|
120
|
+
</div>
|
|
121
|
+
|
|
122
|
+
<CardTitle>
|
|
123
|
+
{status === 'pending' && 'Check Your Email'}
|
|
124
|
+
{status === 'verifying' && 'Verifying Email'}
|
|
125
|
+
{status === 'success' && 'Account Verified'}
|
|
126
|
+
{status === 'failed' && 'Verification Failed'}
|
|
127
|
+
</CardTitle>
|
|
128
|
+
|
|
129
|
+
<CardDescription>
|
|
130
|
+
{status === 'pending' && 'We sent a verification link to your email address.'}
|
|
131
|
+
{status === 'verifying' && 'Please wait while we validate your activation token.'}
|
|
132
|
+
{status === 'success' && 'Your email address has been successfully verified!'}
|
|
133
|
+
{status === 'failed' && 'We could not verify your email address.'}
|
|
134
|
+
</CardDescription>
|
|
135
|
+
</CardHeader>
|
|
136
|
+
|
|
137
|
+
<CardContent className="px-8 py-4 text-center text-sm text-zinc-600">
|
|
138
|
+
{status === 'pending' && (
|
|
139
|
+
<div className="flex flex-col gap-4 text-center">
|
|
140
|
+
<p className="leading-relaxed">
|
|
141
|
+
Thank you for signing up! Please check your email inbox and click on the verification link to activate your account.
|
|
142
|
+
Once verified, you will be automatically logged in.
|
|
143
|
+
</p>
|
|
144
|
+
|
|
145
|
+
<div className="border-t border-slate-100 pt-4 mt-2">
|
|
146
|
+
{resendStatus === 'success' ? (
|
|
147
|
+
<div className="bg-green-50 text-green-700 border border-green-200 text-xs p-3 rounded-md font-medium text-left">
|
|
148
|
+
Verification email successfully resent to <strong>{resendEmail}</strong>!
|
|
149
|
+
</div>
|
|
150
|
+
) : (
|
|
151
|
+
<div className="flex flex-col gap-3">
|
|
152
|
+
{!showResendForm && resendEmail ? (
|
|
153
|
+
<div>
|
|
154
|
+
<p className="text-xs text-zinc-500 mb-2">
|
|
155
|
+
Didn't get the email? We can resend it to <strong>{resendEmail}</strong>.
|
|
156
|
+
</p>
|
|
157
|
+
<Button
|
|
158
|
+
variant="secondary"
|
|
159
|
+
size="sm"
|
|
160
|
+
disabled={resendStatus === 'sending'}
|
|
161
|
+
onClick={() => handleResend()}
|
|
162
|
+
className="cursor-pointer"
|
|
163
|
+
>
|
|
164
|
+
{resendStatus === 'sending' ? 'Resending...' : 'Resend Verification Link'}
|
|
165
|
+
</Button>
|
|
166
|
+
<button
|
|
167
|
+
onClick={() => setShowResendForm(true)}
|
|
168
|
+
className="text-xs text-zinc-400 underline block mx-auto mt-2 hover:text-zinc-600 cursor-pointer"
|
|
169
|
+
>
|
|
170
|
+
Use a different email address
|
|
171
|
+
</button>
|
|
172
|
+
</div>
|
|
173
|
+
) : (
|
|
174
|
+
<form onSubmit={handleResend} className="flex flex-col gap-2 max-w-sm mx-auto w-full text-left">
|
|
175
|
+
<p className="text-xs text-zinc-500 text-center mb-1">
|
|
176
|
+
Enter your email address to request a new verification link.
|
|
177
|
+
</p>
|
|
178
|
+
{resendStatus === 'failed' && resendErrorMessage && (
|
|
179
|
+
<div className="bg-red-50 text-red-600 border border-red-200 text-[11px] p-2 rounded-md font-medium flex items-start gap-1.5 mb-1.5">
|
|
180
|
+
<AlertTriangleIcon className="h-3.5 w-3.5 shrink-0 mt-0.5" />
|
|
181
|
+
<span>{resendErrorMessage}</span>
|
|
182
|
+
</div>
|
|
183
|
+
)}
|
|
184
|
+
<div className="flex gap-2">
|
|
185
|
+
<input
|
|
186
|
+
type="email"
|
|
187
|
+
placeholder="name@example.com"
|
|
188
|
+
value={resendEmail}
|
|
189
|
+
onChange={(e) => setResendEmail(e.target.value)}
|
|
190
|
+
className="flex h-9 w-full rounded-md border border-zinc-200 bg-white px-3 py-1 text-sm shadow-xs transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-zinc-400 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-zinc-950 disabled:cursor-not-allowed disabled:opacity-50"
|
|
191
|
+
required
|
|
192
|
+
disabled={resendStatus === 'sending'}
|
|
193
|
+
/>
|
|
194
|
+
<Button
|
|
195
|
+
type="submit"
|
|
196
|
+
size="sm"
|
|
197
|
+
disabled={resendStatus === 'sending'}
|
|
198
|
+
className="cursor-pointer shrink-0"
|
|
199
|
+
>
|
|
200
|
+
{resendStatus === 'sending' ? 'Sending...' : 'Send'}
|
|
201
|
+
</Button>
|
|
202
|
+
</div>
|
|
203
|
+
{resendEmail && (
|
|
204
|
+
<button
|
|
205
|
+
type="button"
|
|
206
|
+
onClick={() => setShowResendForm(false)}
|
|
207
|
+
className="text-xs text-zinc-400 underline block mx-auto mt-1.5 hover:text-zinc-600 cursor-pointer"
|
|
208
|
+
>
|
|
209
|
+
Cancel
|
|
210
|
+
</button>
|
|
211
|
+
)}
|
|
212
|
+
</form>
|
|
213
|
+
)}
|
|
214
|
+
</div>
|
|
215
|
+
)}
|
|
216
|
+
</div>
|
|
217
|
+
</div>
|
|
218
|
+
)}
|
|
219
|
+
|
|
220
|
+
{status === 'verifying' && (
|
|
221
|
+
<p className="leading-relaxed">
|
|
222
|
+
Communicating with the secure backend server. This process should take only a moment.
|
|
223
|
+
</p>
|
|
224
|
+
)}
|
|
225
|
+
|
|
226
|
+
{status === 'success' && (
|
|
227
|
+
<p className="text-green-600 font-medium">
|
|
228
|
+
Redirecting you to your account dashboard in 3 seconds...
|
|
229
|
+
</p>
|
|
230
|
+
)}
|
|
231
|
+
|
|
232
|
+
{status === 'failed' && (
|
|
233
|
+
<div className="bg-red-50 text-red-600 border border-red-100 rounded-lg p-3 font-medium text-xs flex items-start gap-2 text-left">
|
|
234
|
+
<AlertTriangleIcon className="h-4 w-4 shrink-0 mt-0.5" />
|
|
235
|
+
<span>{errorMessage}</span>
|
|
236
|
+
</div>
|
|
237
|
+
)}
|
|
238
|
+
</CardContent>
|
|
239
|
+
|
|
240
|
+
<CardFooter className="px-8 pb-8 pt-4 flex flex-col gap-2">
|
|
241
|
+
{(status === 'pending' || status === 'failed') && (
|
|
242
|
+
<Button
|
|
243
|
+
variant="outline"
|
|
244
|
+
className="w-full cursor-pointer hover:bg-zinc-50 border-zinc-200"
|
|
245
|
+
onClick={async () => {
|
|
246
|
+
await logout();
|
|
247
|
+
setLocation(loginUrl);
|
|
248
|
+
}}
|
|
249
|
+
>
|
|
250
|
+
Return to Sign In
|
|
251
|
+
</Button>
|
|
252
|
+
)}
|
|
253
|
+
|
|
254
|
+
{status === 'success' && (
|
|
255
|
+
<Button
|
|
256
|
+
className="w-full cursor-pointer"
|
|
257
|
+
onClick={() => setLocation(dashboardUrl)}
|
|
258
|
+
>
|
|
259
|
+
Go to Dashboard Now
|
|
260
|
+
</Button>
|
|
261
|
+
)}
|
|
262
|
+
</CardFooter>
|
|
263
|
+
</Card>
|
|
264
|
+
);
|
|
265
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ForgotPasswordFormWrapper from "@/components/forgot-password-form-wrapper";
|
|
2
|
+
|
|
3
|
+
export default function ForgotPasswordPage() {
|
|
4
|
+
return (
|
|
5
|
+
<div className='flex min-h-svh w-full items-center justify-center p-6 md:p-10 bg-[#fafafa]'>
|
|
6
|
+
<div className='w-full max-w-md'>
|
|
7
|
+
<ForgotPasswordFormWrapper />
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import LoginFormWrapper from "@/components/login-form-wrapper";
|
|
2
|
+
|
|
3
|
+
export default function LoginPage() {
|
|
4
|
+
return (
|
|
5
|
+
<div className='flex min-h-svh w-full items-center justify-center p-6 md:p-10 bg-[#fafafa]'>
|
|
6
|
+
<div className='w-full max-w-sm'>
|
|
7
|
+
<LoginFormWrapper />
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import ResetPasswordFormWrapper from "@/components/reset-password-form-wrapper";
|
|
2
|
+
|
|
3
|
+
export default function ResetPasswordPage() {
|
|
4
|
+
return (
|
|
5
|
+
<div className='flex min-h-svh w-full items-center justify-center p-6 md:p-10 bg-[#fafafa]'>
|
|
6
|
+
<div className='w-full max-w-md'>
|
|
7
|
+
<ResetPasswordFormWrapper />
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import SignupFormWrapper from "@/components/signup-form-wrapper";
|
|
2
|
+
|
|
3
|
+
export default function SignUpPage() {
|
|
4
|
+
return (
|
|
5
|
+
<div className='flex min-h-svh w-full items-center justify-center p-6 md:p-10 bg-[#fafafa]'>
|
|
6
|
+
<div className='w-full max-w-sm'>
|
|
7
|
+
<SignupFormWrapper />
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import VerifyEmailViewWrapper from "@/components/verify-email-view-wrapper";
|
|
2
|
+
|
|
3
|
+
export default function VerifyEmailPage() {
|
|
4
|
+
return (
|
|
5
|
+
<div className='flex min-h-svh w-full items-center justify-center p-6 md:p-10 bg-[#fafafa]'>
|
|
6
|
+
<div className='w-full max-w-md'>
|
|
7
|
+
<VerifyEmailViewWrapper />
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import { Slot } from "@radix-ui/react-slot"
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority"
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils"
|
|
6
|
+
|
|
7
|
+
const buttonVariants = cva(
|
|
8
|
+
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0",
|
|
9
|
+
{
|
|
10
|
+
variants: {
|
|
11
|
+
variant: {
|
|
12
|
+
default:
|
|
13
|
+
"bg-primary text-primary-foreground shadow hover:bg-primary/90",
|
|
14
|
+
destructive:
|
|
15
|
+
"bg-destructive text-destructive-foreground shadow-sm hover:bg-destructive/90",
|
|
16
|
+
outline:
|
|
17
|
+
"border border-input bg-background shadow-sm hover:bg-accent hover:text-accent-foreground",
|
|
18
|
+
secondary:
|
|
19
|
+
"bg-secondary text-secondary-foreground shadow-sm hover:bg-secondary/80",
|
|
20
|
+
ghost: "hover:bg-accent hover:text-accent-foreground",
|
|
21
|
+
link: "text-primary underline-offset-4 hover:underline",
|
|
22
|
+
},
|
|
23
|
+
size: {
|
|
24
|
+
default: "h-9 px-4 py-2",
|
|
25
|
+
sm: "h-8 rounded-md px-3 text-xs",
|
|
26
|
+
lg: "h-10 rounded-md px-8",
|
|
27
|
+
icon: "h-9 w-9",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
defaultVariants: {
|
|
31
|
+
variant: "default",
|
|
32
|
+
size: "default",
|
|
33
|
+
},
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
export interface ButtonProps
|
|
38
|
+
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
|
|
39
|
+
VariantProps<typeof buttonVariants> {
|
|
40
|
+
asChild?: boolean
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
|
|
44
|
+
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
45
|
+
const Comp = asChild ? Slot : "button"
|
|
46
|
+
return (
|
|
47
|
+
<Comp
|
|
48
|
+
className={cn(buttonVariants({ variant, size, className }))}
|
|
49
|
+
ref={ref}
|
|
50
|
+
{...props}
|
|
51
|
+
/>
|
|
52
|
+
)
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
Button.displayName = "Button"
|
|
56
|
+
|
|
57
|
+
export { Button, buttonVariants }
|