wip: cart

This commit is contained in:
Nikita Kiselev
2025-07-20 22:22:14 +03:00
parent 1ffb1cef12
commit ee67bd55df
12 changed files with 541 additions and 19 deletions

View File

@@ -0,0 +1,27 @@
import {defineStore} from "pinia";
export const useCartStore = defineStore('cart', {
state: () => ({
items: [],
}),
actions: {
getProduct(productId) {
return this.items.find(item => parseInt(item.productId) === parseInt(productId)) ?? null;
},
hasProduct(productId) {
return this.getProduct(productId) !== null;
},
addProduct(productId, productName, price, quantity = 1, options = []) {
this.items.push({
productId: productId,
productName: productName,
price: price,
quantity: quantity,
options: options,
});
},
},
});