Skip to content

Commit 23766a5

Browse files
committed
fix: signOut redirect bug
1 parent 8bdad11 commit 23766a5

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

src/modules/account/actions.ts

+2-6
Original file line numberDiff line numberDiff line change
@@ -262,15 +262,11 @@ export async function updateCustomerBillingAddress(
262262
}
263263
}
264264

265-
export async function signOut() {
265+
export async function signOut(countryCode: string) {
266266
cookies().set("_medusa_jwt", "", {
267267
maxAge: -1,
268268
})
269-
const nextUrl = headers().get("next-url")
270-
const countryCode = nextUrl?.split("/")[1] || ""
271269
revalidateTag("auth")
272270
revalidateTag("customer")
273-
if (nextUrl) {
274-
redirect(`/${countryCode}/account`)
275-
}
271+
redirect(`/${countryCode}/account`)
276272
}

src/modules/account/components/account-nav/index.tsx

+27-7
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ const AccountNav = ({
1818
customer: Omit<Customer, "password_hash"> | null
1919
}) => {
2020
const route = usePathname()
21-
const { countryCode } = useParams()
21+
const { countryCode } = useParams() as { countryCode: string }
2222

2323
const handleLogout = async () => {
24-
await signOut()
24+
await signOut(countryCode)
2525
}
2626

2727
return (
@@ -114,27 +114,47 @@ const AccountNav = ({
114114
<div className="text-base-regular">
115115
<ul className="flex mb-0 justify-start items-start flex-col gap-y-4">
116116
<li>
117-
<AccountNavLink href="/account" route={route!} data-testid="overview-link">
117+
<AccountNavLink
118+
href="/account"
119+
route={route!}
120+
data-testid="overview-link"
121+
>
118122
Overview
119123
</AccountNavLink>
120124
</li>
121125
<li>
122-
<AccountNavLink href="/account/profile" route={route!} data-testid="profile-link">
126+
<AccountNavLink
127+
href="/account/profile"
128+
route={route!}
129+
data-testid="profile-link"
130+
>
123131
Profile
124132
</AccountNavLink>
125133
</li>
126134
<li>
127-
<AccountNavLink href="/account/addresses" route={route!} data-testid="addresses-link">
135+
<AccountNavLink
136+
href="/account/addresses"
137+
route={route!}
138+
data-testid="addresses-link"
139+
>
128140
Addresses
129141
</AccountNavLink>
130142
</li>
131143
<li>
132-
<AccountNavLink href="/account/orders" route={route!} data-testid="orders-link">
144+
<AccountNavLink
145+
href="/account/orders"
146+
route={route!}
147+
data-testid="orders-link"
148+
>
133149
Orders
134150
</AccountNavLink>
135151
</li>
136152
<li className="text-grey-700">
137-
<button type="button" onClick={handleLogout} data-testid="logout-button">
153+
<button
154+
type="button"
155+
onClick={handleLogout}
156+
data-testid="logout-button"
157+
>
138158
Log out
139159
</button>
140160
</li>

0 commit comments

Comments
 (0)