print added
This commit is contained in:
32
src/routes/private/boxes-print/BoxesPrintList.tsx
Normal file
32
src/routes/private/boxes-print/BoxesPrintList.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { forwardRef } from 'react';
|
||||
import BoxesPrint from './BoxesPrint';
|
||||
|
||||
interface BoxesPrintListProps {
|
||||
boxData: any;
|
||||
}
|
||||
|
||||
const chunkArray = (arr: any[], chunkSize: number): any[][] => {
|
||||
const result = [];
|
||||
for (let i = 0; i < arr.length; i += chunkSize) {
|
||||
result.push(arr.slice(i, i + chunkSize));
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
const BoxesPrintList = forwardRef<HTMLDivElement, BoxesPrintListProps>(({ boxData }, ref) => {
|
||||
const productsChunks = chunkArray(boxData.products_list || [], 36);
|
||||
|
||||
return (
|
||||
<div ref={ref}>
|
||||
{productsChunks.map((chunk, index) => (
|
||||
<div key={index} style={{ pageBreakAfter: 'always' }}>
|
||||
<BoxesPrint boxData={{ ...boxData, products_list: chunk }} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
});
|
||||
|
||||
BoxesPrintList.displayName = 'BoxesPrintList';
|
||||
|
||||
export default BoxesPrintList;
|
||||
Reference in New Issue
Block a user