Skip to content

Commit e1cae5e

Browse files
authored
Merge pull request #275 from codeableorg/grupo-3-mike-6
feat: enhance cart and checkout components to display variant attribute values
2 parents 00a60c7 + 63d4785 commit e1cae5e

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

src/routes/account/orders/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ export async function loader({ request }: Route.LoaderArgs) {
1313
try {
1414
const orders = await getOrdersByUser(request);
1515

16+
console.log("ORDERS", orders[0].items);
17+
1618
orders.sort((a, b) => b.createdAt.getTime() - a.createdAt.getTime());
1719

1820
return { orders };
@@ -29,7 +31,7 @@ export default function Orders({ loaderData }: Route.ComponentProps) {
2931
{orders!.length > 0 ? (
3032
<div className="flex flex-col gap-4">
3133
{orders!.map((order) => (
32-
<div key={order.id}>
34+
<div key={order.id} className="p-6 border rounded-lg">
3335
<div className="rounded-lg bg-muted py-4 px-6">
3436
<dl className="flex flex-col gap-4 w-full sm:flex-row">
3537
<div className="flex-shrink-0">

src/routes/cart/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ export default function Cart({ loaderData }: Route.ComponentProps) {
3030
Carrito de compras
3131
</h1>
3232
<div className="border-solid border rounded-xl flex flex-col">
33-
{cart?.items?.map(({ product, quantity, id, attributeValueId }) => (
34-
<div key={product.id} className="flex gap-7 p-6 border-b">
33+
{cart?.items?.map(({ product, quantity, id, variantAttributeValue
34+
}) => (
35+
<div key={variantAttributeValue?.id} className="flex gap-7 p-6 border-b">
3536
<div className="w-20 rounded-xl bg-muted">
3637
<img
3738
src={product.imgSrc}
@@ -41,7 +42,7 @@ export default function Cart({ loaderData }: Route.ComponentProps) {
4142
</div>
4243
<div className="flex grow flex-col justify-between">
4344
<div className="flex gap-4 justify-between items-center">
44-
<h2 className="text-sm">{product.title}</h2>
45+
<h2 className="text-sm">{product.title} ({variantAttributeValue?.value})</h2>
4546
<Form method="post" action="/cart/remove-item">
4647
<Button
4748
size="sm-icon"
@@ -62,7 +63,7 @@ export default function Cart({ loaderData }: Route.ComponentProps) {
6263
<input type="hidden" name="quantity" value="-1" />
6364
<Button
6465
name="attributeValueId"
65-
value={attributeValueId}
66+
value={variantAttributeValue?.id}
6667
variant="outline"
6768
size="sm-icon"
6869
disabled={quantity === 1}
@@ -78,7 +79,7 @@ export default function Cart({ loaderData }: Route.ComponentProps) {
7879
variant="outline"
7980
size="sm-icon"
8081
name="attributeValueId"
81-
value={attributeValueId}
82+
value={variantAttributeValue?.id}
8283
>
8384
<Plus />
8485
</Button>

src/routes/category/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ export async function loader({ params, request }: Route.LoaderArgs) {
2828
const [category] = await Promise.all([
2929
getCategoryBySlug(categorySlug),
3030
]);
31-
console.log({categorySlug, minValue, maxValue})
3231
const finalProducts = await filterByMinMaxPrice(categorySlug, minValue, maxValue);
3332

3433
return {

src/routes/checkout/index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -249,9 +249,9 @@ export default function Checkout({
249249
<div className="flex-grow">
250250
<h2 className="text-lg font-medium mb-4">Resumen de la orden</h2>
251251
<div className="border border-border rounded-xl bg-background flex flex-col">
252-
{cart?.items?.map(({ product, quantity }) => (
252+
{cart?.items?.map(({ product, quantity, variantAttributeValue }) => (
253253
<div
254-
key={product.id}
254+
key={variantAttributeValue?.id}
255255
className="flex gap-6 p-6 border-b border-border"
256256
>
257257
<div className="w-20 rounded-xl bg-muted">
@@ -262,7 +262,7 @@ export default function Checkout({
262262
/>
263263
</div>
264264
<div className="flex flex-col justify-between flex-grow">
265-
<h3 className="text-sm leading-5">{product.title}</h3>
265+
<h3 className="text-sm leading-5">{product.title} ({variantAttributeValue?.value})</h3>
266266
<div className="flex text-sm font-medium gap-4 items-center self-end">
267267
<p>{quantity}</p>
268268
<X className="w-4 h-4" />

src/services/cart.service.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ async function getCart(
4545
},
4646
});
4747

48-
console.log("DATA CART SERVICE", data?.items);
49-
5048
if (!data) return null;
5149

5250
return {

0 commit comments

Comments
 (0)