PageSourceSearch

https://kconect.vercel.app/assets/usePayment-DbOsPFvK.js

js kconect.vercel.app collected 2026-10-03 07:12:11 UTC 2,349 bytes, 1 lines download raw bytes

1import{c as v,o as P,a as h,p as w,k as r,V as m}from"./index-IxvR3ybE.js";const _=()=>{const{toast:c}=v(),o=P(),{currentUser:e}=h(),{data:a=[],isLoading:l,refetch:p}=w({queryKey:["event-payments",e==null?void 0:e.id],queryFn:async()=>{if(!(e!=null&&e.id))return[];console.log("Fetching payment records for user:",e.id);const{data:t,error:n}=await r.from("event_payments").select("*").eq("user_id",e.id).eq("status","success");if(n)throw console.error("Error fetching payment records:",n),n;return console.log("Payment records fetched:",t),t},enabled:!!(e!=null&&e.id),staleTime:0,refetchOnWindowFocus:!0}),d=m({mutationFn:async t=>{if(!(e!=null&&e.id))throw new Error("User not authenticated");console.log("Recording payment:",t);const{data:n,error:s}=await r.from("event_payments").insert([{event_id:t.eventId,user_id:e.id,amount:t.amount,currency:t.currency,paystack_reference:t.reference,status:t.status}]).select().single();if(s)throw console.error("Error recording payment:",s),s;return n},onSuccess:async()=>{await o.invalidateQueries({queryKey:["event-payments"]}),await o.refetchQueries({queryKey:["event-payments",e==null?void 0:e.id]}),c({title:"Payment Recorded",description:"Payment has been successfully recorded."})},onError:t=>{console.error("Record payment error:",t),c({title:"Error",description:`Failed to record payment: ${t.message}`,variant:"destructive"})}}),u=m({mutationFn:async({reference:t,status:n})=>{console.log("Updating payment status:",{reference:t,status:n});const{data:s,error:i}=await r.from("event_payments").update({status:n}).eq("paystack_reference",t).select().single();if(i)throw console.error("Error updating payment status:",i),i;return s},onSuccess:async()=>{await o.invalidateQueries({queryKey:["event-payments"]}),await o.refetchQueries({queryKey:["event-payments",e==null?void 0:e.id]})}}),y=t=>{const n=a.some(s=>s.event_id===t&&s.status==="success");return console.log("Checking if event is paid:",{eventId:t,isPaid:n,eventPayments:a}),n},g=t=>{const n=y(t);return console.log("Checking if event is unlocked via payment:",{eventId:t,isPaid:n}),n},f=()=>3e7;return{eventPayments:a,isLoadingPayments:l,refetchPayments:p,recordPayment:d.mutate,updatePaymentStatus:u.mutate,isRecordingPayment:d.isPending,isUpdatingPayment:u.isPending,isEventPaid:y,isEventUnlocked:g,getPaymentAmount:f}};export{_ as u};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.