const { Component } = React; class UserSubscriptions extends Component { constructor(props) { super(props); this.state = { data:[] }; } componentDidMount() { this.getData() } getData() { let email = shopDataLayerData?.customer?.email; fetch('https://easylight.perity.net/backend/get.php', { method: 'POST', headers: {'Accept': 'application/json','Content-Type': 'application/json'}, body: JSON.stringify({ what:"subscriptions", select:"product_img,product_name,product_id,order_id,price,currency,recurrence_price,recurrence_status,recurrence_id,payment_id,created", where:"email='"+email+"'", multiple:false, }), }).then((e)=>e.json()) .then((result)=>{ this.setState({ data:result }) }); } /* handleSubmit = async (e) => { e.preventDefault(); const data = {}; const response = await fetch('https://easylight.perity.net/backend/create-payment-reserve.php', { method: 'POST', headers: {'Accept': 'application/json','Content-Type': 'application/json'}, body: JSON.stringify(data), }).then((e)=>e.json()) .then((result)=>{ const paymentId = result.id; // We don't need to extract the ID from the argument object _gopay.checkout({gatewayUrl: result.gw_url, inline: true}, ()=>getStatus(paymentId, data, "reserve")); }); console.log(response); if (response.ok) { this.context.addNotification('Rezervácia bola úspešne odoslaná!', 'success'); } else { this.context.addNotification('Došlo k chybe pri odosielaní rezervácie.', 'error'); } }; */ render() { const {data} = this.state, name = shopDataLayerData.customer.fullName??"Zákaznícke centrum"; return ( <>

Moje Predplatné

{ !(data?.length <= 0) ? data?.map((e,i)=>( this.getData()} key={i}/> )) : <>

Ešte ste žiadne predplatné nevytvorili....

}
Produkt Dátum Cena jednorázovej platby Cena každý mesiac Stav
1

Stránka 1 z 1 , položiek celkom: 1

)} } class Product extends Component{ getStatus(e) { let state = "Neznámy" if(e === "PAID") { state="Zaplatené" } else if(e === "CANCELED") { state = "Zrušené" } else if(e === "CREATED" || e ===null ) { state = "Nezaplatené" } else if(e === "FINISHED") { state = "Ukončené" } return state; } formatDate(e) { let d = new Date(e); return d.getDate() + "." + (d.getMonth()+1) + "." + d.getFullYear() + " " + d.getHours() + ":" + d.getMinutes(); } stopRecurrence(e) { if(!confirm("Naozaj chcete zrušiť predplatné?")) { return; } const {data:d,reload} = this.props, {payment_id,recurrence_id,order_id} = d, data = { key:order_id+""+payment_id+""+recurrence_id, id:recurrence_id, order:order_id } fetch('https://easylight.perity.net/backend/void_user.php', { method: 'POST', headers: {'Accept': 'application/json','Content-Type': 'application/json'}, body: JSON.stringify(data), }).then((e)=>e.json()) .then((result)=>{ if(result?.error) { throw result?.error; } showMessage("Vaše predplatné bolo zrušené.","info","info",false,true) reload(); }).catch((e)=>{ showMessage("Došlo k chybe pri zrušení predplatného.","error","error",false,true) reload(); }); } retryPayment() { const {data:d} = this.props, {recurrence_price,order_id} = d, formData = { recurrence:true, price:recurrence_price, orderId: order_id, url: window.location.origin + window.location.pathname } paymentGate(formData); } render() { const {data} = this.props return( Produkt

{data?.product_name}

Kód: {data?.product_id} {data?.order_id}
Dátum {this.formatDate(data?.created)} Cena jednorázovej platby {data?.price+(data?.currency==="EUR"?" €":" "+data?.currency)} Cena každý mesiac {data?.recurrence_price+(data?.currency==="EUR"?" €":" "+data?.currency)} Stav {this.getStatus(data?.recurrence_status)} { (data?.recurrence_status === "CANCELED" || data?.recurrence_status === null)? <> :(data?.recurrence_status === "FINISHED")?<> :(data?.recurrence_status === "CREATED")? <> : <> } )} } const subscriptionReactRoot = ReactDOM.createRoot(document.getElementById('subscriptionReactRoot')); subscriptionReactRoot.render( );