@pradip1995/segment-login-template 0.5.27 → 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.
- package/package.json +13 -9
- package/src/account-addresses.tsx +307 -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/address-actions.ts +74 -0
- package/src/auth-server.ts +442 -442
- package/src/card-expiry.test.ts +71 -0
- package/src/card-expiry.ts +29 -0
- package/src/commerce-auth-otp-modal.css +125 -125
- package/src/commerce-auth-otp-modal.tsx +121 -121
- package/src/default-address.test.ts +143 -0
- package/src/default-address.ts +51 -0
- 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-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 +103 -101
- package/src/reset-password-form.tsx +103 -103
- package/src/reset-password-page.tsx +12 -12
- package/src/segment.tsx +272 -272
package/src/account-profile.tsx
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import type { HttpTypes } from "@medusajs/types"
|
|
4
|
-
import type { OtpVerificationComponent } from "./otp-component"
|
|
5
|
-
import OtpVerificationModal from "./otp-verification-modal"
|
|
6
|
-
import { useAccountProfileLogic } from "./account-profile-logic"
|
|
7
|
-
import ProfilePhoneField from "./profile-phone-field"
|
|
8
|
-
import ProfileEmailField from "./profile-email-field"
|
|
9
|
-
import { acct } from "./account-theme"
|
|
10
|
-
|
|
11
|
-
export default function AccountProfile({
|
|
12
|
-
customer,
|
|
13
|
-
countryCode,
|
|
14
|
-
OtpComponent = OtpVerificationModal,
|
|
15
|
-
}: {
|
|
16
|
-
customer: HttpTypes.StoreCustomer
|
|
17
|
-
countryCode: string
|
|
18
|
-
OtpComponent?: OtpVerificationComponent
|
|
19
|
-
}) {
|
|
20
|
-
const profile = useAccountProfileLogic(customer, countryCode)
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<div className="space-y-8">
|
|
24
|
-
<div>
|
|
25
|
-
<h2 className={acct.title}>Account details</h2>
|
|
26
|
-
<p className={`text-sm ${acct.muted}`}>Update your name and contact information.</p>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<form action={profile.formAction} className={`${acct.card} p-6 space-y-4`}>
|
|
30
|
-
<Field label="Full name" name="full_name" defaultValue={profile.fullName} />
|
|
31
|
-
<ProfileEmailField
|
|
32
|
-
email={profile.email}
|
|
33
|
-
onEmailChange={profile.handleEmailChange}
|
|
34
|
-
emailVerified={profile.emailVerified}
|
|
35
|
-
emailError={profile.emailError}
|
|
36
|
-
verifyPending={profile.otpPending}
|
|
37
|
-
onVerify={() => profile.sendVerifyOtp("email_verification")}
|
|
38
|
-
verifyButtonClassName={`${acct.btnOutline} !py-2 !px-3`}
|
|
39
|
-
editButtonClassName={`${acct.btnOutline} !py-2 !px-3`}
|
|
40
|
-
/>
|
|
41
|
-
|
|
42
|
-
<ProfilePhoneField
|
|
43
|
-
phone={profile.phone}
|
|
44
|
-
onPhoneChange={profile.handlePhoneChange}
|
|
45
|
-
phoneVerified={profile.phoneVerified}
|
|
46
|
-
phoneReady={profile.phoneReady}
|
|
47
|
-
phoneError={profile.phoneError}
|
|
48
|
-
verifyPending={profile.otpPending}
|
|
49
|
-
onVerify={() => profile.sendVerifyOtp("phone_verification")}
|
|
50
|
-
verifyButtonClassName={`${acct.btnOutline} !py-2 !px-3`}
|
|
51
|
-
editButtonClassName={`${acct.btnOutline} !py-2 !px-3`}
|
|
52
|
-
/>
|
|
53
|
-
|
|
54
|
-
{(profile.state.error || profile.message) && (
|
|
55
|
-
<p
|
|
56
|
-
className={`text-sm ${profile.state.ok || profile.message ? "text-green-600" : "text-red-600"}`}
|
|
57
|
-
>
|
|
58
|
-
{profile.message || profile.state.error}
|
|
59
|
-
</p>
|
|
60
|
-
)}
|
|
61
|
-
|
|
62
|
-
<button type="submit" disabled={profile.pending} className={acct.btnPrimary}>
|
|
63
|
-
{profile.pending ? "Saving…" : "Save changes"}
|
|
64
|
-
</button>
|
|
65
|
-
</form>
|
|
66
|
-
|
|
67
|
-
<OtpComponent
|
|
68
|
-
open={profile.otpOpen}
|
|
69
|
-
title={
|
|
70
|
-
profile.otpType === "email_verification"
|
|
71
|
-
? "Verify your email"
|
|
72
|
-
: "Verify your phone"
|
|
73
|
-
}
|
|
74
|
-
description={`Enter the code sent to your ${profile.otpType === "email_verification" ? profile.email || "email" : "phone"}.`}
|
|
75
|
-
otp={profile.otp}
|
|
76
|
-
onOtpChange={profile.setOtp}
|
|
77
|
-
error={profile.otpError}
|
|
78
|
-
pending={profile.otpPending}
|
|
79
|
-
onVerify={profile.verifyOtp}
|
|
80
|
-
onResend={() => profile.sendVerifyOtp(profile.otpType)}
|
|
81
|
-
onClose={() => profile.setOtpOpen(false)}
|
|
82
|
-
/>
|
|
83
|
-
</div>
|
|
84
|
-
)
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function Field({
|
|
88
|
-
label,
|
|
89
|
-
name,
|
|
90
|
-
type = "text",
|
|
91
|
-
defaultValue,
|
|
92
|
-
}: {
|
|
93
|
-
label: string
|
|
94
|
-
name: string
|
|
95
|
-
type?: string
|
|
96
|
-
defaultValue?: string
|
|
97
|
-
}) {
|
|
98
|
-
return (
|
|
99
|
-
<label className="block">
|
|
100
|
-
<span className="text-xs font-semibold uppercase tracking-wider text-muted mb-1.5 block">
|
|
101
|
-
{label}
|
|
102
|
-
</span>
|
|
103
|
-
<input
|
|
104
|
-
name={name}
|
|
105
|
-
type={type}
|
|
106
|
-
defaultValue={defaultValue}
|
|
107
|
-
className="w-full border border-cart-border rounded-none px-3 py-2.5 text-sm bg-surface text-heading focus:outline-none focus:border-brand-accent"
|
|
108
|
-
/>
|
|
109
|
-
</label>
|
|
110
|
-
)
|
|
111
|
-
}
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import type { HttpTypes } from "@medusajs/types"
|
|
4
|
+
import type { OtpVerificationComponent } from "./otp-component"
|
|
5
|
+
import OtpVerificationModal from "./otp-verification-modal"
|
|
6
|
+
import { useAccountProfileLogic } from "./account-profile-logic"
|
|
7
|
+
import ProfilePhoneField from "./profile-phone-field"
|
|
8
|
+
import ProfileEmailField from "./profile-email-field"
|
|
9
|
+
import { acct } from "./account-theme"
|
|
10
|
+
|
|
11
|
+
export default function AccountProfile({
|
|
12
|
+
customer,
|
|
13
|
+
countryCode,
|
|
14
|
+
OtpComponent = OtpVerificationModal,
|
|
15
|
+
}: {
|
|
16
|
+
customer: HttpTypes.StoreCustomer
|
|
17
|
+
countryCode: string
|
|
18
|
+
OtpComponent?: OtpVerificationComponent
|
|
19
|
+
}) {
|
|
20
|
+
const profile = useAccountProfileLogic(customer, countryCode)
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<div className="space-y-8">
|
|
24
|
+
<div>
|
|
25
|
+
<h2 className={acct.title}>Account details</h2>
|
|
26
|
+
<p className={`text-sm ${acct.muted}`}>Update your name and contact information.</p>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<form action={profile.formAction} className={`${acct.card} p-6 space-y-4`}>
|
|
30
|
+
<Field label="Full name" name="full_name" defaultValue={profile.fullName} />
|
|
31
|
+
<ProfileEmailField
|
|
32
|
+
email={profile.email}
|
|
33
|
+
onEmailChange={profile.handleEmailChange}
|
|
34
|
+
emailVerified={profile.emailVerified}
|
|
35
|
+
emailError={profile.emailError}
|
|
36
|
+
verifyPending={profile.otpPending}
|
|
37
|
+
onVerify={() => profile.sendVerifyOtp("email_verification")}
|
|
38
|
+
verifyButtonClassName={`${acct.btnOutline} !py-2 !px-3`}
|
|
39
|
+
editButtonClassName={`${acct.btnOutline} !py-2 !px-3`}
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
<ProfilePhoneField
|
|
43
|
+
phone={profile.phone}
|
|
44
|
+
onPhoneChange={profile.handlePhoneChange}
|
|
45
|
+
phoneVerified={profile.phoneVerified}
|
|
46
|
+
phoneReady={profile.phoneReady}
|
|
47
|
+
phoneError={profile.phoneError}
|
|
48
|
+
verifyPending={profile.otpPending}
|
|
49
|
+
onVerify={() => profile.sendVerifyOtp("phone_verification")}
|
|
50
|
+
verifyButtonClassName={`${acct.btnOutline} !py-2 !px-3`}
|
|
51
|
+
editButtonClassName={`${acct.btnOutline} !py-2 !px-3`}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
{(profile.state.error || profile.message) && (
|
|
55
|
+
<p
|
|
56
|
+
className={`text-sm ${profile.state.ok || profile.message ? "text-green-600" : "text-red-600"}`}
|
|
57
|
+
>
|
|
58
|
+
{profile.message || profile.state.error}
|
|
59
|
+
</p>
|
|
60
|
+
)}
|
|
61
|
+
|
|
62
|
+
<button type="submit" disabled={profile.pending} className={acct.btnPrimary}>
|
|
63
|
+
{profile.pending ? "Saving…" : "Save changes"}
|
|
64
|
+
</button>
|
|
65
|
+
</form>
|
|
66
|
+
|
|
67
|
+
<OtpComponent
|
|
68
|
+
open={profile.otpOpen}
|
|
69
|
+
title={
|
|
70
|
+
profile.otpType === "email_verification"
|
|
71
|
+
? "Verify your email"
|
|
72
|
+
: "Verify your phone"
|
|
73
|
+
}
|
|
74
|
+
description={`Enter the code sent to your ${profile.otpType === "email_verification" ? profile.email || "email" : "phone"}.`}
|
|
75
|
+
otp={profile.otp}
|
|
76
|
+
onOtpChange={profile.setOtp}
|
|
77
|
+
error={profile.otpError}
|
|
78
|
+
pending={profile.otpPending}
|
|
79
|
+
onVerify={profile.verifyOtp}
|
|
80
|
+
onResend={() => profile.sendVerifyOtp(profile.otpType)}
|
|
81
|
+
onClose={() => profile.setOtpOpen(false)}
|
|
82
|
+
/>
|
|
83
|
+
</div>
|
|
84
|
+
)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function Field({
|
|
88
|
+
label,
|
|
89
|
+
name,
|
|
90
|
+
type = "text",
|
|
91
|
+
defaultValue,
|
|
92
|
+
}: {
|
|
93
|
+
label: string
|
|
94
|
+
name: string
|
|
95
|
+
type?: string
|
|
96
|
+
defaultValue?: string
|
|
97
|
+
}) {
|
|
98
|
+
return (
|
|
99
|
+
<label className="block">
|
|
100
|
+
<span className="text-xs font-semibold uppercase tracking-wider text-muted mb-1.5 block">
|
|
101
|
+
{label}
|
|
102
|
+
</span>
|
|
103
|
+
<input
|
|
104
|
+
name={name}
|
|
105
|
+
type={type}
|
|
106
|
+
defaultValue={defaultValue}
|
|
107
|
+
className="w-full border border-cart-border rounded-none px-3 py-2.5 text-sm bg-surface text-heading focus:outline-none focus:border-brand-accent"
|
|
108
|
+
/>
|
|
109
|
+
</label>
|
|
110
|
+
)
|
|
111
|
+
}
|
package/src/account-theme.ts
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
/** Logged-in account visual tokens — maps to segment-tokens CSS variables */
|
|
2
|
-
export const acct = {
|
|
3
|
-
pageBg: "bg-page-bg",
|
|
4
|
-
card: "bg-surface border border-cart-border rounded-none shadow-card",
|
|
5
|
-
cardMuted: "bg-surface-muted border border-cart-border rounded-none",
|
|
6
|
-
title:
|
|
7
|
-
"font-heading text-2xl sm:text-3xl font-extrabold tracking-tight text-heading",
|
|
8
|
-
sectionTitle:
|
|
9
|
-
"text-base sm:text-lg font-bold uppercase tracking-wider text-heading",
|
|
10
|
-
subsection: "text-sm font-semibold uppercase tracking-wider text-muted",
|
|
11
|
-
accent: "text-brand-accent",
|
|
12
|
-
muted: "text-muted",
|
|
13
|
-
heading: "text-heading",
|
|
14
|
-
body: "text-sm text-body",
|
|
15
|
-
border: "border-cart-border",
|
|
16
|
-
btnPrimary:
|
|
17
|
-
"inline-flex items-center justify-center bg-brand-primary hover:bg-brand-accent text-inverse rounded-none px-6 py-3 font-bold text-xs uppercase tracking-widest transition-all disabled:opacity-50",
|
|
18
|
-
btnAccent:
|
|
19
|
-
"inline-flex items-center justify-center bg-brand-accent hover:bg-brand-accent-hover text-inverse rounded-none px-6 py-3 font-bold text-xs uppercase tracking-widest transition-all disabled:opacity-50",
|
|
20
|
-
btnOutline:
|
|
21
|
-
"inline-flex items-center justify-center border border-cart-border text-brand-accent rounded-none px-6 py-3 font-bold text-xs uppercase tracking-widest hover:bg-surface-muted transition-all disabled:opacity-50",
|
|
22
|
-
input:
|
|
23
|
-
"w-full border border-cart-border rounded-none px-3 py-2.5 text-sm bg-surface text-heading focus:outline-none focus:border-brand-accent",
|
|
24
|
-
label:
|
|
25
|
-
"block text-xs font-semibold uppercase tracking-wider text-muted mb-1.5",
|
|
26
|
-
badge:
|
|
27
|
-
"inline-flex items-center px-3 py-1 text-xs font-semibold border rounded-none",
|
|
28
|
-
} as const
|
|
29
|
-
|
|
30
|
-
/** Auth / login visual tokens — maps to segment-tokens CSS variables (theme-safe) */
|
|
31
|
-
export const auth = {
|
|
32
|
-
viewport:
|
|
33
|
-
"w-full flex flex-col lg:flex-row overflow-hidden min-h-[calc(100svh-6.25rem)] lg:h-[calc(100svh-6.25rem)] lg:max-h-[calc(100svh-6.25rem)] bg-page-bg",
|
|
34
|
-
formColumn: "relative flex flex-1 flex-col min-h-0 w-full lg:w-1/2 bg-page-bg",
|
|
35
|
-
formWash:
|
|
36
|
-
"pointer-events-none absolute inset-y-0 -left-20 w-40 bg-gradient-to-r from-transparent to-page-bg hidden lg:block z-[1]",
|
|
37
|
-
formGlow:
|
|
38
|
-
"pointer-events-none absolute inset-0 bg-gradient-to-l from-brand-primary/[0.03] via-transparent to-transparent hidden lg:block",
|
|
39
|
-
formInner:
|
|
40
|
-
"relative z-[2] flex flex-1 flex-col justify-center min-h-0 overflow-y-auto overscroll-contain px-5 sm:px-10 md:px-12 lg:px-14 xl:px-20 py-5 sm:py-6 lg:py-8",
|
|
41
|
-
formCard:
|
|
42
|
-
"relative w-full max-w-[440px] shrink-0 border border-cart-border/60 bg-surface shadow-[0_10px_40px_-16px_rgba(0,0,0,0.12)] p-7 sm:p-8",
|
|
43
|
-
desktopHeader: "hidden lg:block mb-6 max-w-[440px] shrink-0",
|
|
44
|
-
title:
|
|
45
|
-
"font-heading text-2xl xl:text-[32px] font-bold text-heading uppercase tracking-[0.08em] leading-tight",
|
|
46
|
-
subtitle: "mt-2 text-[11px] font-medium text-muted uppercase tracking-[0.28em]",
|
|
47
|
-
mobileTitle:
|
|
48
|
-
"font-heading text-base font-bold text-heading uppercase tracking-[0.16em] lg:hidden",
|
|
49
|
-
fieldLabel:
|
|
50
|
-
"text-[10px] font-semibold text-heading/80 uppercase tracking-[0.22em]",
|
|
51
|
-
input:
|
|
52
|
-
"w-full px-0 py-3 text-sm text-heading bg-transparent border-0 border-b-2 border-cart-border rounded-none placeholder:text-muted/50 focus:outline-none focus:border-brand-primary focus:ring-0 transition-colors duration-200",
|
|
53
|
-
btnPrimary:
|
|
54
|
-
"group relative w-full inline-flex items-center justify-center py-3.5 bg-brand-primary text-inverse text-[11px] font-bold uppercase tracking-[0.28em] shadow-[0_8px_28px_-6px_rgba(0,0,0,0.25)] hover:bg-brand-accent hover:shadow-[0_12px_32px_-6px_rgba(0,0,0,0.3)] transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed overflow-hidden active:scale-[0.98]",
|
|
55
|
-
btnShine:
|
|
56
|
-
"before:absolute before:inset-0 before:bg-gradient-to-r before:from-transparent before:via-white/15 before:to-transparent before:-translate-x-full hover:before:translate-x-full before:transition-transform before:duration-700",
|
|
57
|
-
btnOutline:
|
|
58
|
-
"w-full flex items-center justify-center gap-2.5 py-3 border border-brand-primary/15 bg-surface/80 hover:bg-page-bg hover:border-brand-primary/35 shadow-sm transition-all duration-200 disabled:opacity-50",
|
|
59
|
-
guestCta:
|
|
60
|
-
"w-full py-3 border border-brand-primary/20 bg-gradient-to-r from-surface to-page-bg text-heading text-[10px] font-bold uppercase tracking-[0.18em] hover:border-brand-accent hover:shadow-[0_4px_16px_-4px_rgba(0,0,0,0.15)] transition-all duration-300 flex items-center justify-center gap-2 disabled:opacity-50 active:scale-[0.98]",
|
|
61
|
-
tabActive:
|
|
62
|
-
"pb-3 text-xs font-semibold uppercase tracking-[var(--letter-spacing-nav)] border-b-2 -mb-px border-brand-accent text-brand-accent transition-colors duration-200",
|
|
63
|
-
tabIdle:
|
|
64
|
-
"pb-3 text-xs font-semibold uppercase tracking-[var(--letter-spacing-nav)] border-b-2 -mb-px border-transparent text-muted hover:text-heading transition-colors duration-200",
|
|
65
|
-
modeActive:
|
|
66
|
-
"flex-1 py-2 text-xs font-semibold uppercase tracking-[var(--letter-spacing-nav)] rounded-md bg-surface text-heading shadow-sm transition-colors duration-200",
|
|
67
|
-
modeIdle:
|
|
68
|
-
"flex-1 py-2 text-xs font-semibold uppercase tracking-[var(--letter-spacing-nav)] rounded-md text-muted hover:text-heading transition-colors duration-200",
|
|
69
|
-
chipActive:
|
|
70
|
-
"px-3 py-1.5 text-xs font-medium border border-brand-accent text-brand-accent bg-brand-accent/5 transition-colors duration-200",
|
|
71
|
-
chipIdle:
|
|
72
|
-
"px-3 py-1.5 text-xs font-medium border border-cart-border text-muted hover:text-heading transition-colors duration-200",
|
|
73
|
-
} as const
|
|
74
|
-
|
|
75
|
-
export type BrandFeatureCard = {
|
|
76
|
-
imageSrc?: string | null
|
|
77
|
-
title: string
|
|
78
|
-
text: string
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export type BrandPanelConfig = {
|
|
82
|
-
image?: string | null
|
|
83
|
-
logo?: string | null
|
|
84
|
-
eyebrow?: string | null
|
|
85
|
-
headline?: string | null
|
|
86
|
-
/** Sahsha alias for headline */
|
|
87
|
-
title?: string | null
|
|
88
|
-
description?: string | null
|
|
89
|
-
featuresLabel?: string | null
|
|
90
|
-
featureCards?: BrandFeatureCard[] | null
|
|
91
|
-
}
|
|
1
|
+
/** Logged-in account visual tokens — maps to segment-tokens CSS variables */
|
|
2
|
+
export const acct = {
|
|
3
|
+
pageBg: "bg-page-bg",
|
|
4
|
+
card: "bg-surface border border-cart-border rounded-none shadow-card",
|
|
5
|
+
cardMuted: "bg-surface-muted border border-cart-border rounded-none",
|
|
6
|
+
title:
|
|
7
|
+
"font-heading text-2xl sm:text-3xl font-extrabold tracking-tight text-heading",
|
|
8
|
+
sectionTitle:
|
|
9
|
+
"text-base sm:text-lg font-bold uppercase tracking-wider text-heading",
|
|
10
|
+
subsection: "text-sm font-semibold uppercase tracking-wider text-muted",
|
|
11
|
+
accent: "text-brand-accent",
|
|
12
|
+
muted: "text-muted",
|
|
13
|
+
heading: "text-heading",
|
|
14
|
+
body: "text-sm text-body",
|
|
15
|
+
border: "border-cart-border",
|
|
16
|
+
btnPrimary:
|
|
17
|
+
"inline-flex items-center justify-center bg-brand-primary hover:bg-brand-accent text-inverse rounded-none px-6 py-3 font-bold text-xs uppercase tracking-widest transition-all disabled:opacity-50",
|
|
18
|
+
btnAccent:
|
|
19
|
+
"inline-flex items-center justify-center bg-brand-accent hover:bg-brand-accent-hover text-inverse rounded-none px-6 py-3 font-bold text-xs uppercase tracking-widest transition-all disabled:opacity-50",
|
|
20
|
+
btnOutline:
|
|
21
|
+
"inline-flex items-center justify-center border border-cart-border text-brand-accent rounded-none px-6 py-3 font-bold text-xs uppercase tracking-widest hover:bg-surface-muted transition-all disabled:opacity-50",
|
|
22
|
+
input:
|
|
23
|
+
"w-full border border-cart-border rounded-none px-3 py-2.5 text-sm bg-surface text-heading focus:outline-none focus:border-brand-accent",
|
|
24
|
+
label:
|
|
25
|
+
"block text-xs font-semibold uppercase tracking-wider text-muted mb-1.5",
|
|
26
|
+
badge:
|
|
27
|
+
"inline-flex items-center px-3 py-1 text-xs font-semibold border rounded-none",
|
|
28
|
+
} as const
|
|
29
|
+
|
|
30
|
+
/** Auth / login visual tokens — maps to segment-tokens CSS variables (theme-safe) */
|
|
31
|
+
export const auth = {
|
|
32
|
+
viewport:
|
|
33
|
+
"w-full flex flex-col lg:flex-row overflow-hidden min-h-[calc(100svh-6.25rem)] lg:h-[calc(100svh-6.25rem)] lg:max-h-[calc(100svh-6.25rem)] bg-page-bg",
|
|
34
|
+
formColumn: "relative flex flex-1 flex-col min-h-0 w-full lg:w-1/2 bg-page-bg",
|
|
35
|
+
formWash:
|
|
36
|
+
"pointer-events-none absolute inset-y-0 -left-20 w-40 bg-gradient-to-r from-transparent to-page-bg hidden lg:block z-[1]",
|
|
37
|
+
formGlow:
|
|
38
|
+
"pointer-events-none absolute inset-0 bg-gradient-to-l from-brand-primary/[0.03] via-transparent to-transparent hidden lg:block",
|
|
39
|
+
formInner:
|
|
40
|
+
"relative z-[2] flex flex-1 flex-col justify-center min-h-0 overflow-y-auto overscroll-contain px-5 sm:px-10 md:px-12 lg:px-14 xl:px-20 py-5 sm:py-6 lg:py-8",
|
|
41
|
+
formCard:
|
|
42
|
+
"relative w-full max-w-[440px] shrink-0 border border-cart-border/60 bg-surface shadow-[0_10px_40px_-16px_rgba(0,0,0,0.12)] p-7 sm:p-8",
|
|
43
|
+
desktopHeader: "hidden lg:block mb-6 max-w-[440px] shrink-0",
|
|
44
|
+
title:
|
|
45
|
+
"font-heading text-2xl xl:text-[32px] font-bold text-heading uppercase tracking-[0.08em] leading-tight",
|
|
46
|
+
subtitle: "mt-2 text-[11px] font-medium text-muted uppercase tracking-[0.28em]",
|
|
47
|
+
mobileTitle:
|
|
48
|
+
"font-heading text-base font-bold text-heading uppercase tracking-[0.16em] lg:hidden",
|
|
49
|
+
fieldLabel:
|
|
50
|
+
"text-[10px] font-semibold text-heading/80 uppercase tracking-[0.22em]",
|
|
51
|
+
input:
|
|
52
|
+
"w-full px-0 py-3 text-sm text-heading bg-transparent border-0 border-b-2 border-cart-border rounded-none placeholder:text-muted/50 focus:outline-none focus:border-brand-primary focus:ring-0 transition-colors duration-200",
|
|
53
|
+
btnPrimary:
|
|
54
|
+
"group relative w-full inline-flex items-center justify-center py-3.5 bg-brand-primary text-inverse text-[11px] font-bold uppercase tracking-[0.28em] shadow-[0_8px_28px_-6px_rgba(0,0,0,0.25)] hover:bg-brand-accent hover:shadow-[0_12px_32px_-6px_rgba(0,0,0,0.3)] transition-all duration-300 disabled:opacity-50 disabled:cursor-not-allowed overflow-hidden active:scale-[0.98]",
|
|
55
|
+
btnShine:
|
|
56
|
+
"before:absolute before:inset-0 before:bg-gradient-to-r before:from-transparent before:via-white/15 before:to-transparent before:-translate-x-full hover:before:translate-x-full before:transition-transform before:duration-700",
|
|
57
|
+
btnOutline:
|
|
58
|
+
"w-full flex items-center justify-center gap-2.5 py-3 border border-brand-primary/15 bg-surface/80 hover:bg-page-bg hover:border-brand-primary/35 shadow-sm transition-all duration-200 disabled:opacity-50",
|
|
59
|
+
guestCta:
|
|
60
|
+
"w-full py-3 border border-brand-primary/20 bg-gradient-to-r from-surface to-page-bg text-heading text-[10px] font-bold uppercase tracking-[0.18em] hover:border-brand-accent hover:shadow-[0_4px_16px_-4px_rgba(0,0,0,0.15)] transition-all duration-300 flex items-center justify-center gap-2 disabled:opacity-50 active:scale-[0.98]",
|
|
61
|
+
tabActive:
|
|
62
|
+
"pb-3 text-xs font-semibold uppercase tracking-[var(--letter-spacing-nav)] border-b-2 -mb-px border-brand-accent text-brand-accent transition-colors duration-200",
|
|
63
|
+
tabIdle:
|
|
64
|
+
"pb-3 text-xs font-semibold uppercase tracking-[var(--letter-spacing-nav)] border-b-2 -mb-px border-transparent text-muted hover:text-heading transition-colors duration-200",
|
|
65
|
+
modeActive:
|
|
66
|
+
"flex-1 py-2 text-xs font-semibold uppercase tracking-[var(--letter-spacing-nav)] rounded-md bg-surface text-heading shadow-sm transition-colors duration-200",
|
|
67
|
+
modeIdle:
|
|
68
|
+
"flex-1 py-2 text-xs font-semibold uppercase tracking-[var(--letter-spacing-nav)] rounded-md text-muted hover:text-heading transition-colors duration-200",
|
|
69
|
+
chipActive:
|
|
70
|
+
"px-3 py-1.5 text-xs font-medium border border-brand-accent text-brand-accent bg-brand-accent/5 transition-colors duration-200",
|
|
71
|
+
chipIdle:
|
|
72
|
+
"px-3 py-1.5 text-xs font-medium border border-cart-border text-muted hover:text-heading transition-colors duration-200",
|
|
73
|
+
} as const
|
|
74
|
+
|
|
75
|
+
export type BrandFeatureCard = {
|
|
76
|
+
imageSrc?: string | null
|
|
77
|
+
title: string
|
|
78
|
+
text: string
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export type BrandPanelConfig = {
|
|
82
|
+
image?: string | null
|
|
83
|
+
logo?: string | null
|
|
84
|
+
eyebrow?: string | null
|
|
85
|
+
headline?: string | null
|
|
86
|
+
/** Sahsha alias for headline */
|
|
87
|
+
title?: string | null
|
|
88
|
+
description?: string | null
|
|
89
|
+
featuresLabel?: string | null
|
|
90
|
+
featureCards?: BrandFeatureCard[] | null
|
|
91
|
+
}
|
package/src/account-utils.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import type { HttpTypes } from "@medusajs/types"
|
|
2
|
-
|
|
3
|
-
export function getProfileCompletion(customer: HttpTypes.StoreCustomer): number {
|
|
4
|
-
let score = 0
|
|
5
|
-
if (customer.first_name?.trim()) score += 25
|
|
6
|
-
if (customer.last_name?.trim()) score += 25
|
|
7
|
-
if (customer.email?.trim()) score += 25
|
|
8
|
-
if (customer.phone?.trim()) score += 25
|
|
9
|
-
return score
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function customerDisplayName(customer: HttpTypes.StoreCustomer): string {
|
|
13
|
-
return [customer.first_name, customer.last_name].filter(Boolean).join(" ") || customer.email || "Account"
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function accountSectionPath(path?: string): string {
|
|
17
|
-
if (!path || path === "login") return "overview"
|
|
18
|
-
const base = path.split("/")[0]
|
|
19
|
-
return base || "overview"
|
|
20
|
-
}
|
|
1
|
+
import type { HttpTypes } from "@medusajs/types"
|
|
2
|
+
|
|
3
|
+
export function getProfileCompletion(customer: HttpTypes.StoreCustomer): number {
|
|
4
|
+
let score = 0
|
|
5
|
+
if (customer.first_name?.trim()) score += 25
|
|
6
|
+
if (customer.last_name?.trim()) score += 25
|
|
7
|
+
if (customer.email?.trim()) score += 25
|
|
8
|
+
if (customer.phone?.trim()) score += 25
|
|
9
|
+
return score
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function customerDisplayName(customer: HttpTypes.StoreCustomer): string {
|
|
13
|
+
return [customer.first_name, customer.last_name].filter(Boolean).join(" ") || customer.email || "Account"
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function accountSectionPath(path?: string): string {
|
|
17
|
+
if (!path || path === "login") return "overview"
|
|
18
|
+
const base = path.split("/")[0]
|
|
19
|
+
return base || "overview"
|
|
20
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use server"
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
retrieveCustomer,
|
|
5
|
+
setDefaultAddress,
|
|
6
|
+
} from "@pradip1995/commerce-core/data/customer"
|
|
7
|
+
import { findMatchingAddressId } from "./default-address"
|
|
8
|
+
|
|
9
|
+
type ActionResult = { success: boolean; error: string | null }
|
|
10
|
+
|
|
11
|
+
/** Sets this address as the default shipping address. Medusa unsets the previous shipping default. */
|
|
12
|
+
export async function setExclusiveDefaultAddress(addressId: string): Promise<ActionResult> {
|
|
13
|
+
if (!addressId) {
|
|
14
|
+
return { success: false, error: "Address id is required" }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
const result = await setDefaultAddress(addressId)
|
|
19
|
+
if (!result?.success) {
|
|
20
|
+
return {
|
|
21
|
+
success: false,
|
|
22
|
+
error: result?.error || "Failed to set default address",
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return { success: true, error: null }
|
|
26
|
+
} catch (err) {
|
|
27
|
+
return {
|
|
28
|
+
success: false,
|
|
29
|
+
error: err instanceof Error ? err.message : "Failed to set default address",
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* After create/update, force one shipping default.
|
|
36
|
+
* Prefers an explicit address id; otherwise matches the just-saved fields.
|
|
37
|
+
*/
|
|
38
|
+
export async function ensureExclusiveDefaultAddress(input: {
|
|
39
|
+
addressId?: string
|
|
40
|
+
address_1?: string
|
|
41
|
+
postal_code?: string
|
|
42
|
+
phone?: string
|
|
43
|
+
}): Promise<ActionResult> {
|
|
44
|
+
let addressId = input.addressId?.trim() || ""
|
|
45
|
+
|
|
46
|
+
if (!addressId) {
|
|
47
|
+
const address1 = input.address_1?.trim() || ""
|
|
48
|
+
const postal = input.postal_code?.trim() || ""
|
|
49
|
+
if (!address1 || !postal) {
|
|
50
|
+
return { success: false, error: "Address id is required" }
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
const customer = await retrieveCustomer()
|
|
55
|
+
addressId =
|
|
56
|
+
findMatchingAddressId(customer?.addresses ?? [], {
|
|
57
|
+
address_1: address1,
|
|
58
|
+
postal_code: postal,
|
|
59
|
+
phone: input.phone,
|
|
60
|
+
}) || ""
|
|
61
|
+
} catch (err) {
|
|
62
|
+
return {
|
|
63
|
+
success: false,
|
|
64
|
+
error: err instanceof Error ? err.message : "Failed to load addresses",
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!addressId) {
|
|
70
|
+
return { success: false, error: "Could not find the saved address to set as default" }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return setExclusiveDefaultAddress(addressId)
|
|
74
|
+
}
|