@@ -105,9 +105,13 @@ export async function action({ request }: Route.ActionArgs) {
105105
106106 const items = cartItems . map ( ( item ) => ( {
107107 productId : item . product . id ,
108+ categoryVariantId : item . categoryVariantId , // ← NUEVO
108109 quantity : item . quantity ,
109110 title : item . product . title ,
110- price : item . product . price ,
111+ variantInfo : item . categoryVariant
112+ ? getVariantInfoText ( item . categoryVariantId , item . categoryVariant )
113+ : null ,
114+ price : item . finalPrice ,
111115 imgSrc : item . product . imgSrc ,
112116 } ) ) ;
113117
@@ -130,6 +134,15 @@ export async function action({ request }: Route.ActionArgs) {
130134 } ) ;
131135}
132136
137+ function getVariantInfoText (
138+ categoryId : number | null ,
139+ categoryVariant : any
140+ ) : string {
141+ if ( categoryId === 1 ) return `Talla: ${ categoryVariant . label } ` ;
142+ if ( categoryId === 3 ) return `Tamaño: ${ categoryVariant . label } ` ;
143+ return `Opción: ${ categoryVariant . label } ` ;
144+ }
145+
133146export async function loader ( { request } : Route . LoaderArgs ) {
134147 const session = await getSession ( request . headers . get ( "Cookie" ) ) ;
135148 const sessionCartId = session . get ( "sessionCartId" ) ;
@@ -249,28 +262,37 @@ export default function Checkout({
249262 < div className = "flex-grow" >
250263 < h2 className = "text-lg font-medium mb-4" > Resumen de la orden</ h2 >
251264 < div className = "border border-border rounded-xl bg-background flex flex-col" >
252- { cart ?. items ?. map ( ( { product, quantity } ) => (
253- < div
254- key = { product . id }
255- className = "flex gap-6 p-6 border-b border-border"
256- >
257- < div className = "w-20 rounded-xl bg-muted" >
258- < img
259- src = { product . imgSrc }
260- alt = { product . title }
261- className = "w-full aspect-square object-contain"
262- />
263- </ div >
264- < div className = "flex flex-col justify-between flex-grow" >
265- < h3 className = "text-sm leading-5" > { product . title } </ h3 >
266- < div className = "flex text-sm font-medium gap-4 items-center self-end" >
267- < p > { quantity } </ p >
268- < X className = "w-4 h-4" />
269- < p > S/{ product . price . toFixed ( 2 ) } </ p >
265+ { cart ?. items ?. map (
266+ ( { product, quantity, finalPrice, categoryVariant } ) => (
267+ < div
268+ key = { `${ product . id } -${ categoryVariant ?. id } ` }
269+ className = "flex gap-6 p-6 border-b border-border"
270+ >
271+ < div className = "w-20 rounded-xl bg-muted" >
272+ < img
273+ src = { product . imgSrc }
274+ alt = { product . title }
275+ className = "w-full aspect-square object-contain"
276+ />
277+ </ div >
278+ < div className = "flex flex-col justify-between flex-grow" >
279+ < div className = "flex items-center" >
280+ < h3 className = "text-sm leading-5" > { product . title } </ h3 >
281+ { categoryVariant && (
282+ < p className = "text-sm leading-5" >
283+ ({ categoryVariant . label } )
284+ </ p >
285+ ) }
286+ </ div >
287+ < div className = "flex text-sm font-medium gap-4 items-center self-end" >
288+ < p > { quantity } </ p >
289+ < X className = "w-4 h-4" />
290+ < p > S/{ finalPrice . toFixed ( 2 ) } </ p >
291+ </ div >
270292 </ div >
271293 </ div >
272- </ div >
273- ) ) }
294+ )
295+ ) }
274296 < div className = "flex justify-between p-6 text-base font-medium" >
275297 < p > Total</ p >
276298 < p > S/{ total . toFixed ( 2 ) } </ p >
0 commit comments