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

parent 7b80aff7
...@@ -41,32 +41,27 @@ ...@@ -41,32 +41,27 @@
{ {
<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){
}) let content;
.then((orders) => { let orders = await resp.json();
if (orders.length === 0){ $.each( orders, (i) => {
$(this).html('<h3>Заказов нет</h3>'); content += `<tr>
} <td>${orders[i].userId}</td>
else{ <td>${orders[i].address}</td>
let content; <td>${orders[i].contactPhone}</td>
$.each(orders, (order) => { <td>${orders[i].user.name}</td>
content += `<tr> <td>${orders[i].phone.name}</td>
<td>order.id</td> </tr>`
<td>order.address</td>
<td>order.contactPhone</td>
<td>order.user.Name</td>
<td>order.phone.Name</td>
</tr>`
});
$('#orders').html(content);
}
}); });
$('#orders').html(content);
}else{
alert("Ошибка HTTP: " + response.status);
}
}); });
let makeTabs = function (){ let makeTabs = function (){
......
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