@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,98 +1,98 @@
1
- "use client"
2
-
3
- import type { HttpTypes } from "@medusajs/types"
4
- import LocalizedLink from "@pradip1995/segment-primitives/localized-link"
5
- import { formatPrice } from "@pradip1995/segment-primitives/format-price"
6
- import { presentOrderLines } from "@pradip1995/segment-primitives/order-lines"
7
- import { logoutGuest } from "@pradip1995/commerce-core/data/guest"
8
- import { acct } from "./account-theme"
9
- import {
10
- resolveOrderHistoryStatus,
11
- type OrderHistoryStatusInput,
12
- } from "./order-history-status"
13
-
14
- export default function AccountGuestOrders({
15
- orders,
16
- countryCode,
17
- }: {
18
- orders?: HttpTypes.StoreOrder[] | { orders?: HttpTypes.StoreOrder[] } | null
19
- countryCode: string
20
- }) {
21
- const safeOrders: HttpTypes.StoreOrder[] = Array.isArray(orders)
22
- ? orders
23
- : Array.isArray((orders as { orders?: HttpTypes.StoreOrder[] })?.orders)
24
- ? ((orders as { orders: HttpTypes.StoreOrder[] }).orders)
25
- : []
26
-
27
- async function handleSignOut() {
28
- await logoutGuest()
29
- window.location.href = `/${countryCode}/account`
30
- }
31
-
32
- async function handleCheckDifferent() {
33
- await logoutGuest()
34
- window.location.href = `/${countryCode}/account?view=guest`
35
- }
36
-
37
- return (
38
- <div className="sr-guest-orders space-y-6">
39
- <div className="flex flex-wrap items-start justify-between gap-4">
40
- <div>
41
- <h2 className="sr-guest-orders__title font-heading text-2xl font-bold uppercase tracking-[0.08em] mb-1">
42
- Guest orders
43
- </h2>
44
- <p className="sr-guest-orders__copy text-sm">
45
- Track orders linked to your verified email.
46
- </p>
47
- </div>
48
- <div className="flex flex-wrap gap-2">
49
- <button
50
- type="button"
51
- onClick={handleCheckDifferent}
52
- className="sr-guest-orders__btn"
53
- >
54
- Check different email
55
- </button>
56
- <button type="button" onClick={handleSignOut} className="sr-guest-orders__btn">
57
- End guest session
58
- </button>
59
- </div>
60
- </div>
61
-
62
- {safeOrders.length === 0 ? (
63
- <div className="sr-guest-orders__empty p-8 text-center">
64
- <p className="sr-guest-orders__copy text-sm mb-4">No guest orders found for this session.</p>
65
- <LocalizedLink href="/store" className={`${acct.btnPrimary} sr-guest-orders__shop`}>
66
- Continue shopping
67
- </LocalizedLink>
68
- </div>
69
- ) : (
70
- <ul className="space-y-3">
71
- {safeOrders.map((order) => (
72
- <li key={order.id}>
73
- <LocalizedLink
74
- href={`/orders/${order.id}`}
75
- className="sr-guest-orders__card p-5 flex items-center justify-between gap-4 block"
76
- >
77
- <div>
78
- <p className="sr-guest-orders__order font-semibold text-sm">
79
- Order #{order.display_id}
80
- </p>
81
- <p className="sr-guest-orders__status text-xs mt-1 capitalize">
82
- {resolveOrderHistoryStatus(order as OrderHistoryStatusInput).label}
83
- </p>
84
- </div>
85
- <p className="sr-guest-orders__total text-sm font-semibold shrink-0">
86
- {formatPrice(
87
- presentOrderLines(order).paidTotal,
88
- order.currency_code
89
- )}
90
- </p>
91
- </LocalizedLink>
92
- </li>
93
- ))}
94
- </ul>
95
- )}
96
- </div>
97
- )
98
- }
1
+ "use client"
2
+
3
+ import type { HttpTypes } from "@medusajs/types"
4
+ import LocalizedLink from "@pradip1995/segment-primitives/localized-link"
5
+ import { formatPrice } from "@pradip1995/segment-primitives/format-price"
6
+ import { presentOrderLines } from "@pradip1995/segment-primitives/order-lines"
7
+ import { logoutGuest } from "@pradip1995/commerce-core/data/guest"
8
+ import { acct } from "./account-theme"
9
+ import {
10
+ resolveOrderHistoryStatus,
11
+ type OrderHistoryStatusInput,
12
+ } from "./order-history-status"
13
+
14
+ export default function AccountGuestOrders({
15
+ orders,
16
+ countryCode,
17
+ }: {
18
+ orders?: HttpTypes.StoreOrder[] | { orders?: HttpTypes.StoreOrder[] } | null
19
+ countryCode: string
20
+ }) {
21
+ const safeOrders: HttpTypes.StoreOrder[] = Array.isArray(orders)
22
+ ? orders
23
+ : Array.isArray((orders as { orders?: HttpTypes.StoreOrder[] })?.orders)
24
+ ? ((orders as { orders: HttpTypes.StoreOrder[] }).orders)
25
+ : []
26
+
27
+ async function handleSignOut() {
28
+ await logoutGuest()
29
+ window.location.href = `/${countryCode}/account`
30
+ }
31
+
32
+ async function handleCheckDifferent() {
33
+ await logoutGuest()
34
+ window.location.href = `/${countryCode}/account?view=guest`
35
+ }
36
+
37
+ return (
38
+ <div className="sr-guest-orders space-y-6">
39
+ <div className="flex flex-wrap items-start justify-between gap-4">
40
+ <div>
41
+ <h2 className="sr-guest-orders__title font-heading text-2xl font-bold uppercase tracking-[0.08em] mb-1">
42
+ Guest orders
43
+ </h2>
44
+ <p className="sr-guest-orders__copy text-sm">
45
+ Track orders linked to your verified email.
46
+ </p>
47
+ </div>
48
+ <div className="flex flex-wrap gap-2">
49
+ <button
50
+ type="button"
51
+ onClick={handleCheckDifferent}
52
+ className="sr-guest-orders__btn"
53
+ >
54
+ Check different email
55
+ </button>
56
+ <button type="button" onClick={handleSignOut} className="sr-guest-orders__btn">
57
+ End guest session
58
+ </button>
59
+ </div>
60
+ </div>
61
+
62
+ {safeOrders.length === 0 ? (
63
+ <div className="sr-guest-orders__empty p-8 text-center">
64
+ <p className="sr-guest-orders__copy text-sm mb-4">No guest orders found for this session.</p>
65
+ <LocalizedLink href="/store" className={`${acct.btnPrimary} sr-guest-orders__shop`}>
66
+ Continue shopping
67
+ </LocalizedLink>
68
+ </div>
69
+ ) : (
70
+ <ul className="space-y-3">
71
+ {safeOrders.map((order) => (
72
+ <li key={order.id}>
73
+ <LocalizedLink
74
+ href={`/orders/${order.id}`}
75
+ className="sr-guest-orders__card p-5 flex items-center justify-between gap-4 block"
76
+ >
77
+ <div>
78
+ <p className="sr-guest-orders__order font-semibold text-sm">
79
+ Order #{order.display_id}
80
+ </p>
81
+ <p className="sr-guest-orders__status text-xs mt-1 capitalize">
82
+ {resolveOrderHistoryStatus(order as OrderHistoryStatusInput).label}
83
+ </p>
84
+ </div>
85
+ <p className="sr-guest-orders__total text-sm font-semibold shrink-0">
86
+ {formatPrice(
87
+ presentOrderLines(order).paidTotal,
88
+ order.currency_code
89
+ )}
90
+ </p>
91
+ </LocalizedLink>
92
+ </li>
93
+ ))}
94
+ </ul>
95
+ )}
96
+ </div>
97
+ )
98
+ }