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

parent 7b80aff7
......@@ -41,33 +41,28 @@
{
<script >
$('.tab-pane').click(function (e){
$('.tab-pane').click(async function (e){
e.preventDefault();
let userId = $('h2').attr('userId');
fetch("https://localhost:5001/Orders/GetAllByUserId/" + userId)
.then((response) => {
return response.json();
})
.then((orders) => {
if (orders.length === 0){
$(this).html('<h3>Заказов нет</h3>');
}
else{
let resp = await fetch("https://localhost:5001/Orders/GetAllByUserId/" + userId);
if (resp.ok){
let content;
$.each(orders, (order) => {
let orders = await resp.json();
$.each( orders, (i) => {
content += `<tr>
<td>order.id</td>
<td>order.address</td>
<td>order.contactPhone</td>
<td>order.user.Name</td>
<td>order.phone.Name</td>
<td>${orders[i].userId}</td>
<td>${orders[i].address}</td>
<td>${orders[i].contactPhone}</td>
<td>${orders[i].user.name}</td>
<td>${orders[i].phone.name}</td>
</tr>`
});
$('#orders').html(content);
}else{
alert("Ошибка HTTP: " + response.status);
}
});
});
let makeTabs = function (){
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