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
|
||||
@Path("{id}/buy/")
|
||||
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
|
||||
|
@ -82,6 +71,7 @@ public class PixelService {
|
|||
if (user.getBalance() >= pixel.getPrice()) {
|
||||
// on update l'owner
|
||||
pixel.setOwner(user);
|
||||
user.setBalance(user.getBalance() - pixel.getPrice());
|
||||
|
||||
// on ajoute la transaction
|
||||
Date now = new Date(System.currentTimeMillis());
|
||||
|
|
|
@ -124,6 +124,11 @@
|
|||
|
||||
Modify pixel
|
||||
|
||||
<div>
|
||||
<label>Solde</label>
|
||||
<span class="solde"></span>
|
||||
</div>
|
||||
|
||||
<form id="modify-form" method="post">
|
||||
<div class="data">
|
||||
<label>Price</label>
|
||||
|
|
|
@ -29,7 +29,7 @@ function pageLoaded() {
|
|||
fetch(event.target.action, {
|
||||
method: event.target.method,
|
||||
body: new URLSearchParams(new FormData(event.target)),
|
||||
}).then((resp) => {
|
||||
}).then(async (resp) => {
|
||||
if (resp.ok) {
|
||||
userLogin();
|
||||
togglePopup("signup");
|
||||
|
|
|
@ -103,7 +103,7 @@ function updateBuyForm(pixel) {
|
|||
description.innerHTML = pixel.description;
|
||||
|
||||
price = document.getElementById("info-price");
|
||||
price.innerHTML = pixel.price;
|
||||
price.innerHTML = pixel.price + " ₹";
|
||||
|
||||
form = document.getElementById("buy-form");
|
||||
form.action = urlPixel + pixel.id + "/buy";
|
||||
|
|
|
@ -73,15 +73,11 @@ function userLogout() {
|
|||
async function updateSolde() {
|
||||
fetch(urlUser).then(async (resp) => {
|
||||
if (resp.ok) {
|
||||
console.log("ici");
|
||||
user = await resp.json();
|
||||
console.log("là");
|
||||
|
||||
let soldes = document.getElementsByClassName("solde");
|
||||
for (element of soldes) {
|
||||
element.innerHTML = user.balance + " €";
|
||||
element.innerHTML = user.balance + " ₹";
|
||||
}
|
||||
console.log("ok");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue