f5 !
This commit is contained in:
parent
fbcdc11329
commit
9dc30fd47c
|
@ -58,17 +58,6 @@ public class PixelService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@PUT
|
|
||||||
@Path("{id}")
|
|
||||||
@Consumes(MediaType.APPLICATION_JSON)
|
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
|
||||||
public String update(@PathParam("id") Long id, String json) {
|
|
||||||
Pixel pixel = gson.fromJson(json, Pixel.class);
|
|
||||||
pixel.setId(id);
|
|
||||||
em.merge(pixel);
|
|
||||||
return gson.toJson(pixel);
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path("{id}/buy/")
|
@Path("{id}/buy/")
|
||||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||||
|
@ -82,6 +71,7 @@ public class PixelService {
|
||||||
if (user.getBalance() >= pixel.getPrice()) {
|
if (user.getBalance() >= pixel.getPrice()) {
|
||||||
// on update l'owner
|
// on update l'owner
|
||||||
pixel.setOwner(user);
|
pixel.setOwner(user);
|
||||||
|
user.setBalance(user.getBalance() - pixel.getPrice());
|
||||||
|
|
||||||
// on ajoute la transaction
|
// on ajoute la transaction
|
||||||
Date now = new Date(System.currentTimeMillis());
|
Date now = new Date(System.currentTimeMillis());
|
||||||
|
|
|
@ -124,6 +124,11 @@
|
||||||
|
|
||||||
Modify pixel
|
Modify pixel
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label>Solde</label>
|
||||||
|
<span class="solde"></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form id="modify-form" method="post">
|
<form id="modify-form" method="post">
|
||||||
<div class="data">
|
<div class="data">
|
||||||
<label>Price</label>
|
<label>Price</label>
|
||||||
|
|
|
@ -29,7 +29,7 @@ function pageLoaded() {
|
||||||
fetch(event.target.action, {
|
fetch(event.target.action, {
|
||||||
method: event.target.method,
|
method: event.target.method,
|
||||||
body: new URLSearchParams(new FormData(event.target)),
|
body: new URLSearchParams(new FormData(event.target)),
|
||||||
}).then((resp) => {
|
}).then(async (resp) => {
|
||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
userLogin();
|
userLogin();
|
||||||
togglePopup("signup");
|
togglePopup("signup");
|
||||||
|
|
|
@ -103,7 +103,7 @@ function updateBuyForm(pixel) {
|
||||||
description.innerHTML = pixel.description;
|
description.innerHTML = pixel.description;
|
||||||
|
|
||||||
price = document.getElementById("info-price");
|
price = document.getElementById("info-price");
|
||||||
price.innerHTML = pixel.price;
|
price.innerHTML = pixel.price + " ₹";
|
||||||
|
|
||||||
form = document.getElementById("buy-form");
|
form = document.getElementById("buy-form");
|
||||||
form.action = urlPixel + pixel.id + "/buy";
|
form.action = urlPixel + pixel.id + "/buy";
|
||||||
|
|
|
@ -73,15 +73,11 @@ function userLogout() {
|
||||||
async function updateSolde() {
|
async function updateSolde() {
|
||||||
fetch(urlUser).then(async (resp) => {
|
fetch(urlUser).then(async (resp) => {
|
||||||
if (resp.ok) {
|
if (resp.ok) {
|
||||||
console.log("ici");
|
|
||||||
user = await resp.json();
|
user = await resp.json();
|
||||||
console.log("là");
|
|
||||||
|
|
||||||
let soldes = document.getElementsByClassName("solde");
|
let soldes = document.getElementsByClassName("solde");
|
||||||
for (element of soldes) {
|
for (element of soldes) {
|
||||||
element.innerHTML = user.balance + " €";
|
element.innerHTML = user.balance + " ₹";
|
||||||
}
|
}
|
||||||
console.log("ok");
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue