ты думаешь у меня есть только вера?
болван, мне больше ничего и не надо
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
node_modules
|
||||
dist
|
||||
@@ -1,16 +0,0 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es2021": true
|
||||
},
|
||||
"extends": ["airbnb-base", "prettier"],
|
||||
"plugins": ["prettier", "html"],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 12,
|
||||
"sourceType": "module"
|
||||
},
|
||||
"rules": {
|
||||
"prettier/prettier": "error",
|
||||
"no-console": "off"
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"tabWidth": 4,
|
||||
"singleQuote": false,
|
||||
"printWidth": 120,
|
||||
"trailingComma": "es5",
|
||||
"useTabs": false
|
||||
}
|
||||
@@ -29,7 +29,6 @@
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-gender-male me-2"></i>Для мужчин</a></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-gender-female me-2"></i>Для женщин</a></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-emoji-smile me-2"></i>Для детей</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-globe me-2"></i>Заказ из-за границы</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -48,7 +48,6 @@
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-gender-male me-2"></i>Для мужчин</a></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-gender-female me-2"></i>Для женщин</a></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-emoji-smile me-2"></i>Для детей</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-globe me-2"></i>Заказ из-за границы</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-gender-male me-2"></i>Для мужчин</a></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-gender-female me-2"></i>Для женщин</a></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-emoji-smile me-2"></i>Для детей</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-globe me-2"></i>Заказ из-за границы</a></li>
|
||||
</ul>
|
||||
|
||||
77
db.json
Normal file
77
db.json
Normal file
@@ -0,0 +1,77 @@
|
||||
{
|
||||
"shmots" :[
|
||||
{
|
||||
"id": "1",
|
||||
"name": "stone island",
|
||||
"price": 1999.99,
|
||||
"description": "super idol rovny pacan, groza rayona, mother's modnik, патч на месте",
|
||||
"image": "img/stonik.jpg",
|
||||
"category": "1",
|
||||
"condition": "1"
|
||||
},
|
||||
|
||||
{
|
||||
"id": "2",
|
||||
"name": "adidas",
|
||||
"price": 19.99,
|
||||
"description": "sportik, street, baskemtball, air, old school",
|
||||
"image": "img/adidas.jpg",
|
||||
"category": "1",
|
||||
"condition": "2"
|
||||
},
|
||||
|
||||
{
|
||||
"id": "3",
|
||||
"name": "napapisaj",
|
||||
"price": 1499.99,
|
||||
"description": "super idol rovny pacan, groza rayona, mother's modnik, +rep from brothers",
|
||||
"image": "img/napapisaj.jpg",
|
||||
"category": "1",
|
||||
"condition": "2"
|
||||
},
|
||||
|
||||
{
|
||||
"id": "4",
|
||||
"name": "samba",
|
||||
"price": 449.99,
|
||||
"description": "super idol rovny pacan, groza rayona, mother's modnik, +rep from brothers",
|
||||
"image": "img/samba.jpg",
|
||||
"category": "2",
|
||||
"condition": "1"
|
||||
},
|
||||
|
||||
{
|
||||
"id": "5",
|
||||
"name": "lacoste",
|
||||
"price": 399.99,
|
||||
"description": "style, nice, mother's modnik, cotton, krokodil",
|
||||
"image": "img/lacoste.jpg",
|
||||
"category": "1",
|
||||
"condition": "1"
|
||||
}
|
||||
],
|
||||
|
||||
"category":[
|
||||
{
|
||||
"id":"1",
|
||||
"name": "men"
|
||||
},
|
||||
|
||||
{
|
||||
"id":"2",
|
||||
"name": "women"
|
||||
}
|
||||
],
|
||||
|
||||
"condition":[
|
||||
{
|
||||
"id":"1",
|
||||
"name":"new"
|
||||
},
|
||||
|
||||
{
|
||||
"id": "2",
|
||||
"name": "wu"
|
||||
}
|
||||
]
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 259 KiB |
41
js/ApiService.js
Normal file
41
js/ApiService.js
Normal file
@@ -0,0 +1,41 @@
|
||||
class ApiService {
|
||||
constructor(baseUrl) {
|
||||
this.baseUrl = baseUrl;
|
||||
}
|
||||
|
||||
async get(endpoint) {
|
||||
const response = await fetch(`${this.baseUrl}/${endpoint}`);
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async post(endpoint, data) {
|
||||
const response = await fetch(`${this.baseUrl}/${endpoint}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async put(endpoint, id, data) {
|
||||
const response = await fetch(`${this.baseUrl}/${endpoint}/${id}`, {
|
||||
method: "PUT",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
|
||||
async delete(endpoint, id) {
|
||||
const response = await fetch(`${this.baseUrl}/${endpoint}/${id}`, {
|
||||
method: "DELETE",
|
||||
});
|
||||
return response.json();
|
||||
}
|
||||
}
|
||||
|
||||
export const apiService = new ApiService('http://localhost:3000');
|
||||
49
js/basket/BasketModel.js
Normal file
49
js/basket/BasketModel.js
Normal file
@@ -0,0 +1,49 @@
|
||||
import { apiService } from "./js/ApiService.js";
|
||||
|
||||
export class BasketModel {
|
||||
constructor() {
|
||||
this.items = [];
|
||||
}
|
||||
|
||||
async loadBasketItems() {
|
||||
this.items = await apiService.get('basket?_expand=product');
|
||||
return this.items;
|
||||
}
|
||||
|
||||
async addToBasket(productId, quantity = 1) {
|
||||
const existingItem = this.items.find(item => item.productId === productId);
|
||||
|
||||
if (existingItem) {
|
||||
return this.updateBasketItem(existingItem.id, {
|
||||
quantity: existingItem.quantity + quantity
|
||||
});
|
||||
} else {
|
||||
const newItem = await apiService.post('basket', {
|
||||
productId,
|
||||
quantity
|
||||
});
|
||||
this.items.push(newItem);
|
||||
return newItem;
|
||||
}
|
||||
}
|
||||
|
||||
async updateBasketItem(itemId, data) {
|
||||
const updatedItem = await apiService.put('basket', itemId, data);
|
||||
this.items = this.items.map(item =>
|
||||
item.id === itemId ? updatedItem : item
|
||||
);
|
||||
return updatedItem;
|
||||
}
|
||||
|
||||
async removeFromBasket(itemId) {
|
||||
await apiService.delete('basket', itemId);
|
||||
this.items = this.items.filter(item => item.id !== itemId);
|
||||
}
|
||||
|
||||
async clearBasket() {
|
||||
await Promise.all(this.items.map(item =>
|
||||
apiService.delete('basket', item.id)
|
||||
));
|
||||
this.items = [];
|
||||
}
|
||||
}
|
||||
@@ -29,7 +29,6 @@
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-gender-male me-2"></i>Для мужчин</a></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-gender-female me-2"></i>Для женщин</a></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-emoji-smile me-2"></i>Для детей</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-globe me-2"></i>Заказ из-за границы</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
<ul class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-gender-male me-2"></i>Для мужчин</a></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-gender-female me-2"></i>Для женщин</a></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-emoji-smile me-2"></i>Для детей</a></li>
|
||||
<li><hr class="dropdown-divider"></li>
|
||||
<li><a class="dropdown-item" href="catalog.html"><i class="bi bi-globe me-2"></i>Заказ из-за границы</a></li>
|
||||
</ul>
|
||||
|
||||
10
package.json
10
package.json
@@ -3,15 +3,18 @@
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
"start": "npm-run-all --parallel serve vite",
|
||||
"vite": "vite",
|
||||
"build": "vite build",
|
||||
"serve": "http-server -p 4000 ./dist/",
|
||||
"server": "json-server --watch ./database/data.json --port 3000",
|
||||
"prod": "npm-run-all build serve",
|
||||
"lint": "eslint . --ext js --report-unused-disable-directives --max-warnings 0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bootstrap": "5.3.3",
|
||||
"bootstrap-icons": "1.11.3"
|
||||
"bootstrap-icons": "1.11.3",
|
||||
"moment": "^2.30.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "8.56.0",
|
||||
@@ -21,7 +24,8 @@
|
||||
"eslint-plugin-import": "2.31.0",
|
||||
"eslint-plugin-prettier": "5.2.3",
|
||||
"http-server": "14.1.1",
|
||||
"npm-run-all": "^4.1.5",
|
||||
"json-server": "^1.0.0-beta.3",
|
||||
"npm-run-all": "4.1.5",
|
||||
"vite": "6.2.0"
|
||||
}
|
||||
}
|
||||
|
||||
9
server.json
Normal file
9
server.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"/": {
|
||||
"cors": true,
|
||||
"headers": {
|
||||
"Access-Control-Allow-Origin": "*",
|
||||
"Access-Control-Allow-Methods": "GET, POST, PUT, DELETE, OPTIONS"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user