hey guys need some help with changing the Open boolean (true) to (false)saved in the database of a positionId when the withdrawn function reaches onSuccess.
// Query For Positions
const queryPositionsId = useMoralisQuery("PositionsId");
const positionsId = JSON.parse(
JSON.stringify(queryPositionsId.data, [
"positionId",
"walletAddress",
"createdDate",
"unlockDate",
"weiStaked",
"percentInterest",
"weiInterest",
"open",
"numDays"
])
);
let results2 = positionsId.filter((e) =>( e.walletAddress.toLowerCase() === account && e.open === true) )
console.log(results2)
const withdraw = async (positionId) => {
const readOptions = {
contractAddress: CONTRACT_ADDRESS,
functionName: "closePosition",
abi: ABIStake,
params: {
positionId: positionId,
}
};
await contractProcessor.fetch({
params: readOptions,
onSuccess: () => {
alert("WithDrawal sucessfull");
console.log(positionId)
// NEED TO CHANGE BOOLEAN OF OPEN TO FALES IN DATABASE
},
})
}
<div className="col-md-2 assets-text">
{a.open ? (
<div onClick={ () => {withdraw(a.positionId-1)}} className="orangeMiniButton">
Withdraw</div>
) : (
<span>closed</span>
)}
</div>