create-brainerce-store 1.4.1 → 1.5.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 (37) hide show
  1. package/dist/index.js +1 -1
  2. package/messages/en.json +9 -1
  3. package/messages/he.json +9 -1
  4. package/package.json +1 -1
  5. package/templates/nextjs/base/src/app/account/page.tsx +8 -4
  6. package/templates/nextjs/base/src/app/auth/callback/page.tsx +90 -90
  7. package/templates/nextjs/base/src/app/cart/page.tsx +110 -110
  8. package/templates/nextjs/base/src/app/checkout/page.tsx +614 -614
  9. package/templates/nextjs/base/src/app/login/page.tsx +58 -58
  10. package/templates/nextjs/base/src/app/order-confirmation/page.tsx +193 -193
  11. package/templates/nextjs/base/src/app/page.tsx +98 -98
  12. package/templates/nextjs/base/src/app/products/[slug]/page.tsx +435 -435
  13. package/templates/nextjs/base/src/app/products/page.tsx +246 -246
  14. package/templates/nextjs/base/src/app/register/page.tsx +68 -68
  15. package/templates/nextjs/base/src/app/verify-email/page.tsx +293 -293
  16. package/templates/nextjs/base/src/components/account/order-history.tsx +198 -198
  17. package/templates/nextjs/base/src/components/account/profile-section.tsx +189 -40
  18. package/templates/nextjs/base/src/components/auth/login-form.tsx +94 -94
  19. package/templates/nextjs/base/src/components/auth/oauth-buttons.tsx +137 -137
  20. package/templates/nextjs/base/src/components/auth/register-form.tsx +184 -184
  21. package/templates/nextjs/base/src/components/cart/cart-item.tsx +153 -153
  22. package/templates/nextjs/base/src/components/cart/cart-summary.tsx +70 -70
  23. package/templates/nextjs/base/src/components/cart/coupon-input.tsx +134 -134
  24. package/templates/nextjs/base/src/components/cart/reservation-countdown.tsx +103 -103
  25. package/templates/nextjs/base/src/components/checkout/checkout-form.tsx +305 -305
  26. package/templates/nextjs/base/src/components/checkout/delivery-method-step.tsx +64 -64
  27. package/templates/nextjs/base/src/components/checkout/payment-step.tsx +350 -344
  28. package/templates/nextjs/base/src/components/checkout/pickup-step.tsx +199 -199
  29. package/templates/nextjs/base/src/components/checkout/shipping-step.tsx +110 -110
  30. package/templates/nextjs/base/src/components/checkout/tax-display.tsx +65 -65
  31. package/templates/nextjs/base/src/components/layout/footer.tsx +38 -38
  32. package/templates/nextjs/base/src/components/layout/header.tsx +332 -332
  33. package/templates/nextjs/base/src/components/products/product-card.tsx +96 -96
  34. package/templates/nextjs/base/src/components/products/product-grid.tsx +35 -35
  35. package/templates/nextjs/base/src/components/shared/loading-spinner.tsx +32 -32
  36. package/templates/nextjs/base/src/lib/translations.ts +11 -11
  37. package/templates/nextjs/base/src/providers/store-provider.tsx.ejs +5 -1
@@ -1,134 +1,134 @@
1
- 'use client';
2
-
3
- import { useState } from 'react';
4
- import type { Cart } from 'brainerce';
5
- import { getClient } from '@/lib/brainerce';
6
- import { useTranslations } from '@/lib/translations';
7
- import { LoadingSpinner } from '@/components/shared/loading-spinner';
8
- import { cn } from '@/lib/utils';
9
-
10
- interface CouponInputProps {
11
- cart: Cart;
12
- onUpdate: () => void;
13
- className?: string;
14
- }
15
-
16
- export function CouponInput({ cart, onUpdate, className }: CouponInputProps) {
17
- const t = useTranslations('coupon');
18
- const tc = useTranslations('common');
19
- const [code, setCode] = useState('');
20
- const [applying, setApplying] = useState(false);
21
- const [removing, setRemoving] = useState(false);
22
- const [error, setError] = useState<string | null>(null);
23
-
24
- const appliedCoupon = cart.couponCode || null;
25
-
26
- async function handleApply() {
27
- const trimmed = code.trim();
28
- if (!trimmed || applying) return;
29
-
30
- try {
31
- setApplying(true);
32
- setError(null);
33
- const client = getClient();
34
- await client.applyCoupon(cart.id, trimmed);
35
- setCode('');
36
- onUpdate();
37
- } catch (err) {
38
- const message = err instanceof Error ? err.message : t('invalidCode');
39
- setError(message);
40
- } finally {
41
- setApplying(false);
42
- }
43
- }
44
-
45
- async function handleRemove() {
46
- if (removing) return;
47
-
48
- try {
49
- setRemoving(true);
50
- setError(null);
51
- const client = getClient();
52
- await client.removeCoupon(cart.id);
53
- onUpdate();
54
- } catch (err) {
55
- console.error('Failed to remove coupon:', err);
56
- } finally {
57
- setRemoving(false);
58
- }
59
- }
60
-
61
- // Show applied coupon
62
- if (appliedCoupon) {
63
- return (
64
- <div className={cn('space-y-2', className)}>
65
- <div className="bg-muted flex items-center justify-between rounded px-3 py-2">
66
- <div className="flex items-center gap-2">
67
- <svg
68
- className="text-primary h-4 w-4 flex-shrink-0"
69
- fill="none"
70
- viewBox="0 0 24 24"
71
- stroke="currentColor"
72
- >
73
- <path
74
- strokeLinecap="round"
75
- strokeLinejoin="round"
76
- strokeWidth={2}
77
- d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"
78
- />
79
- </svg>
80
- <span className="text-foreground text-sm font-medium">{appliedCoupon}</span>
81
- </div>
82
- <button
83
- type="button"
84
- onClick={handleRemove}
85
- disabled={removing}
86
- className="text-destructive hover:text-destructive/80 text-xs transition-colors disabled:opacity-40"
87
- >
88
- {removing ? tc('removing') : tc('remove')}
89
- </button>
90
- </div>
91
- </div>
92
- );
93
- }
94
-
95
- return (
96
- <div className={cn('space-y-2', className)}>
97
- <div className="flex gap-2">
98
- <input
99
- type="text"
100
- value={code}
101
- onChange={(e) => {
102
- setCode(e.target.value);
103
- if (error) setError(null);
104
- }}
105
- onKeyDown={(e) => {
106
- if (e.key === 'Enter') {
107
- e.preventDefault();
108
- handleApply();
109
- }
110
- }}
111
- placeholder={t('placeholder')}
112
- className={cn(
113
- 'bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-9 flex-1 rounded border px-3 text-sm focus:outline-none focus:ring-2',
114
- error ? 'border-destructive' : 'border-border'
115
- )}
116
- />
117
- <button
118
- type="button"
119
- onClick={handleApply}
120
- disabled={applying || !code.trim()}
121
- className="border-border bg-background text-foreground hover:bg-muted h-9 rounded border px-4 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-40"
122
- >
123
- {applying ? (
124
- <LoadingSpinner size="sm" className="border-muted-foreground/30 border-t-foreground" />
125
- ) : (
126
- tc('apply')
127
- )}
128
- </button>
129
- </div>
130
-
131
- {error && <p className="text-destructive text-xs">{error}</p>}
132
- </div>
133
- );
134
- }
1
+ 'use client';
2
+
3
+ import { useState } from 'react';
4
+ import type { Cart } from 'brainerce';
5
+ import { getClient } from '@/lib/brainerce';
6
+ import { useTranslations } from '@/lib/translations';
7
+ import { LoadingSpinner } from '@/components/shared/loading-spinner';
8
+ import { cn } from '@/lib/utils';
9
+
10
+ interface CouponInputProps {
11
+ cart: Cart;
12
+ onUpdate: () => void;
13
+ className?: string;
14
+ }
15
+
16
+ export function CouponInput({ cart, onUpdate, className }: CouponInputProps) {
17
+ const t = useTranslations('coupon');
18
+ const tc = useTranslations('common');
19
+ const [code, setCode] = useState('');
20
+ const [applying, setApplying] = useState(false);
21
+ const [removing, setRemoving] = useState(false);
22
+ const [error, setError] = useState<string | null>(null);
23
+
24
+ const appliedCoupon = cart.couponCode || null;
25
+
26
+ async function handleApply() {
27
+ const trimmed = code.trim();
28
+ if (!trimmed || applying) return;
29
+
30
+ try {
31
+ setApplying(true);
32
+ setError(null);
33
+ const client = getClient();
34
+ await client.applyCoupon(cart.id, trimmed);
35
+ setCode('');
36
+ onUpdate();
37
+ } catch (err) {
38
+ const message = err instanceof Error ? err.message : t('invalidCode');
39
+ setError(message);
40
+ } finally {
41
+ setApplying(false);
42
+ }
43
+ }
44
+
45
+ async function handleRemove() {
46
+ if (removing) return;
47
+
48
+ try {
49
+ setRemoving(true);
50
+ setError(null);
51
+ const client = getClient();
52
+ await client.removeCoupon(cart.id);
53
+ onUpdate();
54
+ } catch (err) {
55
+ console.error('Failed to remove coupon:', err);
56
+ } finally {
57
+ setRemoving(false);
58
+ }
59
+ }
60
+
61
+ // Show applied coupon
62
+ if (appliedCoupon) {
63
+ return (
64
+ <div className={cn('space-y-2', className)}>
65
+ <div className="bg-muted flex items-center justify-between rounded px-3 py-2">
66
+ <div className="flex items-center gap-2">
67
+ <svg
68
+ className="text-primary h-4 w-4 flex-shrink-0"
69
+ fill="none"
70
+ viewBox="0 0 24 24"
71
+ stroke="currentColor"
72
+ >
73
+ <path
74
+ strokeLinecap="round"
75
+ strokeLinejoin="round"
76
+ strokeWidth={2}
77
+ d="M7 7h.01M7 3h5c.512 0 1.024.195 1.414.586l7 7a2 2 0 010 2.828l-7 7a2 2 0 01-2.828 0l-7-7A1.994 1.994 0 013 12V7a4 4 0 014-4z"
78
+ />
79
+ </svg>
80
+ <span className="text-foreground text-sm font-medium">{appliedCoupon}</span>
81
+ </div>
82
+ <button
83
+ type="button"
84
+ onClick={handleRemove}
85
+ disabled={removing}
86
+ className="text-destructive hover:text-destructive/80 text-xs transition-colors disabled:opacity-40"
87
+ >
88
+ {removing ? tc('removing') : tc('remove')}
89
+ </button>
90
+ </div>
91
+ </div>
92
+ );
93
+ }
94
+
95
+ return (
96
+ <div className={cn('space-y-2', className)}>
97
+ <div className="flex gap-2">
98
+ <input
99
+ type="text"
100
+ value={code}
101
+ onChange={(e) => {
102
+ setCode(e.target.value);
103
+ if (error) setError(null);
104
+ }}
105
+ onKeyDown={(e) => {
106
+ if (e.key === 'Enter') {
107
+ e.preventDefault();
108
+ handleApply();
109
+ }
110
+ }}
111
+ placeholder={t('placeholder')}
112
+ className={cn(
113
+ 'bg-background text-foreground placeholder:text-muted-foreground focus:ring-primary/20 focus:border-primary h-9 flex-1 rounded border px-3 text-sm focus:outline-none focus:ring-2',
114
+ error ? 'border-destructive' : 'border-border'
115
+ )}
116
+ />
117
+ <button
118
+ type="button"
119
+ onClick={handleApply}
120
+ disabled={applying || !code.trim()}
121
+ className="border-border bg-background text-foreground hover:bg-muted h-9 rounded border px-4 text-sm font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-40"
122
+ >
123
+ {applying ? (
124
+ <LoadingSpinner size="sm" className="border-muted-foreground/30 border-t-foreground" />
125
+ ) : (
126
+ tc('apply')
127
+ )}
128
+ </button>
129
+ </div>
130
+
131
+ {error && <p className="text-destructive text-xs">{error}</p>}
132
+ </div>
133
+ );
134
+ }
@@ -1,103 +1,103 @@
1
- 'use client';
2
-
3
- import { useState, useEffect, useCallback } from 'react';
4
- import type { ReservationInfo } from 'brainerce';
5
- import { useTranslations } from '@/lib/translations';
6
- import { cn } from '@/lib/utils';
7
-
8
- interface ReservationCountdownProps {
9
- reservation: ReservationInfo;
10
- className?: string;
11
- }
12
-
13
- export function ReservationCountdown({ reservation, className }: ReservationCountdownProps) {
14
- const t = useTranslations('reservation');
15
- const [remainingSeconds, setRemainingSeconds] = useState<number>(0);
16
-
17
- const calculateRemaining = useCallback(() => {
18
- if (!reservation.expiresAt) return 0;
19
- const expiresAtMs = new Date(reservation.expiresAt).getTime();
20
- const nowMs = Date.now();
21
- return Math.max(0, Math.floor((expiresAtMs - nowMs) / 1000));
22
- }, [reservation.expiresAt]);
23
-
24
- useEffect(() => {
25
- setRemainingSeconds(calculateRemaining());
26
-
27
- const interval = setInterval(() => {
28
- const remaining = calculateRemaining();
29
- setRemainingSeconds(remaining);
30
-
31
- if (remaining <= 0) {
32
- clearInterval(interval);
33
- }
34
- }, 1000);
35
-
36
- return () => clearInterval(interval);
37
- }, [calculateRemaining]);
38
-
39
- if (!reservation.hasReservation) return null;
40
-
41
- const minutes = Math.floor(remainingSeconds / 60);
42
- const seconds = remainingSeconds % 60;
43
- const isExpired = remainingSeconds <= 0;
44
- const isUrgent = remainingSeconds > 0 && remainingSeconds < 120;
45
-
46
- const displayMessage = reservation.countdownMessage
47
- ? reservation.countdownMessage.replace(
48
- '{time}',
49
- `${minutes}:${seconds.toString().padStart(2, '0')}`
50
- )
51
- : null;
52
-
53
- return (
54
- <div
55
- className={cn(
56
- 'flex items-center gap-3 rounded-lg px-4 py-3 text-sm',
57
- isExpired
58
- ? 'bg-destructive/10 border-destructive/20 text-destructive border'
59
- : isUrgent
60
- ? 'border border-orange-200 bg-orange-50 text-orange-800 dark:border-orange-800 dark:bg-orange-950/30 dark:text-orange-300'
61
- : 'bg-primary/5 border-primary/20 text-foreground border',
62
- className
63
- )}
64
- >
65
- <svg
66
- className={cn(
67
- 'h-5 w-5 flex-shrink-0',
68
- isExpired
69
- ? 'text-destructive'
70
- : isUrgent
71
- ? 'text-orange-600 dark:text-orange-400'
72
- : 'text-primary'
73
- )}
74
- fill="none"
75
- viewBox="0 0 24 24"
76
- stroke="currentColor"
77
- >
78
- <path
79
- strokeLinecap="round"
80
- strokeLinejoin="round"
81
- strokeWidth={2}
82
- d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
83
- />
84
- </svg>
85
-
86
- <div className="flex-1">
87
- {isExpired ? (
88
- <p className="font-medium">{t('expired')}</p>
89
- ) : displayMessage ? (
90
- <p>{displayMessage}</p>
91
- ) : (
92
- <p>
93
- {isUrgent ? `${t('hurry')} ` : ''}
94
- {t('reservedFor')}{' '}
95
- <span className="font-semibold tabular-nums">
96
- {minutes}:{seconds.toString().padStart(2, '0')}
97
- </span>
98
- </p>
99
- )}
100
- </div>
101
- </div>
102
- );
103
- }
1
+ 'use client';
2
+
3
+ import { useState, useEffect, useCallback } from 'react';
4
+ import type { ReservationInfo } from 'brainerce';
5
+ import { useTranslations } from '@/lib/translations';
6
+ import { cn } from '@/lib/utils';
7
+
8
+ interface ReservationCountdownProps {
9
+ reservation: ReservationInfo;
10
+ className?: string;
11
+ }
12
+
13
+ export function ReservationCountdown({ reservation, className }: ReservationCountdownProps) {
14
+ const t = useTranslations('reservation');
15
+ const [remainingSeconds, setRemainingSeconds] = useState<number>(0);
16
+
17
+ const calculateRemaining = useCallback(() => {
18
+ if (!reservation.expiresAt) return 0;
19
+ const expiresAtMs = new Date(reservation.expiresAt).getTime();
20
+ const nowMs = Date.now();
21
+ return Math.max(0, Math.floor((expiresAtMs - nowMs) / 1000));
22
+ }, [reservation.expiresAt]);
23
+
24
+ useEffect(() => {
25
+ setRemainingSeconds(calculateRemaining());
26
+
27
+ const interval = setInterval(() => {
28
+ const remaining = calculateRemaining();
29
+ setRemainingSeconds(remaining);
30
+
31
+ if (remaining <= 0) {
32
+ clearInterval(interval);
33
+ }
34
+ }, 1000);
35
+
36
+ return () => clearInterval(interval);
37
+ }, [calculateRemaining]);
38
+
39
+ if (!reservation.hasReservation) return null;
40
+
41
+ const minutes = Math.floor(remainingSeconds / 60);
42
+ const seconds = remainingSeconds % 60;
43
+ const isExpired = remainingSeconds <= 0;
44
+ const isUrgent = remainingSeconds > 0 && remainingSeconds < 120;
45
+
46
+ const displayMessage = reservation.countdownMessage
47
+ ? reservation.countdownMessage.replace(
48
+ '{time}',
49
+ `${minutes}:${seconds.toString().padStart(2, '0')}`
50
+ )
51
+ : null;
52
+
53
+ return (
54
+ <div
55
+ className={cn(
56
+ 'flex items-center gap-3 rounded-lg px-4 py-3 text-sm',
57
+ isExpired
58
+ ? 'bg-destructive/10 border-destructive/20 text-destructive border'
59
+ : isUrgent
60
+ ? 'border border-orange-200 bg-orange-50 text-orange-800 dark:border-orange-800 dark:bg-orange-950/30 dark:text-orange-300'
61
+ : 'bg-primary/5 border-primary/20 text-foreground border',
62
+ className
63
+ )}
64
+ >
65
+ <svg
66
+ className={cn(
67
+ 'h-5 w-5 flex-shrink-0',
68
+ isExpired
69
+ ? 'text-destructive'
70
+ : isUrgent
71
+ ? 'text-orange-600 dark:text-orange-400'
72
+ : 'text-primary'
73
+ )}
74
+ fill="none"
75
+ viewBox="0 0 24 24"
76
+ stroke="currentColor"
77
+ >
78
+ <path
79
+ strokeLinecap="round"
80
+ strokeLinejoin="round"
81
+ strokeWidth={2}
82
+ d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"
83
+ />
84
+ </svg>
85
+
86
+ <div className="flex-1">
87
+ {isExpired ? (
88
+ <p className="font-medium">{t('expired')}</p>
89
+ ) : displayMessage ? (
90
+ <p>{displayMessage}</p>
91
+ ) : (
92
+ <p>
93
+ {isUrgent ? `${t('hurry')} ` : ''}
94
+ {t('reservedFor')}{' '}
95
+ <span className="font-semibold tabular-nums">
96
+ {minutes}:{seconds.toString().padStart(2, '0')}
97
+ </span>
98
+ </p>
99
+ )}
100
+ </div>
101
+ </div>
102
+ );
103
+ }