Skip to content

Commit c8af778

Browse files
committed
modules/cart
1 parent c764397 commit c8af778

File tree

8 files changed

+68
-22
lines changed

8 files changed

+68
-22
lines changed

src/locales/us.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,21 @@ export default {
1010
"cart.shipping": "Shipping",
1111
"cart.giftcard": "Gift card",
1212
"cart.total": "Total",
13+
"cart.summary": "Summary",
14+
"cart.checkout": "Go to checkout",
15+
"cart.cart": "Cart",
16+
"cart.item": "Item",
17+
"cart.price": "Price",
18+
"cart.quantity": "Quantity",
19+
"cart.signin.prompt1": "Already have an account?",
20+
"cart.signin.prompt2": "Sign in for a better experience.",
21+
"cart.signin.signin": "Sign in",
22+
"cart.select": "Select...",
23+
"cart.empty_prompt1": "You don't have anything in your cart. Let's change that, use the link below to start browsing our products.",
24+
"cart.empty_prompt2": "Explore products",
1325
"cart.": "",
1426

27+
1528
"cart.dropdown.cart": "Cart ({count})",
1629
"cart.dropdown.quantity": "Quantity: ",
1730
"cart.dropdown.remove": "Remove",

src/modules/cart/components/cart-item-select/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import {
1010
useState,
1111
} from "react"
1212

13+
import { useScopedI18n } from "../../../../locales/client"
14+
1315
import ChevronDown from "@modules/common/icons/chevron-down"
1416

1517
type NativeSelectProps = {
@@ -19,7 +21,10 @@ type NativeSelectProps = {
1921
} & Omit<SelectHTMLAttributes<HTMLSelectElement>, "size">
2022

2123
const CartItemSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(
22-
({ placeholder = "Select...", className, children, ...props }, ref) => {
24+
({ placeholder = null, className, children, ...props }, ref) => {
25+
const t = useScopedI18n("cart")
26+
placeholder = placeholder || t("select")
27+
2328
const innerRef = useRef<HTMLSelectElement>(null)
2429
const [isPlaceholder, setIsPlaceholder] = useState(false)
2530

src/modules/cart/components/empty-cart-message/index.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
import { Heading, Text } from "@medusajs/ui"
1+
"use client"
22

3+
import { Heading, Text } from "@medusajs/ui"
34
import InteractiveLink from "@modules/common/components/interactive-link"
5+
import { useScopedI18n } from "../../../../locales/client"
46

57
const EmptyCartMessage = () => {
8+
const t = useScopedI18n("cart")
9+
610
return (
7-
<div className="py-48 px-2 flex flex-col justify-center items-start" data-testid="empty-cart-message">
11+
<div
12+
className="py-48 px-2 flex flex-col justify-center items-start"
13+
data-testid="empty-cart-message"
14+
>
815
<Heading
916
level="h1"
1017
className="flex flex-row text-3xl-regular gap-x-2 items-baseline"
1118
>
12-
Cart
19+
{t("cart")}
1320
</Heading>
1421
<Text className="text-base-regular mt-4 mb-6 max-w-[32rem]">
15-
You don&apos;t have anything in your cart. Let&apos;s change that, use
16-
the link below to start browsing our products.
22+
{t("empty_prompt1")}
1723
</Text>
1824
<div>
19-
<InteractiveLink href="/store">Explore products</InteractiveLink>
25+
<InteractiveLink href="/store">{t("empty_prompt2")}</InteractiveLink>
2026
</div>
2127
</div>
2228
)

src/modules/cart/components/sign-in-prompt/index.tsx

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1+
"use client"
2+
3+
import { useScopedI18n } from "../../../../locales/client"
4+
15
import { Button, Heading, Text } from "@medusajs/ui"
26
import LocalizedClientLink from "@modules/common/components/localized-client-link"
37

48
const SignInPrompt = () => {
9+
const t = useScopedI18n("cart.signin")
10+
511
return (
612
<div className="bg-white flex items-center justify-between">
713
<div>
814
<Heading level="h2" className="txt-xlarge">
9-
Already have an account?
15+
{t("prompt1")}
1016
</Heading>
1117
<Text className="txt-medium text-ui-fg-subtle mt-2">
12-
Sign in for a better experience.
18+
{t("prompt2")}
1319
</Text>
1420
</div>
1521
<div>
1622
<LocalizedClientLink href="/account">
17-
<Button variant="secondary" className="h-10" data-testid="sign-in-button">
18-
Sign in
23+
<Button
24+
variant="secondary"
25+
className="h-10"
26+
data-testid="sign-in-button"
27+
>
28+
{t("signin")}
1929
</Button>
2030
</LocalizedClientLink>
2131
</div>

src/modules/cart/templates/items.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
"use client"
2+
13
import { LineItem, Region } from "@medusajs/medusa"
24
import { Heading, Table } from "@medusajs/ui"
35

6+
import { useScopedI18n } from "../../../locales/client"
7+
48
import Item from "@modules/cart/components/item"
59
import SkeletonLineItem from "@modules/skeletons/components/skeleton-line-item"
610

@@ -10,22 +14,24 @@ type ItemsTemplateProps = {
1014
}
1115

1216
const ItemsTemplate = ({ items, region }: ItemsTemplateProps) => {
17+
const t = useScopedI18n("cart")
18+
1319
return (
1420
<div>
1521
<div className="pb-3 flex items-center">
16-
<Heading className="text-[2rem] leading-[2.75rem]">Cart</Heading>
22+
<Heading className="text-[2rem] leading-[2.75rem]">{t("cart")}</Heading>
1723
</div>
1824
<Table>
1925
<Table.Header className="border-t-0">
2026
<Table.Row className="text-ui-fg-subtle txt-medium-plus">
21-
<Table.HeaderCell className="!pl-0">Item</Table.HeaderCell>
27+
<Table.HeaderCell className="!pl-0">{t("item")}</Table.HeaderCell>
2228
<Table.HeaderCell></Table.HeaderCell>
23-
<Table.HeaderCell>Quantity</Table.HeaderCell>
29+
<Table.HeaderCell>{t("quantity")}</Table.HeaderCell>
2430
<Table.HeaderCell className="hidden small:table-cell">
25-
Price
31+
{t("price")}
2632
</Table.HeaderCell>
2733
<Table.HeaderCell className="!pr-0 text-right">
28-
Total
34+
{t("total")}
2935
</Table.HeaderCell>
3036
</Table.Row>
3137
</Table.Header>

src/modules/cart/templates/summary.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import { Button, Heading } from "@medusajs/ui"
44

5+
import { useScopedI18n } from '../../../locales/client'
6+
57
import CartTotals from "@modules/common/components/cart-totals"
68
import Divider from "@modules/common/components/divider"
79
import { CartWithCheckoutStep } from "types/global"
@@ -13,16 +15,17 @@ type SummaryProps = {
1315
}
1416

1517
const Summary = ({ cart }: SummaryProps) => {
18+
const t = useScopedI18n("cart")
1619
return (
1720
<div className="flex flex-col gap-y-4">
1821
<Heading level="h2" className="text-[2rem] leading-[2.75rem]">
19-
Summary
22+
{t("summary")}
2023
</Heading>
2124
<DiscountCode cart={cart} />
2225
<Divider />
2326
<CartTotals data={cart} />
2427
<LocalizedClientLink href={"/checkout?step=" + cart.checkout_step} data-testid="checkout-button">
25-
<Button className="w-full h-10">Go to checkout</Button>
28+
<Button className="w-full h-10">{t("checkout")}</Button>
2629
</LocalizedClientLink>
2730
</div>
2831
)

src/modules/checkout/components/discount-code/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ const DiscountCode: React.FC<DiscountCodeProps> = ({ cart }) => {
150150
<>
151151
<div className="flex w-full gap-x-2 items-center">
152152
<Input
153-
label="Please enter code"
153+
label="Please enter code----------------------------------------------------------------------------------------"
154154
name="code"
155155
type="text"
156156
autoFocus={false}

src/modules/common/components/native-select/index.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"use client"
22

3-
import { useI18n } from '../../../../locales/client'
3+
import { useI18n } from "../../../../locales/client"
44
import { ChevronUpDown } from "@medusajs/icons"
55
import { clx } from "@medusajs/ui"
66
import {
@@ -11,6 +11,7 @@ import {
1111
useRef,
1212
useState,
1313
} from "react"
14+
import { useScopedI18n } from "../../../../locales/client"
1415

1516
export type NativeSelectProps = {
1617
placeholder?: string
@@ -20,12 +21,14 @@ export type NativeSelectProps = {
2021

2122
const NativeSelect = forwardRef<HTMLSelectElement, NativeSelectProps>(
2223
(
23-
{ placeholder = "Select...", defaultValue, className, children, ...props },
24+
{ placeholder = null, defaultValue, className, children, ...props },
2425
ref
2526
) => {
27+
const t = useI18n()
28+
placeholder = placeholder || t("cart.select")
29+
2630
const innerRef = useRef<HTMLSelectElement>(null)
2731
const [isPlaceholder, setIsPlaceholder] = useState(false)
28-
const t = useI18n()
2932

3033
useImperativeHandle<HTMLSelectElement | null, HTMLSelectElement | null>(
3134
ref,

0 commit comments

Comments
 (0)