diff --git a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/app.js b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/app.js index 761367c..f9ad2ad 100644 --- a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/app.js +++ b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/app.js @@ -1,5 +1,9 @@ - - +function pickpayment(e){ + document.getElementById("dropbtn").innerText=e.target.innerText; +} +document.getElementById("paymentMethodCash").addEventListener("click",pickpayment); +document.getElementById("paymentMethodTransfer").addEventListener("click",pickpayment); +document.getElementById("paymentMethodBitcoin").addEventListener("click",pickpayment); function checkRole() { fetch('https://dragonmaster.pl/inz/user', { headers: { @@ -47,9 +51,14 @@ function login() { }) .catch(error => console.log(error)) } - +var invoiceid=""; +var paymentid=""; function tournamentSave() { + if(document.getElementById("dropbtn").innerText =="Przelew"){ + alert("not implemented yet :("); + return; + } fetch('https://dragonmaster.pl/inz/registration', { method: "PUT", headers: { @@ -57,7 +66,7 @@ function tournamentSave() { }, body: JSON.stringify( { - "paymentmethod": "cash", + "paymentmethod": document.getElementById("dropbtn").innerText =="Gotówka"?"cash":"btc", "tournament": localStorage.getItem('tournamentId'), "partner": document.getElementById("ID_input").value } @@ -66,14 +75,82 @@ function tournamentSave() { ) .then(res => { if (res.ok) { - alert("Udało się zapisać!") - window.location.href = '../index.html' + alert("Udało się zapisać!"); + if (document.getElementById("dropbtn").innerText =="Bitcoin") { + }else{ + window.location.href = '../index.html'; + } } else { console.log("Coś poszło nie tak!") } return res }) .then(res => res.json()) + .then(res => { + if (document.getElementById("dropbtn").innerText =="Bitcoin") { + paymentid=res.id; + var splited=res.url.split("/"); + invoiceid=splited[splited.length-1]; + window.btcpay.showInvoice(invoiceid); + window.btcpay.onModalWillLeave(process); + } + }) .catch(error => console.log(error)) } +var counter = 0; +function process(){ + document.getElementById("loader").style.display="block"; + counter = 0; + setTimeout(check, 1000); +} +function check(){ + fetch('https://dragonmaster.pl/inz/registration/paymentstatus?id='+paymentid, { + method: "GET", + headers: { + Authorization: ("Bearer " + localStorage.getItem("token")) + } + } + ) + .then(res => { + if (res.ok) { + } + else { alert("something not work :("); } + return res + }) + .then(res => res.json()) + .then(res => { + if (res.status == "DONE" || res.status == "PROCESSING") { + document.getElementById("loader").style.display="none"; + document.getElementById("msg").style.display="block"; + document.getElementById("msg").innerText="payed"; + window.location.href = '../index.html'; + }else{ + if (res.status == "PENDING" ) { + if(counter==5){ + document.getElementById("loader").style.display="none"; + document.getElementById("msg").style.display="block"; + document.getElementById("msg").innerText="you probably closed popup"; + document.getElementById("reopen").style.display="block"; + }else{ + setTimeout(check, 1000); + } + counter ++; + }else{ + document.getElementById("msg").style.display="block"; + document.getElementById("msg").innerText=res.status; + document.getElementById("reopen").style.display="block"; + + } + } + }) + .catch(error => console.log(error)) + +} +function reopen(){ + document.getElementById("msg").style.display="none"; + document.getElementById("reopen").style.display="none"; + window.btcpay.showInvoice(invoiceid); +} + +document.getElementById("reopen").addEventListener("click",reopen); diff --git a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/index.html b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/index.html index 0fab9bf..644dac3 100644 --- a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/index.html +++ b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/index.html @@ -32,7 +32,7 @@
+ \ No newline at end of file diff --git a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/style.css b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/style.css index 77cd627..3e065df 100644 --- a/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/style.css +++ b/frontend/normal_user/_main page/pojedynczy_turniej/zapisy na turniej/style.css @@ -60,6 +60,7 @@ html { padding-top: 1%; background-color: #ffffff; + position: relative; } /*layer 4*/ @@ -165,4 +166,91 @@ a:active { font-style: normal; font-weight: 600; font-size: 28px; -} \ No newline at end of file +} + + + body { + margin: 0; +} +.loader { + position: absolute; + left:40%; +} +.dot { + width: 24px; + height: 24px; + background: #007c36; + border-radius: 100%; + display: inline-block; + animation: slide 1s infinite; +} +.dot:nth-child(1) { + animation-delay: 0.1s; + background: #007846; +} +.dot:nth-child(2) { + animation-delay: 0.2s; + background: #008c5a; +} +.dot:nth-child(3) { + animation-delay: 0.3s; + background: #00a06e; +} +.dot:nth-child(4) { + animation-delay: 0.4s; + background: #00b482; +} +.dot:nth-child(5) { + animation-delay: 0.5s; + background: #00c896; +} +@-moz-keyframes slide { + 0% { + transform: scale(1); + } + 50% { + opacity: 0.3; + transform: scale(2); + } + 100% { + transform: scale(1); + } +} +@-webkit-keyframes slide { + 0% { + transform: scale(1); + } + 50% { + opacity: 0.3; + transform: scale(2); + } + 100% { + transform: scale(1); + } +} +@-o-keyframes slide { + 0% { + transform: scale(1); + } + 50% { + opacity: 0.3; + transform: scale(2); + } + 100% { + transform: scale(1); + } +} +@keyframes slide { + 0% { + transform: scale(1); + } + 50% { + opacity: 0.3; + transform: scale(2); + } + 100% { + transform: scale(1); + } +} + + \ No newline at end of file