mirror of
https://github.com/aljazceru/landscape-template.git
synced 2025-12-27 19:24:18 +01:00
fix: silent "Tip not confirmed" error
Currently, the payment is made but the graphql api is not able to confirm it, so I just wrapped it with a catch to silent the error, however it has to be fixed from the backend soon
This commit is contained in:
@@ -10,7 +10,7 @@ import { ALL_CATEGORIES_PROJECTS_QUERY, ALL_CATEGORIES_PROJECTS_RES } from "./qu
|
||||
export default function ProjectsSection() {
|
||||
|
||||
const { data, loading } = useQuery<ALL_CATEGORIES_PROJECTS_RES>(ALL_CATEGORIES_PROJECTS_QUERY);
|
||||
console.log(data, loading);
|
||||
|
||||
|
||||
if (loading || !data) return <div className='mt-32 lg:mt-48'>
|
||||
{Array(3).fill(0).map((_, idx) => <ProjectsRowSkeleton key={idx} />)}
|
||||
|
||||
@@ -68,17 +68,24 @@ export default function TipCard({ onClose, direction, tipValue, ...props }: Prop
|
||||
|
||||
const [vote, { data }] = useMutation(VOTE, {
|
||||
onCompleted: async (votingData) => {
|
||||
setPaymentStatus(PaymentStatus.AWAITING_PAYMENT);
|
||||
const webln = await Wallet_Service.getWebln()
|
||||
webln.sendPayment(votingData.vote.payment_request).then((res: any) => {
|
||||
console.log("waiting for payment", res);
|
||||
confirmVote({ variables: { paymentRequest: votingData.vote.payment_request, preimage: res.preimage } });
|
||||
try {
|
||||
setPaymentStatus(PaymentStatus.AWAITING_PAYMENT);
|
||||
const webln = await Wallet_Service.getWebln()
|
||||
const paymentResponse = await webln.sendPayment(votingData.vote.payment_request);
|
||||
setPaymentStatus(PaymentStatus.PAID);
|
||||
})
|
||||
.catch((err: any) => {
|
||||
console.log(err);
|
||||
setPaymentStatus(PaymentStatus.NOT_PAID);
|
||||
});
|
||||
confirmVote({ variables: { paymentRequest: votingData.vote.payment_request, preimage: paymentResponse.preimage } })
|
||||
.catch() // ONLY TEMPROARY !!! SHOULD BE FIXED FROM BACKEND
|
||||
.finally(() => {
|
||||
setTimeout(() => {
|
||||
onClose?.();
|
||||
}, 2000);
|
||||
})
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
setPaymentStatus(PaymentStatus.NOT_PAID);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -88,7 +95,9 @@ export default function TipCard({ onClose, direction, tipValue, ...props }: Prop
|
||||
setTimeout(() => {
|
||||
onClose?.();
|
||||
}, 2000);
|
||||
}
|
||||
},
|
||||
onError: () => { }
|
||||
|
||||
});
|
||||
|
||||
const onChangeInput = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
|
||||
Reference in New Issue
Block a user