@pradip1995/segment-login-template 0.5.26 → 0.5.28

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 (43) hide show
  1. package/package.json +58 -54
  2. package/src/account-addresses.tsx +307 -287
  3. package/src/account-guest-orders.tsx +98 -98
  4. package/src/account-orders.tsx +260 -260
  5. package/src/account-overview.tsx +133 -133
  6. package/src/account-payment-methods.tsx +328 -328
  7. package/src/account-profile-logic.ts +282 -282
  8. package/src/account-profile.tsx +111 -111
  9. package/src/account-theme.ts +91 -91
  10. package/src/account-utils.ts +20 -20
  11. package/src/address-actions.ts +74 -0
  12. package/src/auth-server.ts +442 -442
  13. package/src/card-expiry.test.ts +71 -0
  14. package/src/card-expiry.ts +29 -0
  15. package/src/commerce-auth-otp-modal.css +125 -125
  16. package/src/commerce-auth-otp-modal.tsx +121 -121
  17. package/src/default-address.test.ts +143 -0
  18. package/src/default-address.ts +51 -0
  19. package/src/forgot-password-form.tsx +109 -109
  20. package/src/google-auth-section.tsx +22 -22
  21. package/src/google-sign-in-section.tsx +67 -67
  22. package/src/guest-order-modal.tsx +215 -215
  23. package/src/index.ts +7 -7
  24. package/src/is-next-redirect.ts +60 -60
  25. package/src/login-brand-panel.tsx +159 -158
  26. package/src/login-form.tsx +469 -469
  27. package/src/manifest.ts +11 -11
  28. package/src/order-history-status.test.ts +224 -224
  29. package/src/order-history-status.ts +244 -244
  30. package/src/otp-component.ts +14 -14
  31. package/src/otp-input.tsx +46 -46
  32. package/src/otp-unified-form.tsx +333 -333
  33. package/src/otp-verification-modal.tsx +112 -112
  34. package/src/payment-methods-actions.ts +243 -243
  35. package/src/profile-email-field.tsx +116 -116
  36. package/src/profile-email.test.ts +182 -182
  37. package/src/profile-email.ts +54 -54
  38. package/src/profile-phone-field.tsx +119 -119
  39. package/src/register-form.tsx +339 -339
  40. package/src/reorder-checkout-address.ts +103 -101
  41. package/src/reset-password-form.tsx +103 -103
  42. package/src/reset-password-page.tsx +12 -12
  43. package/src/segment.tsx +272 -272
@@ -1,112 +1,112 @@
1
- "use client"
2
-
3
- import OtpInput from "./otp-input"
4
-
5
- export type OtpVerificationModalProps = {
6
- open: boolean
7
- title: string
8
- description: string
9
- otp: string
10
- onOtpChange: (value: string) => void
11
- error: string | null
12
- pending: boolean
13
- success?: boolean
14
- successTitle?: string
15
- successMessage?: string
16
- verifyLabel?: string
17
- onVerify: () => void
18
- onResend: () => void
19
- onClose?: () => void
20
- /** When true, backdrop click does not dismiss the modal (registration OTP). */
21
- preventClose?: boolean
22
- extraContent?: React.ReactNode
23
- }
24
-
25
- export default function OtpVerificationModal({
26
- open,
27
- title,
28
- description,
29
- otp,
30
- onOtpChange,
31
- error,
32
- pending,
33
- success = false,
34
- successTitle = "Verified",
35
- successMessage = "Redirecting you…",
36
- verifyLabel = "Verify & continue",
37
- onVerify,
38
- onResend,
39
- onClose,
40
- preventClose = false,
41
- extraContent,
42
- }: OtpVerificationModalProps) {
43
- if (!open) return null
44
-
45
- function handleBackdropClick() {
46
- if (preventClose || pending || success) return
47
- onClose?.()
48
- }
49
-
50
- return (
51
- <div className="fixed inset-0 z-50 flex items-center justify-center p-4">
52
- <button
53
- type="button"
54
- className="absolute inset-0 bg-black/40"
55
- aria-label="Close verification dialog"
56
- onClick={handleBackdropClick}
57
- />
58
- <div className="relative w-full max-w-md rounded-2xl bg-page-bg border border-cart-border shadow-xl p-6">
59
- {success ? (
60
- <div className="text-center space-y-4 py-4">
61
- <div className="w-14 h-14 mx-auto rounded-full bg-green-100 flex items-center justify-center text-2xl text-green-600">
62
- ✓
63
- </div>
64
- <h2 className="section-heading text-lg">{successTitle}</h2>
65
- <p className="text-sm text-muted">{successMessage}</p>
66
- </div>
67
- ) : (
68
- <>
69
- <h2 className="section-heading text-lg text-center mb-2">{title}</h2>
70
- <p className="text-sm text-muted text-center mb-6">{description}</p>
71
-
72
- {extraContent}
73
-
74
- <div className="mb-6">
75
- <OtpInput value={otp} onChange={onOtpChange} autoFocus />
76
- </div>
77
-
78
- {error && (
79
- <p className="text-sm text-brand-sale text-center mb-4" role="alert">
80
- {error}
81
- </p>
82
- )}
83
-
84
- <button
85
- type="button"
86
- onClick={onVerify}
87
- disabled={pending || otp.length < 6}
88
- className="btn-primary w-full disabled:opacity-60 mb-3"
89
- >
90
- {pending ? "Verifying…" : verifyLabel}
91
- </button>
92
-
93
- <button
94
- type="button"
95
- onClick={onResend}
96
- disabled={pending}
97
- className="text-sm text-muted hover:text-brand-accent w-full text-center disabled:opacity-60"
98
- >
99
- Didn&apos;t receive the code? Resend
100
- </button>
101
-
102
- {preventClose && (
103
- <p className="text-xs text-muted text-center mt-4">
104
- Verification is required to complete {verifyLabel.includes("sign in") ? "sign in" : "registration"}.
105
- </p>
106
- )}
107
- </>
108
- )}
109
- </div>
110
- </div>
111
- )
112
- }
1
+ "use client"
2
+
3
+ import OtpInput from "./otp-input"
4
+
5
+ export type OtpVerificationModalProps = {
6
+ open: boolean
7
+ title: string
8
+ description: string
9
+ otp: string
10
+ onOtpChange: (value: string) => void
11
+ error: string | null
12
+ pending: boolean
13
+ success?: boolean
14
+ successTitle?: string
15
+ successMessage?: string
16
+ verifyLabel?: string
17
+ onVerify: () => void
18
+ onResend: () => void
19
+ onClose?: () => void
20
+ /** When true, backdrop click does not dismiss the modal (registration OTP). */
21
+ preventClose?: boolean
22
+ extraContent?: React.ReactNode
23
+ }
24
+
25
+ export default function OtpVerificationModal({
26
+ open,
27
+ title,
28
+ description,
29
+ otp,
30
+ onOtpChange,
31
+ error,
32
+ pending,
33
+ success = false,
34
+ successTitle = "Verified",
35
+ successMessage = "Redirecting you…",
36
+ verifyLabel = "Verify & continue",
37
+ onVerify,
38
+ onResend,
39
+ onClose,
40
+ preventClose = false,
41
+ extraContent,
42
+ }: OtpVerificationModalProps) {
43
+ if (!open) return null
44
+
45
+ function handleBackdropClick() {
46
+ if (preventClose || pending || success) return
47
+ onClose?.()
48
+ }
49
+
50
+ return (
51
+ <div className="fixed inset-0 z-50 flex items-center justify-center p-4">
52
+ <button
53
+ type="button"
54
+ className="absolute inset-0 bg-black/40"
55
+ aria-label="Close verification dialog"
56
+ onClick={handleBackdropClick}
57
+ />
58
+ <div className="relative w-full max-w-md rounded-2xl bg-page-bg border border-cart-border shadow-xl p-6">
59
+ {success ? (
60
+ <div className="text-center space-y-4 py-4">
61
+ <div className="w-14 h-14 mx-auto rounded-full bg-green-100 flex items-center justify-center text-2xl text-green-600">
62
+ ✓
63
+ </div>
64
+ <h2 className="section-heading text-lg">{successTitle}</h2>
65
+ <p className="text-sm text-muted">{successMessage}</p>
66
+ </div>
67
+ ) : (
68
+ <>
69
+ <h2 className="section-heading text-lg text-center mb-2">{title}</h2>
70
+ <p className="text-sm text-muted text-center mb-6">{description}</p>
71
+
72
+ {extraContent}
73
+
74
+ <div className="mb-6">
75
+ <OtpInput value={otp} onChange={onOtpChange} autoFocus />
76
+ </div>
77
+
78
+ {error && (
79
+ <p className="text-sm text-brand-sale text-center mb-4" role="alert">
80
+ {error}
81
+ </p>
82
+ )}
83
+
84
+ <button
85
+ type="button"
86
+ onClick={onVerify}
87
+ disabled={pending || otp.length < 6}
88
+ className="btn-primary w-full disabled:opacity-60 mb-3"
89
+ >
90
+ {pending ? "Verifying…" : verifyLabel}
91
+ </button>
92
+
93
+ <button
94
+ type="button"
95
+ onClick={onResend}
96
+ disabled={pending}
97
+ className="text-sm text-muted hover:text-brand-accent w-full text-center disabled:opacity-60"
98
+ >
99
+ Didn&apos;t receive the code? Resend
100
+ </button>
101
+
102
+ {preventClose && (
103
+ <p className="text-xs text-muted text-center mt-4">
104
+ Verification is required to complete {verifyLabel.includes("sign in") ? "sign in" : "registration"}.
105
+ </p>
106
+ )}
107
+ </>
108
+ )}
109
+ </div>
110
+ </div>
111
+ )
112
+ }