- поправил скрипт на странице кабинета пользователя.

parent 7b80aff7
...@@ -41,33 +41,28 @@ ...@@ -41,33 +41,28 @@
{ {
<script > <script >
$('.tab-pane').click(function (e){ $('.tab-pane').click(async function (e){
e.preventDefault(); e.preventDefault();
let userId = $('h2').attr('userId'); let userId = $('h2').attr('userId');
fetch("https://localhost:5001/Orders/GetAllByUserId/" + userId)
.then((response) => { let resp = await fetch("https://localhost:5001/Orders/GetAllByUserId/" + userId);
return response.json(); if (resp.ok){
})
.then((orders) => {
if (orders.length === 0){
$(this).html('<h3>Заказов нет</h3>');
}
else{
let content; let content;
$.each(orders, (order) => { let orders = await resp.json();
$.each( orders, (i) => {
content += `<tr> content += `<tr>
<td>order.id</td> <td>${orders[i].userId}</td>
<td>order.address</td> <td>${orders[i].address}</td>
<td>order.contactPhone</td> <td>${orders[i].contactPhone}</td>
<td>order.user.Name</td> <td>${orders[i].user.name}</td>
<td>order.phone.Name</td> <td>${orders[i].phone.name}</td>
</tr>` </tr>`
}); });
$('#orders').html(content); $('#orders').html(content);
}else{
alert("Ошибка HTTP: " + response.status);
} }
}); });
});
let makeTabs = function (){ let makeTabs = function (){
let tabs = $(".tabs").find(".tab-items a"); let tabs = $(".tabs").find(".tab-items a");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment