Skip to content

Commit 23a9536

Browse files
committed
feat: update currency display to PEN in Orders, ProductCard, and Checkout components
1 parent bcf8fef commit 23a9536

File tree

5 files changed

+22
-15
lines changed

5 files changed

+22
-15
lines changed

src/routes/account/orders/index.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ export default function Orders({ loaderData }: Route.ComponentProps) {
5353
Total
5454
</dt>
5555
<dd className="mt-1 font-medium text-foreground">
56-
{order.totalAmount.toLocaleString("en-US", {
56+
{order.totalAmount.toLocaleString("es-PE", {
5757
style: "currency",
58-
currency: "USD",
58+
currency: "PEN",
5959
})}
6060
</dd>
6161
</div>
@@ -102,19 +102,19 @@ export default function Orders({ loaderData }: Route.ComponentProps) {
102102
{item.title}
103103
</div>
104104
<div className="mt-1 sm:hidden">
105-
{item.quantity} × ${item.price.toFixed(2)}
105+
{item.quantity} × S/{item.price.toFixed(2)}
106106
</div>
107107
</div>
108108
</div>
109109
</td>
110110
<td className="py-6 pr-8 text-center hidden sm:table-cell">
111-
${item.price.toFixed(2)}
111+
S/{item.price.toFixed(2)}
112112
</td>
113113
<td className="py-6 pr-8 text-center hidden sm:table-cell">
114114
{item.quantity}
115115
</td>
116116
<td className="py-6 pr-8 whitespace-nowrap text-center font-medium text-foreground">
117-
${(item.price * item.quantity).toFixed(2)}
117+
S/{(item.price * item.quantity).toFixed(2)}
118118
</td>
119119
</tr>
120120
))}

src/routes/cart/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export default function Cart({ loaderData }: Route.ComponentProps) {
9090
))}
9191
<div className="flex justify-between p-6 text-base font-medium border-b">
9292
<p>Total</p>
93-
<p>${total.toFixed(2)}</p>
93+
<p>S/{total.toFixed(2)}</p>
9494
</div>
9595
<div className="p-6">
9696
<Button size="lg" className="w-full" asChild>

src/routes/category/components/product-card/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export function ProductCard({ product }: ProductCardProps) {
2525
<div className="flex grow flex-col gap-2 p-4">
2626
<h2 className="text-sm font-medium">{product.title}</h2>
2727
<p className="text-sm text-muted-foreground">{product.description}</p>
28-
<p className="mt-auto text-base font-medium">${product.price}</p>
28+
<p className="mt-auto text-base font-medium">S/{product.price}</p>
2929
</div>
3030
{product.isOnSale && (
3131
<span className="absolute top-0 right-0 rounded-bl-xl bg-primary px-2 py-1 text-sm font-medium text-primary-foreground">

src/routes/checkout/index.tsx

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export async function action({ request }: Route.ActionArgs) {
8686
const token = formData.get("token") as string;
8787

8888
const body = {
89-
amount: 2000,
89+
amount: 2000, // TODO: Calculate total dynamically
9090
currency_code: "PEN",
9191
email: shippingDetails.email,
9292
source_id: token,
@@ -97,14 +97,15 @@ export async function action({ request }: Route.ActionArgs) {
9797
method: "POST",
9898
headers: {
9999
"content-type": "application/json",
100-
Authorization: `Bearer sk_test_EC8oOLd3ZiCTKqjN`,
100+
Authorization: `Bearer sk_test_EC8oOLd3ZiCTKqjN`, // TODO: Use environment variable
101101
},
102102
body: JSON.stringify(body),
103103
});
104104

105105
if (!response.ok) {
106106
const errorData = await response.json();
107107
console.error("Error creating charge:", errorData);
108+
// TODO: Handle error appropriately
108109
throw new Error("Error processing payment");
109110
}
110111

@@ -118,7 +119,7 @@ export async function action({ request }: Route.ActionArgs) {
118119

119120
// TODO
120121
// @ts-expect-error Arreglar el tipo de shippingDetails
121-
const { id: orderId } = await createOrder(items, shippingDetails);
122+
const { id: orderId } = await createOrder(items, shippingDetails); // TODO: Add payment information to the order
122123

123124
await deleteRemoteCart(request);
124125
const session = await getSession(request.headers.get("Cookie"));
@@ -155,6 +156,7 @@ export default function Checkout({ loaderData }: Route.ComponentProps) {
155156
const navigation = useNavigation();
156157
const submit = useSubmit();
157158
const loading = navigation.state === "submitting";
159+
158160
const [culqui, setCulqui] = useState<CulqiInstance | null>(null);
159161
const scriptRef = useRef<HTMLScriptElement | null>(null);
160162

@@ -221,13 +223,18 @@ export default function Checkout({ loaderData }: Route.ComponentProps) {
221223
.then((CulqiCheckout) => {
222224
const config = {
223225
settings: {
224-
currency: "USD",
226+
currency: "PEN",
225227
amount: total * 100,
226228
},
227229
client: {
228230
email: user?.email,
229231
},
230-
options: {},
232+
options: {
233+
paymentMethods: {
234+
tarjeta: true,
235+
yape: false,
236+
},
237+
},
231238
appearance: {},
232239
};
233240

@@ -297,14 +304,14 @@ export default function Checkout({ loaderData }: Route.ComponentProps) {
297304
<div className="flex text-sm font-medium gap-4 items-center self-end">
298305
<p>{quantity}</p>
299306
<X className="w-4 h-4" />
300-
<p>${product.price.toFixed(2)}</p>
307+
<p>S/{product.price.toFixed(2)}</p>
301308
</div>
302309
</div>
303310
</div>
304311
))}
305312
<div className="flex justify-between p-6 text-base font-medium">
306313
<p>Total</p>
307-
<p>${total.toFixed(2)}</p>
314+
<p>S/{total.toFixed(2)}</p>
308315
</div>
309316
</div>
310317
</div>

src/routes/product/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export default function Product({ loaderData }: Route.ComponentProps) {
4141
<h1 className="text-3xl leading-9 font-bold mb-3">
4242
{product.title}
4343
</h1>
44-
<p className="text-3xl leading-9 mb-6">${product.price}</p>
44+
<p className="text-3xl leading-9 mb-6">S/{product.price}</p>
4545
<p className="text-sm leading-5 text-muted-foreground mb-10">
4646
{product.description}
4747
</p>

0 commit comments

Comments
 (0)