fix extrasgroup as backend request
This commit is contained in:
@@ -69,7 +69,7 @@ export default function useOrder() {
|
||||
items: items.map((i) => ({
|
||||
...i,
|
||||
qty: i.quantity,
|
||||
extras: i.extras || [],
|
||||
extras: i.extras?.map((e) => e.id) || [],
|
||||
extrasgroup: i.extrasgroup || [],
|
||||
order_item_comment: i.comment || "",
|
||||
})),
|
||||
|
||||
@@ -73,12 +73,27 @@ export default function ProductFooter({
|
||||
groupid: key,
|
||||
extrasid: selectedGroups[Number(key)],
|
||||
})),
|
||||
extrasgroup: Object.keys(selectedGroups).map((groupid) => {
|
||||
const groupInfo = product.theExtrasGroups?.find(
|
||||
(g) => g.id.toString() === groupid,
|
||||
);
|
||||
return `${groupInfo?.name}_${groupid},${selectedGroups[Number(groupid)].join(",")}`;
|
||||
}),
|
||||
extrasgroup: Object.entries(selectedGroups).flatMap(
|
||||
([groupId, extrasIds]) => {
|
||||
if (!extrasIds || extrasIds.length === 0) {
|
||||
return [];
|
||||
}
|
||||
const groupInfo = product.theExtrasGroups?.find(
|
||||
(g) => g.id.toString() === groupId,
|
||||
);
|
||||
const groupName = groupInfo?.name ?? `Group${groupId}`;
|
||||
const [firstExtra, ...remainingExtras] = extrasIds;
|
||||
const remainingSuffix =
|
||||
remainingExtras.length > 0
|
||||
? `,${remainingExtras.join(",")}`
|
||||
: "";
|
||||
|
||||
return [
|
||||
`${groupName}_${firstExtra}_${groupId}${remainingSuffix}`,
|
||||
`${groupName}_${extrasIds.join(",")}`,
|
||||
];
|
||||
},
|
||||
),
|
||||
isHasLoyalty: product?.isHasLoyalty,
|
||||
no_of_stamps_give: product?.no_of_stamps_give,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user