diff --git a/src/private/catalogs/products/ProductCollections.jsx b/src/private/catalogs/products/ProductCollections.jsx index da5d651..bc7071b 100644 --- a/src/private/catalogs/products/ProductCollections.jsx +++ b/src/private/catalogs/products/ProductCollections.jsx @@ -174,7 +174,7 @@ export default function ProductCollections() { }, [statusFilter, rawRows]); const columns = [ - { + { field: 'actions', headerName: '', width: 130, @@ -192,7 +192,7 @@ export default function ProductCollections() { borderRadius: 2, p: 1, }} - onClick={() => { setEditRow(p.row); setOpen(true); }} + onClick={() => { setEditRow(params.row); setOpen(true); }} > @@ -212,31 +212,30 @@ export default function ProductCollections() { ), }, - - - { field: 'name', headerName: 'Name', width: 200 }, - { field: 'categoryId', headerName: 'Category', width: 170, valueGetter: (p) => labelCategory(p?.row?.categoryId) }, - { field: 'providerId', headerName: 'Provider', width: 170, valueGetter: (p) => labelProvider(p?.row?.providerId) }, - { field: 'color', headerName: 'Color', width: 130, valueGetter: (p) => labelColor(p?.row?.color) }, - { field: 'line', headerName: 'Line', width: 130, valueGetter: (p) => labelLine(p?.row?.line) }, + { field: 'name', headerName: 'Name', flex: 1, minWidth: 160 }, + { field: 'categoryId', headerName: 'Category', flex: 1, minWidth: 160 }, + { field: 'providerId', headerName: 'Provider', flex: 1, minWidth: 160 }, + { field: 'color', headerName: 'Color', flex: 1, minWidth: 160 }, + { field: 'line', headerName: 'Line', flex: 1, minWidth: 160 }, { field: 'price', headerName: 'Price', - width: 130, + flex: 1, + minWidth: 160, type: 'number', valueGetter: (p) => parsePrice(p?.row?.price), renderCell: (p) => { - const currency = labelCurrency(p?.row?.currency || 'USD'); const val = parsePrice(p?.row?.price); + const currency = p?.row?.currency || 'USD'; try { - return new Intl.NumberFormat(undefined, { style: 'currency', currency: currency || 'USD' }).format(val); + return new Intl.NumberFormat(undefined, { style: 'currency', currency }).format(val); } catch { return `${currency} ${val.toFixed(2)}`; } } }, - { field: 'currency', headerName: 'Currency', width: 120, valueGetter: (p) => labelCurrency(p?.row?.currency) }, - { field: 'stock', headerName: 'Stock', width: 100, type: 'number', valueGetter: (p) => Number(p?.row?.stock ?? 0) }, + { field: 'currency', headerName: 'Currency', flex: 1, minWidth: 160 }, + { field: 'stock', headerName: 'Stock', flex: 1, minWidth: 160 }, { field: 'attributes', headerName: 'Attributes', @@ -246,17 +245,12 @@ export default function ProductCollections() { filterable: false, renderCell: (params) => { const a = params?.row?.attributes || {}; - const chips = [ - ['Material', labelMaterial(a.material)], - ['Legs', labelLegs(a.legs)], - ['Origin', labelOrigin(a.origin)], - ].filter(([, value]) => !!value); - + const chips = Object.entries(a).filter(([, v]) => !!v); return ( - {chips.map(([label, value]) => ( + {chips.map(([key, value]) => ( - {label}: {value} + {key}: {value} ))} ); } }, - { field: 'status', headerName: 'Status', width: 120 } + { field: 'status', headerName: 'Status', flex: 1, minWidth: 160 } ]; return ( - + Product Collection @@ -312,10 +306,28 @@ export default function ProductCollections() { columns: { columnVisibilityModel: { id: false, _Id: false } }, }} getRowHeight={() => 'auto'} + columnBuffer={0} sx={{ - '& .MuiDataGrid-cell': { display: 'flex', alignItems: 'center' }, - '& .MuiDataGrid-columnHeader': { display: 'flex', alignItems: 'center' }, - '& .MuiDataGrid-virtualScroller': { overflowX: 'hidden' }, + width: '100%', + '& .MuiDataGrid-cell': { + display: 'flex', + alignItems: 'center', + whiteSpace: 'normal', + wordBreak: 'break-word', + minHeight: '100%', + }, + '& .MuiDataGrid-columnHeader': { + display: 'flex', + alignItems: 'center', + whiteSpace: 'normal', + wordBreak: 'break-word', + }, + '& .MuiDataGrid-virtualScroller': { + overflowX: 'auto', + }, + '& .MuiDataGrid-main': { + minWidth: '1000px', + }, }} />