create-brainerce-store 1.27.6 → 1.28.1

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 (26) hide show
  1. package/dist/index.js +120 -22
  2. package/messages/en.json +389 -382
  3. package/messages/he.json +389 -382
  4. package/package.json +46 -46
  5. package/templates/nextjs/base/.env.local.ejs +3 -3
  6. package/templates/nextjs/base/next.config.ts +32 -31
  7. package/templates/nextjs/base/package.json.ejs +2 -1
  8. package/templates/nextjs/base/src/app/api/auth/logout/route.ts +15 -14
  9. package/templates/nextjs/base/src/app/api/auth/oauth-callback/route.ts +66 -59
  10. package/templates/nextjs/base/src/app/api/auth/reset-password/route.ts +76 -77
  11. package/templates/nextjs/base/src/app/api/store/[...path]/route.ts +229 -198
  12. package/templates/nextjs/base/src/app/checkout/page.tsx +3 -1
  13. package/templates/nextjs/base/src/app/layout.tsx.ejs +31 -13
  14. package/templates/nextjs/base/src/app/products/[slug]/product-client-section.tsx +501 -501
  15. package/templates/nextjs/base/src/app/reset-password/page.tsx +138 -131
  16. package/templates/nextjs/base/src/components/auth/register-form.tsx +245 -232
  17. package/templates/nextjs/base/src/components/checkout/checkout-form.tsx +416 -415
  18. package/templates/nextjs/base/src/components/checkout/payment-step.tsx +656 -592
  19. package/templates/nextjs/base/src/components/seo/product-json-ld.tsx +88 -72
  20. package/templates/nextjs/base/src/lib/csrf.ts +11 -0
  21. package/templates/nextjs/base/src/lib/nonce.ts +10 -0
  22. package/templates/nextjs/base/src/lib/safe-redirect.ts +45 -0
  23. package/templates/nextjs/base/src/lib/sanitize-html.ts +93 -0
  24. package/templates/nextjs/base/src/lib/validation.ts +37 -0
  25. package/templates/nextjs/base/src/middleware.ts.ejs +103 -8
  26. package/templates/nextjs/base/tsconfig.tsbuildinfo +1 -0
@@ -1,131 +1,138 @@
1
- 'use client';
2
-
3
- import { useState } from 'react';
4
- import { useRouter, Link } from '@/lib/navigation';
5
- import { proxyResetPassword } from '@/lib/auth';
6
- import { LoadingSpinner } from '@/components/shared/loading-spinner';
7
- import { useTranslations } from '@/lib/translations';
8
-
9
- export default function ResetPasswordPage() {
10
- const router = useRouter();
11
- const t = useTranslations('auth');
12
-
13
- const [newPassword, setNewPassword] = useState('');
14
- const [confirmPassword, setConfirmPassword] = useState('');
15
- const [loading, setLoading] = useState(false);
16
- const [error, setError] = useState<string | null>(null);
17
- const [success, setSuccess] = useState(false);
18
-
19
- async function handleSubmit(e: React.FormEvent) {
20
- e.preventDefault();
21
- if (loading) return;
22
-
23
- if (newPassword !== confirmPassword) {
24
- setError(t('passwordsMustMatch'));
25
- return;
26
- }
27
-
28
- try {
29
- setLoading(true);
30
- setError(null);
31
- await proxyResetPassword(newPassword);
32
- setSuccess(true);
33
- setTimeout(() => router.push('/login'), 2000);
34
- } catch (err) {
35
- const message =
36
- err instanceof Error ? err.message : 'Something went wrong. Please try again.';
37
- setError(message);
38
- } finally {
39
- setLoading(false);
40
- }
41
- }
42
-
43
- return (
44
- <div className="flex min-h-[60vh] items-center justify-center px-4 py-12">
45
- <div className="w-full max-w-md space-y-6">
46
- <div className="text-center">
47
- <h1 className="text-foreground text-2xl font-bold">{t('resetPasswordTitle')}</h1>
48
- <p className="text-muted-foreground mt-1 text-sm">{t('resetPasswordSubtitle')}</p>
49
- </div>
50
-
51
- {error && (
52
- <div className="bg-destructive/10 border-destructive/20 text-destructive space-y-2 rounded-lg border px-4 py-3 text-sm">
53
- <p>{error}</p>
54
- <Link
55
- href="/forgot-password"
56
- className="text-primary block font-medium hover:underline"
57
- >
58
- {t('sendResetLink')}
59
- </Link>
60
- </div>
61
- )}
62
-
63
- {success ? (
64
- <div className="rounded-lg border border-green-200 bg-green-50 px-4 py-3 text-sm text-green-800 dark:border-green-800 dark:bg-green-950/30 dark:text-green-300">
65
- {t('passwordResetSuccess')}
66
- </div>
67
- ) : (
68
- <form onSubmit={handleSubmit} className="space-y-4">
69
- <div>
70
- <label
71
- htmlFor="new-password"
72
- className="text-foreground mb-1.5 block text-sm font-medium"
73
- >
74
- {t('newPassword')}
75
- </label>
76
- <input
77
- id="new-password"
78
- type="password"
79
- required
80
- minLength={8}
81
- value={newPassword}
82
- onChange={(e) => setNewPassword(e.target.value)}
83
- placeholder={t('newPasswordPlaceholder')}
84
- autoComplete="new-password"
85
- className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
86
- />
87
- </div>
88
-
89
- <div>
90
- <label
91
- htmlFor="confirm-password"
92
- className="text-foreground mb-1.5 block text-sm font-medium"
93
- >
94
- {t('confirmPassword')}
95
- </label>
96
- <input
97
- id="confirm-password"
98
- type="password"
99
- required
100
- minLength={8}
101
- value={confirmPassword}
102
- onChange={(e) => setConfirmPassword(e.target.value)}
103
- placeholder={t('confirmPasswordPlaceholder')}
104
- autoComplete="new-password"
105
- className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
106
- />
107
- </div>
108
-
109
- <button
110
- type="submit"
111
- disabled={loading}
112
- className="bg-primary text-primary-foreground flex h-10 w-full items-center justify-center gap-2 rounded text-sm font-medium transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50"
113
- >
114
- {loading ? (
115
- <>
116
- <LoadingSpinner
117
- size="sm"
118
- className="border-primary-foreground/30 border-t-primary-foreground"
119
- />
120
- {t('resettingPassword')}
121
- </>
122
- ) : (
123
- t('resetPassword')
124
- )}
125
- </button>
126
- </form>
127
- )}
128
- </div>
129
- </div>
130
- );
131
- }
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+ import { useRouter, Link } from '@/lib/navigation';
5
+ import { proxyResetPassword } from '@/lib/auth';
6
+ import { LoadingSpinner } from '@/components/shared/loading-spinner';
7
+ import { useTranslations } from '@/lib/translations';
8
+ import { getPasswordError } from '@/lib/validation';
9
+
10
+ export default function ResetPasswordPage() {
11
+ const router = useRouter();
12
+ const t = useTranslations('auth');
13
+
14
+ const [newPassword, setNewPassword] = useState('');
15
+ const [confirmPassword, setConfirmPassword] = useState('');
16
+ const [loading, setLoading] = useState(false);
17
+ const [error, setError] = useState<string | null>(null);
18
+ const [success, setSuccess] = useState(false);
19
+
20
+ async function handleSubmit(e: React.FormEvent) {
21
+ e.preventDefault();
22
+ if (loading) return;
23
+
24
+ const pwCode = getPasswordError(newPassword);
25
+ if (pwCode) {
26
+ setError(t(pwCode));
27
+ return;
28
+ }
29
+
30
+ if (newPassword !== confirmPassword) {
31
+ setError(t('passwordsMustMatch'));
32
+ return;
33
+ }
34
+
35
+ try {
36
+ setLoading(true);
37
+ setError(null);
38
+ await proxyResetPassword(newPassword);
39
+ setSuccess(true);
40
+ setTimeout(() => router.push('/login'), 2000);
41
+ } catch (err) {
42
+ const message =
43
+ err instanceof Error ? err.message : 'Something went wrong. Please try again.';
44
+ setError(message);
45
+ } finally {
46
+ setLoading(false);
47
+ }
48
+ }
49
+
50
+ return (
51
+ <div className="flex min-h-[60vh] items-center justify-center px-4 py-12">
52
+ <div className="w-full max-w-md space-y-6">
53
+ <div className="text-center">
54
+ <h1 className="text-foreground text-2xl font-bold">{t('resetPasswordTitle')}</h1>
55
+ <p className="text-muted-foreground mt-1 text-sm">{t('resetPasswordSubtitle')}</p>
56
+ </div>
57
+
58
+ {error && (
59
+ <div className="bg-destructive/10 border-destructive/20 text-destructive space-y-2 rounded-lg border px-4 py-3 text-sm">
60
+ <p>{error}</p>
61
+ <Link
62
+ href="/forgot-password"
63
+ className="text-primary block font-medium hover:underline"
64
+ >
65
+ {t('sendResetLink')}
66
+ </Link>
67
+ </div>
68
+ )}
69
+
70
+ {success ? (
71
+ <div className="rounded-lg border border-green-200 bg-green-50 px-4 py-3 text-sm text-green-800 dark:border-green-800 dark:bg-green-950/30 dark:text-green-300">
72
+ {t('passwordResetSuccess')}
73
+ </div>
74
+ ) : (
75
+ <form onSubmit={handleSubmit} className="space-y-4">
76
+ <div>
77
+ <label
78
+ htmlFor="new-password"
79
+ className="text-foreground mb-1.5 block text-sm font-medium"
80
+ >
81
+ {t('newPassword')}
82
+ </label>
83
+ <input
84
+ id="new-password"
85
+ type="password"
86
+ required
87
+ minLength={8}
88
+ value={newPassword}
89
+ onChange={(e) => setNewPassword(e.target.value)}
90
+ placeholder={t('newPasswordPlaceholder')}
91
+ autoComplete="new-password"
92
+ className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
93
+ />
94
+ </div>
95
+
96
+ <div>
97
+ <label
98
+ htmlFor="confirm-password"
99
+ className="text-foreground mb-1.5 block text-sm font-medium"
100
+ >
101
+ {t('confirmPassword')}
102
+ </label>
103
+ <input
104
+ id="confirm-password"
105
+ type="password"
106
+ required
107
+ minLength={8}
108
+ value={confirmPassword}
109
+ onChange={(e) => setConfirmPassword(e.target.value)}
110
+ placeholder={t('confirmPasswordPlaceholder')}
111
+ autoComplete="new-password"
112
+ className="border-border bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-10 w-full rounded border px-3 text-sm focus:outline-none focus:ring-2"
113
+ />
114
+ </div>
115
+
116
+ <button
117
+ type="submit"
118
+ disabled={loading}
119
+ className="bg-primary text-primary-foreground flex h-10 w-full items-center justify-center gap-2 rounded text-sm font-medium transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50"
120
+ >
121
+ {loading ? (
122
+ <>
123
+ <LoadingSpinner
124
+ size="sm"
125
+ className="border-primary-foreground/30 border-t-primary-foreground"
126
+ />
127
+ {t('resettingPassword')}
128
+ </>
129
+ ) : (
130
+ t('resetPassword')
131
+ )}
132
+ </button>
133
+ </form>
134
+ )}
135
+ </div>
136
+ </div>
137
+ );
138
+ }