In the last experiment, I added the ability to submit a single claim.
This experiment expands it to submit multiple at once.
Code
It was prettry straight forward, just looping thru all pending shipments and submitting it.
Since I need to the list of pending shipments in a few places, and it’s computed based of shipments
, I used a reactive statement keep the logic in one place:
$: pendingShipments = shipments
.filter(shipment => shipment.status == 'pending')
Then my looping logic was very straightforward:
async function submitAll() {
for (const shipment of pendingShipments) {
await submit(shipment, {submit: true})
}
}
Came together pretty nicely. Pretty good result for just 6 experiments.