Skip to content

Commit c764397

Browse files
committed
modules/account
1 parent c1b17f2 commit c764397

File tree

30 files changed

+374
-150
lines changed

30 files changed

+374
-150
lines changed

src/locales/us.ts

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ export default {
55
"nav.account": "Account",
66
"nav.cart": "Cart",
77

8+
"cart.subtotal": "Subtotal",
9+
"cart.discount": "Discount",
10+
"cart.shipping": "Shipping",
11+
"cart.giftcard": "Gift card",
12+
"cart.total": "Total",
13+
"cart.": "",
14+
815
"cart.dropdown.cart": "Cart ({count})",
916
"cart.dropdown.quantity": "Quantity: ",
1017
"cart.dropdown.remove": "Remove",
@@ -90,6 +97,82 @@ export default {
9097
"help.contact": "Contact",
9198
"help.returns": "Returns & Exchanges",
9299

100+
"account.save": "Save changes",
101+
"account.updated": " updated succesfully",
102+
"account.cancel": "Cancel",
103+
"account.edit": "Edit",
104+
"account.account": "Account",
105+
"account.overview": "Overview",
106+
"account.profile": "Profile",
107+
"account.addresses": "Addresses",
108+
"account.orders": "Orders",
109+
"account.logout": "Log out",
110+
111+
"account.address.new": "New address",
112+
"account.address.add": "Add address",
113+
"account.address.save": "Save",
114+
"account.address.edit": "Edit",
115+
"account.address.remove": "Remove",
116+
"account.address.editaddress": "Edit address",
117+
"account.address.cancel": "Cancel",
118+
"account.address.name": "Name",
119+
"account.address.first_name": "First name",
120+
"account.address.last_name": "Last name",
121+
"account.address.company": "Company",
122+
"account.address.address-line1": "Address",
123+
"account.address.address-line2": "Apartment, suite, etc.",
124+
"account.address.postal_code": "Postal code",
125+
"account.address.city": "City",
126+
"account.address.province": "Province / State",
127+
"account.address.country_code": "Country",
128+
"account.address.phone": "Phone",
129+
"account.address.same_as_billing": "Billing address same as shipping address",
130+
"account.address.billing_address": "Billing address",
131+
"account.address.no_billing_address": "No billing address",
132+
"account.address.email": "E-mail",
133+
134+
"account.password": "Password",
135+
"account.old_password": "Old password",
136+
"account.new_password": "New password",
137+
"account.confirm_password": "Confirm password",
138+
139+
"account.register.register_title": "Become a member",
140+
"account.register.register_desc": "Create your store member profile, and get access to an enhanced shopping experience.",
141+
"account.register.aggreement": "By creating an account, you agree to the Store's ",
142+
"account.register.pp": "Privacy Policy",
143+
"account.register.and": "and",
144+
"account.register.tou": "Terms of Use",
145+
"account.register.join": "Join",
146+
"account.register.member": "Already a member?",
147+
148+
"account.login.welcome": "Welcome back",
149+
"account.login.welcome_desc": "Sign in to access an enhanced shopping experience.",
150+
"account.login.email": "Email",
151+
"account.login.email_desc": "Enter a valid email address.",
152+
"account.login.password": "Password",
153+
"account.login.signin": "Sign in",
154+
"account.login.notamember": "Not a member?",
155+
"account.login.join": "Join us",
156+
"account.orders.details": "See details",
157+
"account.orders.more": " more",
158+
"account.orders.noorder": "Nothing to see here",
159+
"account.orders.noorder_desc": "You don't have any orders yet, let us change that",
160+
"account.orders.continueshopping": "Continue shopping",
161+
"account.question": "Got questions?",
162+
"account.question_desc": "You can find frequently asked questions and answers on our customer service page.",
163+
"account.service": "Customer Service",
164+
"account.overview.hello": "Hello ",
165+
"account.overview.signedinas": "Signed in as:",
166+
"account.overview.completed": "Completed",
167+
"account.overview.addresses": "Addresses",
168+
"account.overview.saved": "Saved",
169+
"account.overview.recent": "Recent orders",
170+
"account.overview.ordernumber": "Order number",
171+
"account.overview.total": "Total amount",
172+
"account.overview.goto": "Go to order ",
173+
"account.overview.norecent": "No recent orders",
174+
"account.": "",
175+
93176
"footer.store": "Medusa Store",
94177
"footer.categories": "Categories",
95178
"footer.collections": "Collections",

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

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
"use client"
2+
13
import { Disclosure } from "@headlessui/react"
24
import { Badge, Button, clx } from "@medusajs/ui"
35
import { useEffect } from "react"
46

7+
import { useScopedI18n } from "../../../../locales/client"
8+
59
import useToggleState from "@lib/hooks/use-toggle-state"
610
import { useFormStatus } from "react-dom"
711

@@ -13,7 +17,7 @@ type AccountInfoProps = {
1317
errorMessage?: string
1418
clearState: () => void
1519
children?: React.ReactNode
16-
'data-testid'?: string
20+
"data-testid"?: string
1721
}
1822

1923
const AccountInfo = ({
@@ -24,7 +28,7 @@ const AccountInfo = ({
2428
clearState,
2529
errorMessage = "An error occurred, please try again",
2630
children,
27-
'data-testid': dataTestid
31+
"data-testid": dataTestid,
2832
}: AccountInfoProps) => {
2933
const { state, close, toggle } = useToggleState()
3034

@@ -41,14 +45,18 @@ const AccountInfo = ({
4145
}
4246
}, [isSuccess, close])
4347

48+
const t = useScopedI18n("account")
49+
4450
return (
4551
<div className="text-small-regular" data-testid={dataTestid}>
4652
<div className="flex items-end justify-between">
4753
<div className="flex flex-col">
4854
<span className="uppercase text-ui-fg-base">{label}</span>
4955
<div className="flex items-center flex-1 basis-0 justify-end gap-x-4">
5056
{typeof currentInfo === "string" ? (
51-
<span className="font-semibold" data-testid="current-info">{currentInfo}</span>
57+
<span className="font-semibold" data-testid="current-info">
58+
{currentInfo}
59+
</span>
5260
) : (
5361
currentInfo
5462
)}
@@ -63,7 +71,7 @@ const AccountInfo = ({
6371
data-testid="edit-button"
6472
data-active={state}
6573
>
66-
{state ? "Cancel" : "Edit"}
74+
{state ? t("cancel") : t("edit")}
6775
</Button>
6876
</div>
6977
</div>
@@ -82,7 +90,9 @@ const AccountInfo = ({
8290
data-testid="success-message"
8391
>
8492
<Badge className="p-2 my-4" color="green">
85-
<span>{label} updated succesfully</span>
93+
<span>
94+
{label} {t("updated")}
95+
</span>
8696
</Badge>
8797
</Disclosure.Panel>
8898
</Disclosure>
@@ -126,7 +136,7 @@ const AccountInfo = ({
126136
type="submit"
127137
data-testid="save-button"
128138
>
129-
Save changes
139+
{t("save")}
130140
</Button>
131141
</div>
132142
</div>

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

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { clx } from "@medusajs/ui"
55
import { ArrowRightOnRectangle } from "@medusajs/icons"
66
import { useParams, usePathname } from "next/navigation"
77

8+
import { useScopedI18n } from '../../../../locales/client'
9+
810
import ChevronDown from "@modules/common/icons/chevron-down"
911
import { signOut } from "@modules/account/actions"
1012
import User from "@modules/common/icons/user"
@@ -23,6 +25,8 @@ const AccountNav = ({
2325
const handleLogout = async () => {
2426
await signOut(countryCode)
2527
}
28+
29+
const t = useScopedI18n("account")
2630

2731
return (
2832
<div>
@@ -35,13 +39,13 @@ const AccountNav = ({
3539
>
3640
<>
3741
<ChevronDown className="transform rotate-90" />
38-
<span>Account</span>
42+
<span>{t("account")}</span>
3943
</>
4044
</LocalizedClientLink>
4145
) : (
4246
<>
4347
<div className="text-xl-semi mb-4 px-8">
44-
Hello {customer?.first_name}
48+
{t("")}Hello {customer?.first_name}
4549
</div>
4650
<div className="text-base-regular">
4751
<ul>
@@ -54,7 +58,7 @@ const AccountNav = ({
5458
<>
5559
<div className="flex items-center gap-x-2">
5660
<User size={20} />
57-
<span>Profile</span>
61+
<span>{t("")}Profile</span>
5862
</div>
5963
<ChevronDown className="transform -rotate-90" />
6064
</>
@@ -69,7 +73,7 @@ const AccountNav = ({
6973
<>
7074
<div className="flex items-center gap-x-2">
7175
<MapPin size={20} />
72-
<span>Addresses</span>
76+
<span>{t("")}Addresses</span>
7377
</div>
7478
<ChevronDown className="transform -rotate-90" />
7579
</>
@@ -83,7 +87,7 @@ const AccountNav = ({
8387
>
8488
<div className="flex items-center gap-x-2">
8589
<Package size={20} />
86-
<span>Orders</span>
90+
<span>{t("")}Orders</span>
8791
</div>
8892
<ChevronDown className="transform -rotate-90" />
8993
</LocalizedClientLink>
@@ -97,7 +101,7 @@ const AccountNav = ({
97101
>
98102
<div className="flex items-center gap-x-2">
99103
<ArrowRightOnRectangle />
100-
<span>Log out</span>
104+
<span>{t("")}Log out</span>
101105
</div>
102106
<ChevronDown className="transform -rotate-90" />
103107
</button>
@@ -110,7 +114,7 @@ const AccountNav = ({
110114
<div className="hidden small:block" data-testid="account-nav">
111115
<div>
112116
<div className="pb-4">
113-
<h3 className="text-base-semi">Account</h3>
117+
<h3 className="text-base-semi">{t("account")}</h3>
114118
</div>
115119
<div className="text-base-regular">
116120
<ul className="flex mb-0 justify-start items-start flex-col gap-y-4">
@@ -120,7 +124,7 @@ const AccountNav = ({
120124
route={route!}
121125
data-testid="overview-link"
122126
>
123-
Overview
127+
{t("overview")}
124128
</AccountNavLink>
125129
</li>
126130
<li>
@@ -129,7 +133,7 @@ const AccountNav = ({
129133
route={route!}
130134
data-testid="profile-link"
131135
>
132-
Profile
136+
{t("profile")}
133137
</AccountNavLink>
134138
</li>
135139
<li>
@@ -138,7 +142,7 @@ const AccountNav = ({
138142
route={route!}
139143
data-testid="addresses-link"
140144
>
141-
Addresses
145+
{t("addresses")}
142146
</AccountNavLink>
143147
</li>
144148
<li>
@@ -147,7 +151,7 @@ const AccountNav = ({
147151
route={route!}
148152
data-testid="orders-link"
149153
>
150-
Orders
154+
{t("orders")}
151155
</AccountNavLink>
152156
</li>
153157
<li className="text-grey-700">
@@ -156,7 +160,7 @@ const AccountNav = ({
156160
onClick={handleLogout}
157161
data-testid="logout-button"
158162
>
159-
Log out
163+
{t("logout")}
160164
</button>
161165
</li>
162166
</ul>

src/modules/account/components/address-book/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
"use client"
2+
13
import { Customer, Region } from "@medusajs/medusa"
24
import React from "react"
35

0 commit comments

Comments
 (0)