@pradip1995/segment-login-template 0.5.19 → 0.5.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pradip1995/segment-login-template",
3
- "version": "0.5.19",
3
+ "version": "0.5.21",
4
4
  "license": "MIT",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -34,18 +34,13 @@ export default function AccountGuestOrders({
34
34
  }
35
35
 
36
36
  return (
37
- <div className="space-y-6">
37
+ <div className="sr-guest-orders space-y-6">
38
38
  <div className="flex flex-wrap items-start justify-between gap-4">
39
39
  <div>
40
- <div className="flex items-center gap-2 mb-2" aria-hidden>
41
- <span className="h-px w-6 bg-brand-accent/70" />
42
- <span className="text-brand-accent text-[7px]">◆</span>
43
- <span className="h-px w-6 bg-brand-accent/70" />
44
- </div>
45
- <h2 className="font-heading text-2xl font-bold text-heading uppercase tracking-[0.08em] mb-1">
40
+ <h2 className="sr-guest-orders__title font-heading text-2xl font-bold uppercase tracking-[0.08em] mb-1">
46
41
  Guest orders
47
42
  </h2>
48
- <p className="text-sm text-muted">
43
+ <p className="sr-guest-orders__copy text-sm">
49
44
  Track orders linked to your verified email.
50
45
  </p>
51
46
  </div>
@@ -53,20 +48,20 @@ export default function AccountGuestOrders({
53
48
  <button
54
49
  type="button"
55
50
  onClick={handleCheckDifferent}
56
- className="btn-outline text-xs"
51
+ className="sr-guest-orders__btn"
57
52
  >
58
53
  Check different email
59
54
  </button>
60
- <button type="button" onClick={handleSignOut} className="btn-outline text-xs">
55
+ <button type="button" onClick={handleSignOut} className="sr-guest-orders__btn">
61
56
  End guest session
62
57
  </button>
63
58
  </div>
64
59
  </div>
65
60
 
66
61
  {safeOrders.length === 0 ? (
67
- <div className="border border-cart-border bg-surface p-8 text-center">
68
- <p className="text-sm text-muted mb-4">No guest orders found for this session.</p>
69
- <LocalizedLink href="/store" className={acct.btnPrimary}>
62
+ <div className="sr-guest-orders__empty p-8 text-center">
63
+ <p className="sr-guest-orders__copy text-sm mb-4">No guest orders found for this session.</p>
64
+ <LocalizedLink href="/store" className={`${acct.btnPrimary} sr-guest-orders__shop`}>
70
65
  Continue shopping
71
66
  </LocalizedLink>
72
67
  </div>
@@ -76,17 +71,17 @@ export default function AccountGuestOrders({
76
71
  <li key={order.id}>
77
72
  <LocalizedLink
78
73
  href={`/orders/${order.id}`}
79
- className="border border-cart-border bg-surface p-5 flex items-center justify-between gap-4 hover:border-brand-accent transition-colors duration-200 block"
74
+ className="sr-guest-orders__card p-5 flex items-center justify-between gap-4 block"
80
75
  >
81
76
  <div>
82
- <p className="font-semibold text-heading text-sm">
77
+ <p className="sr-guest-orders__order font-semibold text-sm">
83
78
  Order #{order.display_id}
84
79
  </p>
85
- <p className="text-xs text-muted mt-1 capitalize">
80
+ <p className="sr-guest-orders__status text-xs mt-1 capitalize">
86
81
  {resolveOrderHistoryStatus(order as OrderHistoryStatusInput).label}
87
82
  </p>
88
83
  </div>
89
- <p className="text-sm font-semibold text-brand-accent shrink-0">
84
+ <p className="sr-guest-orders__total text-sm font-semibold shrink-0">
90
85
  {formatPrice(order.total, order.currency_code)}
91
86
  </p>
92
87
  </LocalizedLink>
@@ -1,6 +1,6 @@
1
1
  "use client"
2
2
 
3
- import { useMemo, useState, type MouseEvent } from "react"
3
+ import { useEffect, useMemo, useState, type MouseEvent } from "react"
4
4
  import { usePathname, useRouter } from "next/navigation"
5
5
  import type { HttpTypes } from "@medusajs/types"
6
6
  import { addToCart } from "@pradip1995/commerce-core/client/actions/cart"
@@ -46,12 +46,29 @@ function statusStyle(tone: OrderHistoryStatusTone) {
46
46
  return "bg-surface-muted text-muted border-cart-border"
47
47
  }
48
48
 
49
+ const DEFAULT_PAGE_SIZE = 3
50
+
51
+ function paginationItems(current: number, total: number) {
52
+ if (total <= 7) return Array.from({ length: total }, (_, index) => index + 1)
53
+ const items: (number | "ellipsis")[] = [1]
54
+ const start = Math.max(2, current - 1)
55
+ const end = Math.min(total - 1, current + 1)
56
+ if (start > 2) items.push("ellipsis")
57
+ for (let page = start; page <= end; page += 1) items.push(page)
58
+ if (end < total - 1) items.push("ellipsis")
59
+ items.push(total)
60
+ return items
61
+ }
62
+
49
63
  export default function AccountOrders({
50
64
  orders,
65
+ pageSize = DEFAULT_PAGE_SIZE,
51
66
  }: {
52
67
  orders?: HttpTypes.StoreOrder[] | { orders?: HttpTypes.StoreOrder[] } | null
68
+ pageSize?: number
53
69
  }) {
54
70
  const [query, setQuery] = useState("")
71
+ const [page, setPage] = useState(1)
55
72
  const [reorderingId, setReorderingId] = useState<string | null>(null)
56
73
  const router = useRouter()
57
74
  const pathname = usePathname() || ""
@@ -75,6 +92,22 @@ export default function AccountOrders({
75
92
  })
76
93
  }, [safeOrders, query])
77
94
 
95
+ const perPage = Math.max(1, pageSize)
96
+ const totalPages = Math.max(1, Math.ceil(filtered.length / perPage))
97
+ const currentPage = Math.min(page, totalPages)
98
+ const paged = useMemo(
99
+ () => filtered.slice((currentPage - 1) * perPage, currentPage * perPage),
100
+ [filtered, currentPage, perPage]
101
+ )
102
+
103
+ useEffect(() => {
104
+ setPage(1)
105
+ }, [query, perPage])
106
+
107
+ useEffect(() => {
108
+ if (page > totalPages) setPage(totalPages)
109
+ }, [page, totalPages])
110
+
78
111
  async function handleReorder(event: MouseEvent, order: HttpTypes.StoreOrder) {
79
112
  event.preventDefault()
80
113
  event.stopPropagation()
@@ -130,7 +163,7 @@ export default function AccountOrders({
130
163
  </div>
131
164
  ) : (
132
165
  <ul className="space-y-4">
133
- {filtered.map((order) => {
166
+ {paged.map((order) => {
134
167
  const resolved = historyStatus(order)
135
168
  const showReorder = canReorder(order)
136
169
  const presentation = presentOrderLines(order)
@@ -180,6 +213,48 @@ export default function AccountOrders({
180
213
  })}
181
214
  </ul>
182
215
  )}
216
+
217
+ {filtered.length > perPage ? (
218
+ <nav className="account-orders__pager" aria-label="Order pagination">
219
+ <button
220
+ type="button"
221
+ className="account-orders__page"
222
+ disabled={currentPage <= 1}
223
+ onClick={() => setPage((p) => Math.max(1, p - 1))}
224
+ >
225
+ Prev
226
+ </button>
227
+ {paginationItems(currentPage, totalPages).map((item, index) =>
228
+ item === "ellipsis" ? (
229
+ <span key={`ellipsis-${index}`} className="account-orders__ellipsis">
230
+ …
231
+ </span>
232
+ ) : (
233
+ <button
234
+ key={item}
235
+ type="button"
236
+ className={
237
+ item === currentPage
238
+ ? "account-orders__page is-active"
239
+ : "account-orders__page"
240
+ }
241
+ aria-current={item === currentPage ? "page" : undefined}
242
+ onClick={() => setPage(item)}
243
+ >
244
+ {item}
245
+ </button>
246
+ )
247
+ )}
248
+ <button
249
+ type="button"
250
+ className="account-orders__page"
251
+ disabled={currentPage >= totalPages}
252
+ onClick={() => setPage((p) => Math.min(totalPages, p + 1))}
253
+ >
254
+ Next
255
+ </button>
256
+ </nav>
257
+ ) : null}
183
258
  </div>
184
259
  )
185
260
  }
@@ -33,21 +33,21 @@ export default function CommerceAuthOtpModal({
33
33
  }
34
34
 
35
35
  return (
36
- <div className="fixed inset-0 z-50 flex items-center justify-center p-4">
36
+ <div className="sr-otp-modal fixed inset-0 z-50 flex items-center justify-center p-4">
37
37
  <button
38
38
  type="button"
39
- className="absolute inset-0 bg-black/40"
39
+ className="sr-otp-modal__backdrop absolute inset-0"
40
40
  aria-label="Close verification dialog"
41
41
  onClick={handleBackdropClick}
42
42
  />
43
- <div className="relative w-full max-w-md rounded-2xl bg-page-bg shadow-xl p-6">
43
+ <div className="sr-otp-modal__panel relative w-full max-w-md p-6">
44
44
  <div className="flex flex-col gap-6 py-4 px-2">
45
45
  <div className="text-center">
46
- <h2 className="text-2xl font-bold text-heading mb-2">
46
+ <h2 className="sr-otp-modal__title text-2xl font-bold mb-2">
47
47
  {success ? successTitle : title}
48
48
  </h2>
49
49
  {!success && (
50
- <p className="text-sm text-gray-500 leading-relaxed max-w-[320px] mx-auto">
50
+ <p className="sr-otp-modal__copy text-sm leading-relaxed max-w-[320px] mx-auto">
51
51
  {description}
52
52
  </p>
53
53
  )}
@@ -55,16 +55,23 @@ export default function CommerceAuthOtpModal({
55
55
 
56
56
  {success ? (
57
57
  <div className="text-center py-6">
58
- <p className="text-brand-accent font-bold animate-pulse">{successMessage}</p>
58
+ <p className="sr-otp-modal__success font-bold">{successMessage}</p>
59
59
  </div>
60
60
  ) : (
61
61
  <>
62
62
  {extraContent}
63
63
 
64
- <OtpInput value={otp} onChange={onOtpChange} autoFocus />
64
+ <OtpInput
65
+ value={otp}
66
+ onChange={onOtpChange}
67
+ autoFocus
68
+ activeClassName="sr-otp-modal__cell is-active"
69
+ filledClassName="sr-otp-modal__cell is-filled"
70
+ emptyClassName="sr-otp-modal__cell"
71
+ />
65
72
 
66
73
  {error && (
67
- <p className="text-red-500 text-xs text-center" role="alert">
74
+ <p className="sr-otp-modal__error text-xs text-center" role="alert">
68
75
  {error}
69
76
  </p>
70
77
  )}
@@ -74,7 +81,7 @@ export default function CommerceAuthOtpModal({
74
81
  type="button"
75
82
  onClick={onVerify}
76
83
  disabled={pending || otp.length < 6}
77
- className="w-full py-3 bg-brand-accent text-inverse font-bold hover:opacity-90 rounded-[30px] transition-colors disabled:opacity-60"
84
+ className="sr-otp-modal__verify w-full"
78
85
  >
79
86
  {pending ? "Verifying…" : verifyLabel}
80
87
  </button>
@@ -83,14 +90,14 @@ export default function CommerceAuthOtpModal({
83
90
  type="button"
84
91
  onClick={onResend}
85
92
  disabled={pending}
86
- className="text-xs text-gray-500 hover:text-brand-accent w-full text-center underline font-medium disabled:opacity-60"
93
+ className="sr-otp-modal__resend w-full text-center disabled:opacity-60"
87
94
  >
88
95
  Resend code
89
96
  </button>
90
97
  </div>
91
98
 
92
99
  {preventClose && (
93
- <p className="text-xs text-muted text-center">
100
+ <p className="sr-otp-modal__hint text-xs text-center">
94
101
  Verification is required to complete{" "}
95
102
  {verifyLabel.toLowerCase().includes("sign in") ? "sign in" : "registration"}.
96
103
  </p>
@@ -54,7 +54,7 @@ export default function GoogleAuthSection({ countryCode }: { countryCode: string
54
54
  type="button"
55
55
  onClick={handleClick}
56
56
  disabled={loading}
57
- className={auth.btnOutline}
57
+ className={`${auth.btnOutline} sr-google-btn`}
58
58
  aria-label="Continue with Google"
59
59
  >
60
60
  <svg width="18" height="18" viewBox="0 0 24 24" aria-hidden="true">
@@ -75,7 +75,7 @@ export default function GoogleAuthSection({ countryCode }: { countryCode: string
75
75
  d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z"
76
76
  />
77
77
  </svg>
78
- <span className="text-xs text-heading font-medium tracking-wide">
78
+ <span className="sr-google-btn__label">
79
79
  {loading ? "Redirecting…" : "Continue with Google"}
80
80
  </span>
81
81
  </button>
@@ -5,7 +5,6 @@ import { useEffect, useRef, useState } from "react"
5
5
  import { sendOTP, verifyOTP } from "./auth-server"
6
6
  import OtpVerificationModal from "./otp-verification-modal"
7
7
  import type { OtpVerificationComponent } from "./otp-component"
8
- import { auth } from "./account-theme"
9
8
 
10
9
  type GuestOrderModalProps = {
11
10
  open: boolean
@@ -152,14 +151,14 @@ export default function GuestOrderModal({
152
151
  }
153
152
 
154
153
  return (
155
- <div className="fixed inset-0 z-50 flex items-center justify-center p-4">
154
+ <div className="sr-otp-modal fixed inset-0 z-50 flex items-center justify-center p-4">
156
155
  <button
157
156
  type="button"
158
- className="absolute inset-0 bg-black/40"
157
+ className="sr-otp-modal__backdrop absolute inset-0"
159
158
  aria-label="Close guest order dialog"
160
159
  onClick={handleClose}
161
160
  />
162
- <div className="relative w-full max-w-md border border-cart-border/60 bg-surface shadow-[0_10px_40px_-16px_rgba(0,0,0,0.2)] p-7 sm:p-8">
161
+ <div className="sr-otp-modal__panel relative w-full max-w-md p-7 sm:p-8">
163
162
  <form
164
163
  onSubmit={(e) => {
165
164
  e.preventDefault()
@@ -168,16 +167,15 @@ export default function GuestOrderModal({
168
167
  className="space-y-5"
169
168
  >
170
169
  <div className="text-center">
171
- <Ornament />
172
- <h2 className={`${auth.title} text-xl xl:text-2xl`}>Track your order</h2>
173
- <p className="mt-2 text-sm text-muted leading-relaxed">
170
+ <h2 className="sr-otp-modal__title text-xl xl:text-2xl">Track your order</h2>
171
+ <p className="sr-otp-modal__copy mt-2 text-sm leading-relaxed">
174
172
  Enter the email used at checkout. We&apos;ll send a one-time code to view guest
175
173
  orders.
176
174
  </p>
177
175
  </div>
178
176
 
179
177
  <label className="block">
180
- <span className={`${auth.fieldLabel} mb-1.5 block`}>Email</span>
178
+ <span className="sr-otp-modal__label mb-1.5 block">Email</span>
181
179
  <input
182
180
  type="email"
183
181
  value={email}
@@ -185,12 +183,12 @@ export default function GuestOrderModal({
185
183
  required
186
184
  autoComplete="email"
187
185
  placeholder="you@example.com"
188
- className={auth.input}
186
+ className="sr-otp-modal__input"
189
187
  />
190
188
  </label>
191
189
 
192
190
  {error && (
193
- <p className="text-sm text-brand-sale" role="alert">
191
+ <p className="sr-otp-modal__error text-sm" role="alert">
194
192
  {error}
195
193
  </p>
196
194
  )}
@@ -198,15 +196,15 @@ export default function GuestOrderModal({
198
196
  <button
199
197
  type="submit"
200
198
  disabled={pending || !email.trim()}
201
- className={`${auth.btnPrimary} ${auth.btnShine}`}
199
+ className="sr-otp-modal__verify w-full"
202
200
  >
203
- <span className="relative z-[1]">{pending ? "Sending…" : "Send verification code"}</span>
201
+ {pending ? "Sending…" : "Send verification code"}
204
202
  </button>
205
203
 
206
204
  <button
207
205
  type="button"
208
206
  onClick={handleClose}
209
- className="text-sm text-muted hover:text-brand-accent w-full text-center transition-colors"
207
+ className="sr-otp-modal__resend w-full text-center"
210
208
  >
211
209
  Cancel
212
210
  </button>
@@ -215,13 +213,3 @@ export default function GuestOrderModal({
215
213
  </div>
216
214
  )
217
215
  }
218
-
219
- function Ornament() {
220
- return (
221
- <div className="flex items-center justify-center gap-2 mb-4" aria-hidden>
222
- <span className="h-px w-8 bg-gradient-to-r from-transparent to-brand-accent" />
223
- <span className="text-brand-accent text-[8px] leading-none">◆</span>
224
- <span className="h-px w-8 bg-gradient-to-l from-transparent to-brand-accent" />
225
- </div>
226
- )
227
- }
@@ -79,7 +79,7 @@ export default function LoginBrandPanel({
79
79
  src={image}
80
80
  alt=""
81
81
  fill
82
- className="object-cover object-center"
82
+ className="sr-login-hero object-cover object-center"
83
83
  sizes="50vw"
84
84
  priority
85
85
  unoptimized={image.startsWith("data:")}
@@ -139,7 +139,7 @@ export default function LoginBrandPanel({
139
139
  />
140
140
  ) : (
141
141
  <span
142
- className="mt-1.5 h-2 w-2 rounded-full bg-brand-accent shrink-0"
142
+ className="sr-login-dot mt-1.5 h-2 w-2 rounded-full shrink-0"
143
143
  aria-hidden
144
144
  />
145
145
  )}