ProductList fix chunkInefficient

This commit is contained in:
Jérémy Munsch 2024-02-02 11:09:17 +01:00
parent e9a18f5dce
commit fdd8fedbae
No known key found for this signature in database
GPG key ID: 18361AF3BFEC0FEC

View file

@ -120,12 +120,18 @@ export default defineComponent({
methods: {
chunkInefficient(products: Array<TypeProduct>, chunkSize: number):Array<Array<TypeProduct>> {
const out:Array<Array<TypeProduct>> = [];
// eslint-disable-next-line @typescript-eslint/no-unused-vars
let row: Array<TypeProduct> = [];
products.forEach((elem: TypeProduct, i: number) => {
if (i % chunkSize) {
out.push(products.slice(i, i + chunkSize));
row.push(elem);
if (i % chunkSize && row.length) {
out.push(row);
row = [];
}
});
if (row.length) {
out.push(row);
}
return out;
},
t(text: string, params: Record<string, string> = {}, localeToUse: string | null = null): string {