@pradip1995/segment-login-template 0.5.25 → 0.5.26
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 +54 -54
- package/src/account-addresses.tsx +287 -287
- package/src/account-guest-orders.tsx +98 -98
- package/src/account-orders.tsx +260 -260
- package/src/account-overview.tsx +133 -133
- package/src/account-payment-methods.tsx +328 -328
- package/src/account-profile-logic.ts +282 -282
- package/src/account-profile.tsx +111 -111
- package/src/account-theme.ts +91 -91
- package/src/account-utils.ts +20 -20
- package/src/auth-server.ts +442 -442
- package/src/commerce-auth-otp-modal.css +125 -125
- package/src/commerce-auth-otp-modal.tsx +121 -121
- package/src/forgot-password-form.tsx +109 -109
- package/src/google-auth-section.tsx +22 -22
- package/src/google-sign-in-section.tsx +67 -67
- package/src/guest-order-modal.tsx +215 -215
- package/src/index.ts +7 -7
- package/src/is-next-redirect.ts +60 -60
- package/src/login-brand-panel.tsx +158 -158
- package/src/login-form.tsx +469 -469
- package/src/manifest.ts +11 -11
- package/src/order-history-status.test.ts +224 -224
- package/src/order-history-status.ts +244 -244
- package/src/otp-component.ts +14 -14
- package/src/otp-input.tsx +46 -46
- package/src/otp-unified-form.tsx +333 -333
- package/src/otp-verification-modal.tsx +112 -112
- package/src/payment-methods-actions.ts +243 -243
- package/src/profile-email-field.tsx +116 -116
- package/src/profile-email.test.ts +182 -182
- package/src/profile-email.ts +54 -54
- package/src/profile-phone-field.tsx +119 -119
- package/src/register-form.tsx +339 -339
- package/src/reorder-checkout-address.ts +101 -101
- package/src/reset-password-form.tsx +103 -103
- package/src/reset-password-page.tsx +12 -12
- 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
|
+
}
|