instant-harlequinI
Refine2y ago
128 replies
instant-harlequin

HandleSave mutate useUpdate & useOne

I want to update and use useOne in the same handleSave code. When I put useOne inside the handleSave it dont work.

The code is:


const { mutate } = useUpdate<IProdutos, HttpError>();



const handleSave = async (value: any ) => {
const { data } = useOne<IProdutos, HttpError>({
resource: "rqp-produtos",
id: value.rqp_produto_id.id,
});

const product = data?.data;

mutate({
resource: "rqp-produtos",
id: value.rqp_produto_id.id,
values: {
stock: product?.stock ,
},
mutationMode: "optimistic",
invalidates: [],
successNotification: false,
errorNotification: false,
});

formProps.onFinish?.({
rqp_requisicao_id: value.rqp_requisicao_id,
rqp_produto_id: value.rqp_produto_id.id,
qnt: product?.stock,
});
};
Was this page helpful?