- caaloghi, categorie
This commit is contained in:
@@ -8582,8 +8582,41 @@ export const tools = {
|
||||
}
|
||||
|
||||
return color
|
||||
}
|
||||
},
|
||||
|
||||
getIconByVersione (versione: number ) {
|
||||
let str = ''
|
||||
if (versione === shared_consts.VERSIONE.NUOVO)
|
||||
str = 'fas fa-book'
|
||||
else if (versione === shared_consts.VERSIONE.USATO)
|
||||
// Versione Libro usato
|
||||
str = 'fas fa-book-open'
|
||||
else if (versione === shared_consts.VERSIONE.DOWNLOAD)
|
||||
str = 'fas fa-file-download'
|
||||
else if (versione === shared_consts.VERSIONE.DVD)
|
||||
str = 'fas fa-film'
|
||||
else if (versione === shared_consts.VERSIONE.PDF)
|
||||
str = 'fas fa-file-pdf'
|
||||
else if (versione === shared_consts.VERSIONE.EPUB)
|
||||
// Libro elettronico EPUB
|
||||
str = 'fas fa-book-open-reader'
|
||||
else if (versione === shared_consts.VERSIONE.DVD)
|
||||
str = 'fas fa-video'
|
||||
else if (versione === shared_consts.VERSIONE.STREAMING)
|
||||
str = 'fas fa-stream'
|
||||
|
||||
return str
|
||||
},
|
||||
|
||||
// get the integer part, no round, of a decimal number
|
||||
getIntPart(number: number) {
|
||||
return Math.trunc(number)
|
||||
},
|
||||
|
||||
// get the last 2 digit fraction part, of a decimal number
|
||||
getDecPart2Digit(number: number) {
|
||||
return Math.round(number * 100) % 100
|
||||
}
|
||||
|
||||
// FINE !
|
||||
|
||||
|
||||
@@ -172,12 +172,6 @@ export const useProducts = defineStore('Products', {
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
getProductById: (state: IProductsState) => (id: string): IProduct => {
|
||||
const prod = state.products.find((prod: IProduct) => prod._id === id)
|
||||
return prod ? prod : getRecordProductEmpty()
|
||||
},
|
||||
|
||||
getProductByCode: (state: IProductsState) => (code: string): IProduct => {
|
||||
if (!code) {
|
||||
return getRecordProductEmpty()
|
||||
@@ -410,6 +404,19 @@ export const useProducts = defineStore('Products', {
|
||||
this.products = [...arrprod]
|
||||
},*/
|
||||
|
||||
async getProductById (id: string): Promise<IProduct> {
|
||||
let prod = null
|
||||
if (!this.products) {
|
||||
// Se non lo carico all'avvio, allora fai la chiamata al server
|
||||
prod = await this.loadProductById(id)
|
||||
} else {
|
||||
prod = this.products.find((prod: IProduct) => prod._id === id)
|
||||
}
|
||||
|
||||
return prod ? prod : getRecordProductEmpty()
|
||||
},
|
||||
|
||||
|
||||
async loadProducts() {
|
||||
|
||||
const userStore = useUserStore()
|
||||
@@ -882,7 +889,7 @@ export const useProducts = defineStore('Products', {
|
||||
return ris
|
||||
},
|
||||
async addtoCartBase({ $q, t, id, order, addqty }: { $q: any, t: any, id: string, order: IOrder, addqty: boolean }) {
|
||||
let product = this.getProductById(id)
|
||||
let product = await this.getProductById(id)
|
||||
|
||||
return await this.addToCart({ product, order, addqty })
|
||||
.then((ris) => {
|
||||
|
||||
Reference in New Issue
Block a user