Hi everyone! Im having troubles at displaying and uptdating data information. I have a repetaer with some orders information, one of them is status order (pending, on process, completed).
I’m using wixdata.save and context The issue is that the item that gets the event creates a copy of it instead of updating the info, so the same order is getting duplicated on the repeater. Here is my code
export function completedBt_onClick((event) =>{
$w('#c2').show();
const itemId = event.context.itemId;
$w('#b1').onClick(() => {
wixData.query("ErickHOrders")
.eq("_id", itemId)
.find()
.then((results) => {
let itemData = results.items[0];
if(itemData._orderSt === 'In process' || itemData._orderSt === 'Urgent' ) {
let toUpdate = {
"_client" : itemData.client,
"orderReference" :itemData. orderReference,
"_deliveryDate" : itemData.deliveryDate,
"_orderSt" : 'Completed',
"_billing" : itemData.billing,
"_paymentSt" : itemData.paymentSt,
"_spec" : itemData.spec,
"_piecesAmount" : itemData.piecesAmount,
"_unitValue" :itemData. unitValue,
"_totalValue" : itemData.totalValue,
"_productDescription" : itemData.productDescription
}
wixData.save("ErickHOrders", toUpdate)
.then((results) => {
ordersTrigger();
$w('#c2').hide();
})
} // if brackets
}) // then brackets
}) // Onclick brackets
} // completedBt brackets
In the repeteater i’m getting a duplicated values of all the orders that are in process status.