@@ -24,7 +24,9 @@ import {
2424} from 'react-icons/hi' ;
2525
2626const CustomerDetailsContainer = ( { clienteDetails} ) => {
27- console . log ( 'detalles del cliente:' , clienteDetails ) ;
27+ const orders = clienteDetails . pedidos ;
28+ const cantidadOrders = orders . length ;
29+ console . log ( 'detalles del cliente:' , clienteDetails , orders ) ;
2830
2931 const [ customer ] = useState ( {
3032 id : 'CUST-78945' ,
@@ -41,16 +43,7 @@ const CustomerDetailsContainer = ({clienteDetails}) => {
4143 favoriteCategory : 'Electrónica' ,
4244 satisfaction : 4.5
4345 } ) ;
44-
45- const [ orders ] = useState ( [
46- { id : 'ORD-98765' , date : '12/05/2023' , amount : 189.99 , status : 'Entregado' , items : 3 } ,
47- { id : 'ORD-98764' , date : '05/05/2023' , amount : 245.5 , status : 'Entregado' , items : 5 } ,
48- { id : 'ORD-98763' , date : '28/04/2023' , amount : 89.99 , status : 'Cancelado' , items : 2 } ,
49- { id : 'ORD-98762' , date : '15/04/2023' , amount : 320.75 , status : 'Entregado' , items : 4 } ,
50- { id : 'ORD-98761' , date : '02/04/2023' , amount : 156.3 , status : 'Entregado' , items : 3 }
51- ] ) ;
52-
53-
46+
5447
5548 return (
5649 < div className = "container mx-auto px-4 py-6 space-y-6" >
@@ -88,7 +81,7 @@ const CustomerDetailsContainer = ({clienteDetails}) => {
8881 < Card className = "lg:col-span-2 bg-white dark:bg-gray-950 shadow-lg border border-gray-200 dark:border-gray-700 rounded-2xl p-6" >
8982 < h5 className = "text-xl font-bold mb-6 text-gray-900 dark:text-white" > Estadísticas del Cliente</ h5 >
9083 < div className = "grid grid-cols-1 md:grid-cols-3 gap-4 mb-6" >
91- < StatCard icon = { < HiOutlineShoppingBag /> } label = "Pedidos totales" value = { customer . totalOrders } color = "text-blue-500" />
84+ < StatCard icon = { < HiOutlineShoppingBag /> } label = "Pedidos totales" value = { cantidadOrders } color = "text-blue-500" />
9285 < StatCard icon = { < HiOutlineCurrencyDollar /> } label = "Total gastado" value = { `$${ customer . totalSpent . toFixed ( 2 ) } ` } color = "text-green-500" />
9386 < StatCard icon = { < HiOutlineClock /> } label = "Último pedido" value = { customer . lastOrder } color = "text-purple-500" />
9487 </ div >
@@ -113,7 +106,6 @@ const CustomerDetailsContainer = ({clienteDetails}) => {
113106 < Card className = "bg-white dark:bg-gray-950 shadow-lg border border-gray-200 dark:border-gray-700 rounded-2xl p-6" >
114107 < div className = "flex flex-col sm:flex-row sm:justify-between sm:items-center mb-4 gap-2" >
115108 < h5 className = "text-xl font-bold text-gray-900 dark:text-white" > Pedidos Recientes</ h5 >
116- < Button color = "light" size = "sm" > Ver todos ({ customer . totalOrders } )</ Button >
117109 </ div >
118110
119111 < div className = "overflow-x-auto" >
@@ -130,18 +122,24 @@ const CustomerDetailsContainer = ({clienteDetails}) => {
130122 </ TableHead >
131123 < TableBody className = "divide-y divide-gray-200 dark:divide-gray-700" >
132124 { orders . map ( ( order ) => (
125+
133126 < TableRow key = { order . id } className = "transition hover:bg-gray-50 dark:hover:bg-gray-800" >
134127 < TableCell className = "font-medium text-blue-600 dark:text-blue-400 hover:underline cursor-pointer" > { order . id } </ TableCell >
135- < TableCell > { order . date } </ TableCell >
136- < TableCell > { order . items } </ TableCell >
137- < TableCell > ${ order . amount . toFixed ( 2 ) } </ TableCell >
128+ < TableCell > { order . fecha_pedido } </ TableCell >
138129 < TableCell >
139- < Badge color = { order . status === 'Entregado' ? 'success' : order . status === 'Cancelado' ? 'failure' : 'warning' } className = "px-2 py-1 rounded-full" >
140- { order . status }
141- </ Badge >
130+ < ul >
131+ { order . items . map ( item => (
132+ < li key = { item . id } >
133+ Empaque: { item ?. empaque ?. codigo_unico } , { item ?. empaque ?. producto ?. descripcion }
134+ </ li >
135+ ) ) }
136+ </ ul >
142137 </ TableCell >
138+ < TableCell > $</ TableCell >
143139 < TableCell >
144- < Button size = "xs" gradientduotone = "cyanToBlue" > Detalles</ Button >
140+ < Badge color = { order . estado === 'entregado' ? 'success' : order . status === 'cancelado' ? 'failure' : 'warning' } className = "px-2 py-1 rounded-full" >
141+ { order ?. estado }
142+ </ Badge >
145143 </ TableCell >
146144 </ TableRow >
147145 ) ) }
0 commit comments