36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
export function showInfo(api) {
|
|
let token = localStorage.getItem("token");
|
|
let id = window.location.pathname.split("/").pop();
|
|
|
|
const requestOptions = {
|
|
method: 'post',
|
|
headers: {
|
|
'Accept': `application/json`,
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Bearer ' + token,
|
|
},
|
|
};
|
|
|
|
fetch(api + "/api/admin/get-sale/" + id, requestOptions)
|
|
.then(response => response.json())
|
|
.then(function (data) {
|
|
console.log(data);
|
|
if (data) {
|
|
document.getElementById("order-no").innerHTML = data.id
|
|
document.getElementById("customer").innerHTML = data.customer.first_name + " " + data.customer.last_name
|
|
document.getElementById("product").innerHTML = data.widget.name
|
|
document.getElementById("quantity").innerHTML = data.quantity
|
|
document.getElementById("amount").innerHTML = formatCurrency(data.transaction.amount)
|
|
}
|
|
});
|
|
}
|
|
|
|
function formatCurrency(amount) {
|
|
let c = parseFloat(amount/100);
|
|
return c.toLocaleString("fr-FR", {
|
|
style:"currency",
|
|
currency: "EUR",
|
|
});
|
|
}
|
|
|