-
-
-
+
-
+
+
+
+
@@ -98,6 +98,23 @@
+
+
+
+
+
+
+
+
@@ -130,7 +147,6 @@
Stone Island
super idol rovny pacan, groza rayona, mother's modnik, патч на месте
-
Category:
@@ -348,9 +364,15 @@
e.preventDefault();
const name = document.getElementById("productName").value;
const price = document.getElementById("productPrice").value;
+ const category = document.getElementById("productCategory").value;
+ const condition = document.getElementById("productCondition").value;
const description = document.getElementById("productDescription").value;
const image = document.getElementById("productImage").value;
+ // Получаем текстовые значения для отображения
+ const categoryText = document.getElementById("productCategory").options[document.getElementById("productCategory").selectedIndex].text;
+ const conditionText = document.getElementById("productCondition").options[document.getElementById("productCondition").selectedIndex].text;
+
const productCard = `
@@ -358,6 +380,16 @@
${name}
${description}
+
+
+ Category:
+ ${categoryText}
+
+
+ Condition:
+ ${conditionText}
+
+
diff --git a/components/likes/controller.js b/components/likes/controller.js
index 662acdb..f784d60 100644
--- a/components/likes/controller.js
+++ b/components/likes/controller.js
@@ -71,6 +71,10 @@ export class LikesController {
const description = card.querySelector('.card-text').textContent;
const image = card.querySelector('img').src;
+ // ✅ Вытаскиваем category и condition
+ const category = card.querySelector('.col-6:nth-child(1) p')?.textContent.trim() || '';
+ const condition = card.querySelector('.col-6:nth-child(2) p')?.textContent.trim() || '';
+
const id = btoa(`${name}-${priceText}`).substring(0, 8);
return {
@@ -78,7 +82,9 @@ export class LikesController {
name: name.trim(),
price: parseFloat(priceText),
description: description.trim(),
- image: image
+ image: image,
+ category: category,
+ condition: condition
};
} catch (error) {
console.error('Ошибка при извлечении данных товара:', error);
diff --git a/components/likes/view.js b/components/likes/view.js
index d44cf0e..5e8eff7 100644
--- a/components/likes/view.js
+++ b/components/likes/view.js
@@ -26,27 +26,47 @@ export class LikesView {
}
createLikesItemHTML(item) {
- return `
-
-
-
-
- ${item.name}
- ${item.description}
- $${item.price}
+ return `
+
+
+
+
+ ${item.name}
+ ${item.description}
+
+
+
+
+ Category:
+ ${item.category || '-'}
+
+
+ Condition:
+ ${item.condition || '-'}
+
-
-
-
+
+
+
+
+
+
+
+ $${item.price}
+
+
+
+
+
+
-
- `;
- }
+ `;
+}
showEmptyLikes() {
if (this.emptyLikesElement) {
diff --git a/db.json b/db.json
index f4fc114..215988f 100644
--- a/db.json
+++ b/db.json
@@ -70,24 +70,6 @@
"name": "wu"
}
],
- "likes": [
- {
- "id": "U3RvbmUgSXNs",
- "name": "Stone Island",
- "price": 1999.99,
- "description": "super idol rovny pacan, groza rayona, mother's modnik, патч на месте",
- "image": "http://192.168.31.212:4000/assets/stonik-D_cwcHTM.jpg"
- }
- ],
- "basket": [
- {
- "id": "U3RvbmUgSXNs",
- "name": "Stone Island",
- "price": 1999.99,
- "description": "super idol rovny pacan, groza rayona, mother's modnik, патч на месте",
- "image": "http://192.168.31.212:4000/assets/stonik-D_cwcHTM.jpg",
- "quantity": 1,
- "addedAt": "2025-09-26T10:54:28.952Z"
- }
- ]
+ "likes": [],
+ "basket": []
}
\ No newline at end of file
diff --git a/dist/assets/controller-BaU4rR-2.js b/dist/assets/controller-BaU4rR-2.js
deleted file mode 100644
index f1879c5..0000000
--- a/dist/assets/controller-BaU4rR-2.js
+++ /dev/null
@@ -1,26 +0,0 @@
-class r{constructor(){this.apiUrl="http://localhost:3000"}async request(t,e={}){const s=await fetch(`${this.apiUrl}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}async getLikesItems(){try{return await this.request("/likes")}catch(t){return console.error("Ошибка при получении избранного:",t),[]}}async addToLikes(t){try{if(!(await this.getLikesItems()).find(i=>i.id===t.id))return await(await fetch(`${this.apiUrl}/likes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json()}catch(e){console.error("Ошибка при добавлении в избранное:",e)}}async removeFromLikes(t){try{await fetch(`${this.apiUrl}/likes/${t}`,{method:"DELETE"})}catch(e){console.error("Ошибка при удалении из избранного:",e)}}async moveToBasket(t){try{await(await fetch(`${this.apiUrl}/basket`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,quantity:1,addedAt:new Date().toISOString()})})).json(),await this.removeFromLikes(t.id)}catch(e){console.error("Ошибка при переносе товара в корзину:",e)}}}class c{constructor(){this.likesContainer=document.getElementById("likesContainer"),this.emptyLikesElement=document.querySelector(".empty-likes")}showLikes(t){if(!this.likesContainer)return;if(!t||t.length===0){this.showEmptyLikes();return}this.hideEmptyLikes();const e=t.map(s=>this.createLikesItemHTML(s)).join("");this.likesContainer.innerHTML=`
- Избранное
- ${e}
- `}createLikesItemHTML(t){return`
-
-
-
-
- ${t.name}
- ${t.description}
- $${t.price}
-
-
-
-
-
-
-
- `}showEmptyLikes(){this.emptyLikesElement&&(this.emptyLikesElement.style.display="block"),this.likesContainer&&(this.likesContainer.innerHTML="")}hideEmptyLikes(){this.emptyLikesElement&&(this.emptyLikesElement.style.display="none")}showNotification(t,e="success"){const s=document.createElement("div");s.className=`alert alert-${e==="success"?"success":"danger"} alert-dismissible fade show`,s.style.cssText="position: fixed; top: 20px; right: 20px; z-index: 1050; min-width: 300px;",s.innerHTML=`
- ${t}
-
- `,document.body.appendChild(s),setTimeout(()=>{s.parentNode&&s.remove()},3e3)}}class l{constructor(t,e){this.model=t,this.view=e,this.init()}async init(){window.location.pathname.includes("likes.html")&&(await this.loadLikes(),this.setupLikesEventListeners()),window.location.pathname.includes("catalog.html")&&this.setupCatalogEventListeners()}async loadLikes(){const t=await this.model.getLikesItems();this.view.showLikes(t)}setupLikesEventListeners(){document.addEventListener("click",async t=>{const e=t.target.closest(".like-item");if(!e)return;const s=e.dataset.id;if(t.target.closest(".remove-like-btn")&&(await this.model.removeFromLikes(s),this.view.showNotification("Товар удален из избранного"),await this.loadLikes()),t.target.closest(".move-to-basket-btn")){const o=(await this.model.getLikesItems()).find(n=>n.id===s);o&&(await this.model.moveToBasket(o),this.view.showNotification("Товар перенесен в корзину"),await this.loadLikes())}})}setupCatalogEventListeners(){document.addEventListener("click",async t=>{const e=t.target.closest(".card");if(e&&t.target.closest(".like-btn")){const s=this.extractProductData(e);s&&(await this.model.addToLikes(s),this.view.showNotification("Товар добавлен в избранное!"))}})}extractProductData(t){try{const e=t.querySelector(".card-title").textContent,s=t.querySelector(".text-muted").textContent.replace("$",""),i=t.querySelector(".card-text").textContent,o=t.querySelector("img").src;return{id:btoa(`${e}-${s}`).substring(0,8),name:e.trim(),price:parseFloat(s),description:i.trim(),image:o}}catch(e){return console.error("Ошибка при извлечении данных товара:",e),null}}}export{c as L,l as a,r as b};
diff --git a/dist/assets/controller-BsNF2rMP.js b/dist/assets/controller-BsNF2rMP.js
new file mode 100644
index 0000000..74bcce7
--- /dev/null
+++ b/dist/assets/controller-BsNF2rMP.js
@@ -0,0 +1,46 @@
+class h{constructor(){this.apiUrl="http://localhost:3000"}async request(t,e={}){const s=await fetch(`${this.apiUrl}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}async getLikesItems(){try{return await this.request("/likes")}catch(t){return console.error("Ошибка при получении избранного:",t),[]}}async addToLikes(t){try{if(!(await this.getLikesItems()).find(i=>i.id===t.id))return await(await fetch(`${this.apiUrl}/likes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json()}catch(e){console.error("Ошибка при добавлении в избранное:",e)}}async removeFromLikes(t){try{await fetch(`${this.apiUrl}/likes/${t}`,{method:"DELETE"})}catch(e){console.error("Ошибка при удалении из избранного:",e)}}async moveToBasket(t){try{await(await fetch(`${this.apiUrl}/basket`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,quantity:1,addedAt:new Date().toISOString()})})).json(),await this.removeFromLikes(t.id)}catch(e){console.error("Ошибка при переносе товара в корзину:",e)}}}class m{constructor(){this.likesContainer=document.getElementById("likesContainer"),this.emptyLikesElement=document.querySelector(".empty-likes")}showLikes(t){if(!this.likesContainer)return;if(!t||t.length===0){this.showEmptyLikes();return}this.hideEmptyLikes();const e=t.map(s=>this.createLikesItemHTML(s)).join("");this.likesContainer.innerHTML=`
+ Избранное
+ ${e}
+ `}createLikesItemHTML(t){return`
+
+
+
+
+ ${t.name}
+ ${t.description}
+
+
+
+
+ Category:
+ ${t.category||"-"}
+
+
+ Condition:
+ ${t.condition||"-"}
+
+
+
+
+
+
+
+
+
+ $${t.price}
+
+
+
+
+
+
+
+
+ `}showEmptyLikes(){this.emptyLikesElement&&(this.emptyLikesElement.style.display="block"),this.likesContainer&&(this.likesContainer.innerHTML="")}hideEmptyLikes(){this.emptyLikesElement&&(this.emptyLikesElement.style.display="none")}showNotification(t,e="success"){const s=document.createElement("div");s.className=`alert alert-${e==="success"?"success":"danger"} alert-dismissible fade show`,s.style.cssText="position: fixed; top: 20px; right: 20px; z-index: 1050; min-width: 300px;",s.innerHTML=`
+ ${t}
+
+ `,document.body.appendChild(s),setTimeout(()=>{s.parentNode&&s.remove()},3e3)}}class p{constructor(t,e){this.model=t,this.view=e,this.init()}async init(){window.location.pathname.includes("likes.html")&&(await this.loadLikes(),this.setupLikesEventListeners()),window.location.pathname.includes("catalog.html")&&this.setupCatalogEventListeners()}async loadLikes(){const t=await this.model.getLikesItems();this.view.showLikes(t)}setupLikesEventListeners(){document.addEventListener("click",async t=>{const e=t.target.closest(".like-item");if(!e)return;const s=e.dataset.id;if(t.target.closest(".remove-like-btn")&&(await this.model.removeFromLikes(s),this.view.showNotification("Товар удален из избранного"),await this.loadLikes()),t.target.closest(".move-to-basket-btn")){const o=(await this.model.getLikesItems()).find(a=>a.id===s);o&&(await this.model.moveToBasket(o),this.view.showNotification("Товар перенесен в корзину"),await this.loadLikes())}})}setupCatalogEventListeners(){document.addEventListener("click",async t=>{const e=t.target.closest(".card");if(e&&t.target.closest(".like-btn")){const s=this.extractProductData(e);s&&(await this.model.addToLikes(s),this.view.showNotification("Товар добавлен в избранное!"))}})}extractProductData(t){var e,s;try{const i=t.querySelector(".card-title").textContent,o=t.querySelector(".text-muted").textContent.replace("$",""),a=t.querySelector(".card-text").textContent,r=t.querySelector("img").src,c=((e=t.querySelector(".col-6:nth-child(1) p"))==null?void 0:e.textContent.trim())||"",l=((s=t.querySelector(".col-6:nth-child(2) p"))==null?void 0:s.textContent.trim())||"";return{id:btoa(`${i}-${o}`).substring(0,8),name:i.trim(),price:parseFloat(o),description:a.trim(),image:r,category:c,condition:l}}catch(i){return console.error("Ошибка при извлечении данных товара:",i),null}}}export{m as L,p as a,h as b};
diff --git a/dist/assets/page2-DYag8OKJ.js b/dist/assets/page2-Crmhwurg.js
similarity index 87%
rename from dist/assets/page2-DYag8OKJ.js
rename to dist/assets/page2-Crmhwurg.js
index c913dc0..40f9bf5 100644
--- a/dist/assets/page2-DYag8OKJ.js
+++ b/dist/assets/page2-Crmhwurg.js
@@ -1 +1 @@
-import"./modulepreload-polyfill-B5Qt9EMX.js";/* empty css */import{L as t,a as o,b as d}from"./controller-BaU4rR-2.js";import{V as i,C as s,M as r}from"./controller-BHzoImTo.js";document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("productsContainer")){const e=new d,n=new t;new o(e,n)}});document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("basketContainer")||document.getElementById("productsContainer")){const e=new r,n=new i;new s(e,n)}});
+import"./modulepreload-polyfill-B5Qt9EMX.js";/* empty css */import{L as t,a as o,b as d}from"./controller-BsNF2rMP.js";import{V as i,C as s,M as r}from"./controller-BHzoImTo.js";document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("productsContainer")){const e=new d,n=new t;new o(e,n)}});document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("basketContainer")||document.getElementById("productsContainer")){const e=new r,n=new i;new s(e,n)}});
diff --git a/dist/assets/page4-C9wa6TTi.js b/dist/assets/page4-DyyBeFxE.js
similarity index 76%
rename from dist/assets/page4-C9wa6TTi.js
rename to dist/assets/page4-DyyBeFxE.js
index 34cf083..4399df8 100644
--- a/dist/assets/page4-C9wa6TTi.js
+++ b/dist/assets/page4-DyyBeFxE.js
@@ -1 +1 @@
-import"./modulepreload-polyfill-B5Qt9EMX.js";/* empty css */import{L as o,a as t,b as i}from"./controller-BaU4rR-2.js";document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("likesContainer")){const e=new i,n=new o;new t(e,n)}});
+import"./modulepreload-polyfill-B5Qt9EMX.js";/* empty css */import{L as o,a as t,b as i}from"./controller-BsNF2rMP.js";document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("likesContainer")){const e=new i,n=new o;new t(e,n)}});
diff --git a/dist/catalog.html b/dist/catalog.html
index f2b62e2..ce0f611 100644
--- a/dist/catalog.html
+++ b/dist/catalog.html
@@ -26,9 +26,9 @@
transition: text-shadow 0.2s ease;
}
-
+
-
+
@@ -82,12 +82,12 @@
-
-
-
-
+
+
+
+
@@ -102,6 +102,23 @@
+
+
+
+
+
+
+
+
@@ -134,7 +151,6 @@
Stone Island
super idol rovny pacan, groza rayona, mother's modnik, патч на месте
-
Category:
@@ -352,9 +368,15 @@
e.preventDefault();
const name = document.getElementById("productName").value;
const price = document.getElementById("productPrice").value;
+ const category = document.getElementById("productCategory").value;
+ const condition = document.getElementById("productCondition").value;
const description = document.getElementById("productDescription").value;
const image = document.getElementById("productImage").value;
+ // Получаем текстовые значения для отображения
+ const categoryText = document.getElementById("productCategory").options[document.getElementById("productCategory").selectedIndex].text;
+ const conditionText = document.getElementById("productCondition").options[document.getElementById("productCondition").selectedIndex].text;
+
const productCard = `
@@ -362,6 +384,16 @@
${name}
${description}
+
+
+ Category:
+ ${categoryText}
+
+
+ Condition:
+ ${conditionText}
+
+
diff --git a/dist/likes.html b/dist/likes.html
index 12bda12..b4d9105 100644
--- a/dist/likes.html
+++ b/dist/likes.html
@@ -7,9 +7,9 @@
-
+
-
+
+
+
@@ -98,6 +98,23 @@
+
+
+
+
+
+
+
+
@@ -130,7 +147,6 @@
Stone Island
super idol rovny pacan, groza rayona, mother's modnik, патч на месте
-Category:
@@ -348,9 +364,15 @@ e.preventDefault(); const name = document.getElementById("productName").value; const price = document.getElementById("productPrice").value; + const category = document.getElementById("productCategory").value; + const condition = document.getElementById("productCondition").value; const description = document.getElementById("productDescription").value; const image = document.getElementById("productImage").value; + // Получаем текстовые значения для отображения + const categoryText = document.getElementById("productCategory").options[document.getElementById("productCategory").selectedIndex].text; + const conditionText = document.getElementById("productCondition").options[document.getElementById("productCondition").selectedIndex].text; + const productCard = `
@@ -358,6 +380,16 @@
${name}
${description}
+
+
+
+ Category:
+${categoryText}
+
+
+ Condition:
+${conditionText}
+
diff --git a/components/likes/controller.js b/components/likes/controller.js
index 662acdb..f784d60 100644
--- a/components/likes/controller.js
+++ b/components/likes/controller.js
@@ -71,6 +71,10 @@ export class LikesController {
const description = card.querySelector('.card-text').textContent;
const image = card.querySelector('img').src;
+ // ✅ Вытаскиваем category и condition
+ const category = card.querySelector('.col-6:nth-child(1) p')?.textContent.trim() || '';
+ const condition = card.querySelector('.col-6:nth-child(2) p')?.textContent.trim() || '';
+
const id = btoa(`${name}-${priceText}`).substring(0, 8);
return {
@@ -78,7 +82,9 @@ export class LikesController {
name: name.trim(),
price: parseFloat(priceText),
description: description.trim(),
- image: image
+ image: image,
+ category: category,
+ condition: condition
};
} catch (error) {
console.error('Ошибка при извлечении данных товара:', error);
diff --git a/components/likes/view.js b/components/likes/view.js
index d44cf0e..5e8eff7 100644
--- a/components/likes/view.js
+++ b/components/likes/view.js
@@ -26,27 +26,47 @@ export class LikesView {
}
createLikesItemHTML(item) {
- return `
-
-
-
-
-
${item.name}
-${item.description}
- $${item.price} + return ` +
+
+
+
+
- `;
- }
+ `;
+}
showEmptyLikes() {
if (this.emptyLikesElement) {
diff --git a/db.json b/db.json
index f4fc114..215988f 100644
--- a/db.json
+++ b/db.json
@@ -70,24 +70,6 @@
"name": "wu"
}
],
- "likes": [
- {
- "id": "U3RvbmUgSXNs",
- "name": "Stone Island",
- "price": 1999.99,
- "description": "super idol rovny pacan, groza rayona, mother's modnik, патч на месте",
- "image": "http://192.168.31.212:4000/assets/stonik-D_cwcHTM.jpg"
- }
- ],
- "basket": [
- {
- "id": "U3RvbmUgSXNs",
- "name": "Stone Island",
- "price": 1999.99,
- "description": "super idol rovny pacan, groza rayona, mother's modnik, патч на месте",
- "image": "http://192.168.31.212:4000/assets/stonik-D_cwcHTM.jpg",
- "quantity": 1,
- "addedAt": "2025-09-26T10:54:28.952Z"
- }
- ]
+ "likes": [],
+ "basket": []
}
\ No newline at end of file
diff --git a/dist/assets/controller-BaU4rR-2.js b/dist/assets/controller-BaU4rR-2.js
deleted file mode 100644
index f1879c5..0000000
--- a/dist/assets/controller-BaU4rR-2.js
+++ /dev/null
@@ -1,26 +0,0 @@
-class r{constructor(){this.apiUrl="http://localhost:3000"}async request(t,e={}){const s=await fetch(`${this.apiUrl}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}async getLikesItems(){try{return await this.request("/likes")}catch(t){return console.error("Ошибка при получении избранного:",t),[]}}async addToLikes(t){try{if(!(await this.getLikesItems()).find(i=>i.id===t.id))return await(await fetch(`${this.apiUrl}/likes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json()}catch(e){console.error("Ошибка при добавлении в избранное:",e)}}async removeFromLikes(t){try{await fetch(`${this.apiUrl}/likes/${t}`,{method:"DELETE"})}catch(e){console.error("Ошибка при удалении из избранного:",e)}}async moveToBasket(t){try{await(await fetch(`${this.apiUrl}/basket`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,quantity:1,addedAt:new Date().toISOString()})})).json(),await this.removeFromLikes(t.id)}catch(e){console.error("Ошибка при переносе товара в корзину:",e)}}}class c{constructor(){this.likesContainer=document.getElementById("likesContainer"),this.emptyLikesElement=document.querySelector(".empty-likes")}showLikes(t){if(!this.likesContainer)return;if(!t||t.length===0){this.showEmptyLikes();return}this.hideEmptyLikes();const e=t.map(s=>this.createLikesItemHTML(s)).join("");this.likesContainer.innerHTML=`
- ${item.name}
+${item.description}
+ + +
+
-
+
+ Category:
+${item.category || '-'}
+
+
Condition:
+${item.condition || '-'}
+
-
-
+
+
+
+
+
+
-
+
+ $${item.price}
+
+
+
+
+
+
Избранное
-${e}
- `}createLikesItemHTML(t){return`
-
-
- `}showEmptyLikes(){this.emptyLikesElement&&(this.emptyLikesElement.style.display="block"),this.likesContainer&&(this.likesContainer.innerHTML="")}hideEmptyLikes(){this.emptyLikesElement&&(this.emptyLikesElement.style.display="none")}showNotification(t,e="success"){const s=document.createElement("div");s.className=`alert alert-${e==="success"?"success":"danger"} alert-dismissible fade show`,s.style.cssText="position: fixed; top: 20px; right: 20px; z-index: 1050; min-width: 300px;",s.innerHTML=`
- ${t}
-
- `,document.body.appendChild(s),setTimeout(()=>{s.parentNode&&s.remove()},3e3)}}class l{constructor(t,e){this.model=t,this.view=e,this.init()}async init(){window.location.pathname.includes("likes.html")&&(await this.loadLikes(),this.setupLikesEventListeners()),window.location.pathname.includes("catalog.html")&&this.setupCatalogEventListeners()}async loadLikes(){const t=await this.model.getLikesItems();this.view.showLikes(t)}setupLikesEventListeners(){document.addEventListener("click",async t=>{const e=t.target.closest(".like-item");if(!e)return;const s=e.dataset.id;if(t.target.closest(".remove-like-btn")&&(await this.model.removeFromLikes(s),this.view.showNotification("Товар удален из избранного"),await this.loadLikes()),t.target.closest(".move-to-basket-btn")){const o=(await this.model.getLikesItems()).find(n=>n.id===s);o&&(await this.model.moveToBasket(o),this.view.showNotification("Товар перенесен в корзину"),await this.loadLikes())}})}setupCatalogEventListeners(){document.addEventListener("click",async t=>{const e=t.target.closest(".card");if(e&&t.target.closest(".like-btn")){const s=this.extractProductData(e);s&&(await this.model.addToLikes(s),this.view.showNotification("Товар добавлен в избранное!"))}})}extractProductData(t){try{const e=t.querySelector(".card-title").textContent,s=t.querySelector(".text-muted").textContent.replace("$",""),i=t.querySelector(".card-text").textContent,o=t.querySelector("img").src;return{id:btoa(`${e}-${s}`).substring(0,8),name:e.trim(),price:parseFloat(s),description:i.trim(),image:o}}catch(e){return console.error("Ошибка при извлечении данных товара:",e),null}}}export{c as L,l as a,r as b};
diff --git a/dist/assets/controller-BsNF2rMP.js b/dist/assets/controller-BsNF2rMP.js
new file mode 100644
index 0000000..74bcce7
--- /dev/null
+++ b/dist/assets/controller-BsNF2rMP.js
@@ -0,0 +1,46 @@
+class h{constructor(){this.apiUrl="http://localhost:3000"}async request(t,e={}){const s=await fetch(`${this.apiUrl}${t}`,{...e,headers:{"Content-Type":"application/json",...e.headers}});if(!s.ok)throw new Error(`HTTP error! status: ${s.status}`);return await s.json()}async getLikesItems(){try{return await this.request("/likes")}catch(t){return console.error("Ошибка при получении избранного:",t),[]}}async addToLikes(t){try{if(!(await this.getLikesItems()).find(i=>i.id===t.id))return await(await fetch(`${this.apiUrl}/likes`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json()}catch(e){console.error("Ошибка при добавлении в избранное:",e)}}async removeFromLikes(t){try{await fetch(`${this.apiUrl}/likes/${t}`,{method:"DELETE"})}catch(e){console.error("Ошибка при удалении из избранного:",e)}}async moveToBasket(t){try{await(await fetch(`${this.apiUrl}/basket`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...t,quantity:1,addedAt:new Date().toISOString()})})).json(),await this.removeFromLikes(t.id)}catch(e){console.error("Ошибка при переносе товара в корзину:",e)}}}class m{constructor(){this.likesContainer=document.getElementById("likesContainer"),this.emptyLikesElement=document.querySelector(".empty-likes")}showLikes(t){if(!this.likesContainer)return;if(!t||t.length===0){this.showEmptyLikes();return}this.hideEmptyLikes();const e=t.map(s=>this.createLikesItemHTML(s)).join("");this.likesContainer.innerHTML=`
+
-
-
-
-
- ${t.name}
-${t.description}
- $${t.price} -
-
-
-
- Избранное
+${e}
+ `}createLikesItemHTML(t){return`
+
+
+
+
-
+
+
+ ${t.name}
+${t.description}
+ + +
+
+
+
+
+
+ Category:
+${t.category||"-"}
+
+
+ Condition:
+${t.condition||"-"}
+
+
+ `}showEmptyLikes(){this.emptyLikesElement&&(this.emptyLikesElement.style.display="block"),this.likesContainer&&(this.likesContainer.innerHTML="")}hideEmptyLikes(){this.emptyLikesElement&&(this.emptyLikesElement.style.display="none")}showNotification(t,e="success"){const s=document.createElement("div");s.className=`alert alert-${e==="success"?"success":"danger"} alert-dismissible fade show`,s.style.cssText="position: fixed; top: 20px; right: 20px; z-index: 1050; min-width: 300px;",s.innerHTML=`
+ ${t}
+
+ `,document.body.appendChild(s),setTimeout(()=>{s.parentNode&&s.remove()},3e3)}}class p{constructor(t,e){this.model=t,this.view=e,this.init()}async init(){window.location.pathname.includes("likes.html")&&(await this.loadLikes(),this.setupLikesEventListeners()),window.location.pathname.includes("catalog.html")&&this.setupCatalogEventListeners()}async loadLikes(){const t=await this.model.getLikesItems();this.view.showLikes(t)}setupLikesEventListeners(){document.addEventListener("click",async t=>{const e=t.target.closest(".like-item");if(!e)return;const s=e.dataset.id;if(t.target.closest(".remove-like-btn")&&(await this.model.removeFromLikes(s),this.view.showNotification("Товар удален из избранного"),await this.loadLikes()),t.target.closest(".move-to-basket-btn")){const o=(await this.model.getLikesItems()).find(a=>a.id===s);o&&(await this.model.moveToBasket(o),this.view.showNotification("Товар перенесен в корзину"),await this.loadLikes())}})}setupCatalogEventListeners(){document.addEventListener("click",async t=>{const e=t.target.closest(".card");if(e&&t.target.closest(".like-btn")){const s=this.extractProductData(e);s&&(await this.model.addToLikes(s),this.view.showNotification("Товар добавлен в избранное!"))}})}extractProductData(t){var e,s;try{const i=t.querySelector(".card-title").textContent,o=t.querySelector(".text-muted").textContent.replace("$",""),a=t.querySelector(".card-text").textContent,r=t.querySelector("img").src,c=((e=t.querySelector(".col-6:nth-child(1) p"))==null?void 0:e.textContent.trim())||"",l=((s=t.querySelector(".col-6:nth-child(2) p"))==null?void 0:s.textContent.trim())||"";return{id:btoa(`${i}-${o}`).substring(0,8),name:i.trim(),price:parseFloat(o),description:a.trim(),image:r,category:c,condition:l}}catch(i){return console.error("Ошибка при извлечении данных товара:",i),null}}}export{m as L,p as a,h as b};
diff --git a/dist/assets/page2-DYag8OKJ.js b/dist/assets/page2-Crmhwurg.js
similarity index 87%
rename from dist/assets/page2-DYag8OKJ.js
rename to dist/assets/page2-Crmhwurg.js
index c913dc0..40f9bf5 100644
--- a/dist/assets/page2-DYag8OKJ.js
+++ b/dist/assets/page2-Crmhwurg.js
@@ -1 +1 @@
-import"./modulepreload-polyfill-B5Qt9EMX.js";/* empty css */import{L as t,a as o,b as d}from"./controller-BaU4rR-2.js";import{V as i,C as s,M as r}from"./controller-BHzoImTo.js";document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("productsContainer")){const e=new d,n=new t;new o(e,n)}});document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("basketContainer")||document.getElementById("productsContainer")){const e=new r,n=new i;new s(e,n)}});
+import"./modulepreload-polyfill-B5Qt9EMX.js";/* empty css */import{L as t,a as o,b as d}from"./controller-BsNF2rMP.js";import{V as i,C as s,M as r}from"./controller-BHzoImTo.js";document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("productsContainer")){const e=new d,n=new t;new o(e,n)}});document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("basketContainer")||document.getElementById("productsContainer")){const e=new r,n=new i;new s(e,n)}});
diff --git a/dist/assets/page4-C9wa6TTi.js b/dist/assets/page4-DyyBeFxE.js
similarity index 76%
rename from dist/assets/page4-C9wa6TTi.js
rename to dist/assets/page4-DyyBeFxE.js
index 34cf083..4399df8 100644
--- a/dist/assets/page4-C9wa6TTi.js
+++ b/dist/assets/page4-DyyBeFxE.js
@@ -1 +1 @@
-import"./modulepreload-polyfill-B5Qt9EMX.js";/* empty css */import{L as o,a as t,b as i}from"./controller-BaU4rR-2.js";document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("likesContainer")){const e=new i,n=new o;new t(e,n)}});
+import"./modulepreload-polyfill-B5Qt9EMX.js";/* empty css */import{L as o,a as t,b as i}from"./controller-BsNF2rMP.js";document.addEventListener("DOMContentLoaded",function(){if(document.getElementById("likesContainer")){const e=new i,n=new o;new t(e,n)}});
diff --git a/dist/catalog.html b/dist/catalog.html
index f2b62e2..ce0f611 100644
--- a/dist/catalog.html
+++ b/dist/catalog.html
@@ -26,9 +26,9 @@
transition: text-shadow 0.2s ease;
}
-
+
-
+
@@ -82,12 +82,12 @@
+
+ $${t.price}
+
+
+
+
+
+
+
+
-
-
-
+
-
+
+
+
+
@@ -102,6 +102,23 @@
+
+
+
+
+
+
+
+
@@ -134,7 +151,6 @@
Stone Island
super idol rovny pacan, groza rayona, mother's modnik, патч на месте
-
Category:
@@ -352,9 +368,15 @@
e.preventDefault();
const name = document.getElementById("productName").value;
const price = document.getElementById("productPrice").value;
+ const category = document.getElementById("productCategory").value;
+ const condition = document.getElementById("productCondition").value;
const description = document.getElementById("productDescription").value;
const image = document.getElementById("productImage").value;
+ // Получаем текстовые значения для отображения
+ const categoryText = document.getElementById("productCategory").options[document.getElementById("productCategory").selectedIndex].text;
+ const conditionText = document.getElementById("productCondition").options[document.getElementById("productCondition").selectedIndex].text;
+
const productCard = `
@@ -362,6 +384,16 @@
${name}
${description}
+
+
+ Category:
+ ${categoryText}
+
+
+ Condition:
+ ${conditionText}
+
+
diff --git a/dist/likes.html b/dist/likes.html
index 12bda12..b4d9105 100644
--- a/dist/likes.html
+++ b/dist/likes.html
@@ -7,9 +7,9 @@
-
+
-
+
+
+
@@ -102,6 +102,23 @@
+
+
+
+
+
+
+
+
@@ -134,7 +151,6 @@
Stone Island
super idol rovny pacan, groza rayona, mother's modnik, патч на месте
-Category:
@@ -352,9 +368,15 @@ e.preventDefault(); const name = document.getElementById("productName").value; const price = document.getElementById("productPrice").value; + const category = document.getElementById("productCategory").value; + const condition = document.getElementById("productCondition").value; const description = document.getElementById("productDescription").value; const image = document.getElementById("productImage").value; + // Получаем текстовые значения для отображения + const categoryText = document.getElementById("productCategory").options[document.getElementById("productCategory").selectedIndex].text; + const conditionText = document.getElementById("productCondition").options[document.getElementById("productCondition").selectedIndex].text; + const productCard = `
@@ -362,6 +384,16 @@
${name}
${description}
+
+
+
+ Category:
+${categoryText}
+
+
+ Condition:
+${conditionText}
+
diff --git a/dist/likes.html b/dist/likes.html
index 12bda12..b4d9105 100644
--- a/dist/likes.html
+++ b/dist/likes.html
@@ -7,9 +7,9 @@
-
+
-
+