feat: enhance RowShareAction component to group and display cutting results by product, improving shareable output format
This commit is contained in:
parent
d57ad3e65d
commit
366380ae67
@ -36,6 +36,30 @@ const whatsappText = computed(() => {
|
||||
text += `Deskripsi: ${c.description}\n`;
|
||||
}
|
||||
|
||||
if (c.results?.length) {
|
||||
const groups: Record<string, { name: string; items: typeof c.results }> = {};
|
||||
|
||||
c.results.forEach((result) => {
|
||||
const productName = result.product_variant?.product?.name ?? 'Produk Tidak Diketahui';
|
||||
|
||||
if (!groups[productName]) {
|
||||
groups[productName] = { name: productName, items: [] };
|
||||
}
|
||||
|
||||
groups[productName].items.push(result);
|
||||
});
|
||||
|
||||
text += `\n*Hasil Produk:*\n`;
|
||||
|
||||
Object.values(groups).forEach((group, index) => {
|
||||
text += `${index + 1}. ${group.name}\n`;
|
||||
|
||||
group.items.forEach((item) => {
|
||||
text += ` - ${item.product_variant?.name ?? '-'}: ${item.cutting_result} pcs\n`;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
text += `\nTotal Hasil Cutting: ${c.total_result_pieces ?? 0} pcs\n`;
|
||||
text += `\nLihat detail lengkap:\n${shareLink.value}`;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user