|
|
|
|
@@ -1,4 +1,4 @@
|
|
|
|
|
import type { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatalog, ICatPrTotali, ISingleProductOrdered, ISchedaSingola, IMyScheda, IElementiScheda, T_Web_StatiProdotto, T_Web_Tipologie, T_WEB_TipiFormato } from 'model'
|
|
|
|
|
import type { IBaseOrder, ICart, IOrder, IOrderCart, IProduct, IProductsState, IProductInfo, ICatProd, IUserShort, IGasordine, IAuthor, ISubCatProd, IText, IOptCatalogo, ICatalog, ICatPrTotali, ISingleProductOrdered, ISchedaSingola, IMyScheda, IElementiScheda, T_Web_StatiProdotto, T_Web_Tipologie, T_WEB_TipiFormato, IPublisher } from 'model'
|
|
|
|
|
|
|
|
|
|
import { Api } from '@api'
|
|
|
|
|
import { serv_constants } from '@src/store/Modules/serv_constants'
|
|
|
|
|
@@ -198,11 +198,21 @@ export const useProducts = defineStore('Products', {
|
|
|
|
|
// 34 - In Prevendita
|
|
|
|
|
return (idStatoProdotto === 34)
|
|
|
|
|
},
|
|
|
|
|
isNovitaById: (state: IProductsState) => (date_pub: Date): boolean => {
|
|
|
|
|
const sixMonthsAgo = new Date();
|
|
|
|
|
sixMonthsAgo.setMonth(sixMonthsAgo.getMonth() - 6);
|
|
|
|
|
return new Date(date_pub).getTime() > sixMonthsAgo.getTime();
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
isPubblicato: (state: IProductsState) => (productInfo: IProductInfo): boolean => {
|
|
|
|
|
return state.isPubblicatoById(productInfo.idStatoProdotto)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
isNovita: (state: IProductsState) => (productInfo: IProductInfo): boolean => {
|
|
|
|
|
return state.isNovitaById(productInfo.date_pub)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
isNonVendibile: (state: IProductsState) => (productInfo: IProductInfo): boolean => {
|
|
|
|
|
return !state.isPubblicatoById(productInfo.idStatoProdotto) && !state.isProssimaUscitaById(productInfo.idStatoProdotto)
|
|
|
|
|
},
|
|
|
|
|
@@ -220,6 +230,11 @@ export const useProducts = defineStore('Products', {
|
|
|
|
|
return (ctrec) ? ctrec.Descrizione : ''
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getCasaEditriceByIdPublisher: (state: IProductsState) => (idPublisher: string): string => {
|
|
|
|
|
const rectrovato: IPublisher = state.publishers.find((editore: IPublisher) => editore._id === idPublisher)
|
|
|
|
|
return (rectrovato) ? rectrovato.name : ''
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getDescrByIdTipologia: (state: IProductsState) => (idTipologia: number): string => {
|
|
|
|
|
const ctrec = state.tipologie.find((mystatus: T_Web_Tipologie) => mystatus.IdTipologia === idTipologia)
|
|
|
|
|
@@ -1548,8 +1563,8 @@ export const useProducts = defineStore('Products', {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (testo.contenuto.includes('{prezzo}') || testo.contenuto.includes('{prezzo_scontato}')) {
|
|
|
|
|
const prezzo = tools.arrotonda2Dec(myproduct.arrvariazioni![0].price) || '';
|
|
|
|
|
const prezzo_scontato = tools.arrotonda2Dec(myproduct.arrvariazioni![0].sale_price) || '';
|
|
|
|
|
const prezzo = tools.arrotonda2Dec(myproduct.arrvariazioni?.[0]?.price) || '';
|
|
|
|
|
const prezzo_scontato = tools.arrotonda2Dec(myproduct.arrvariazioni?.[0]?.sale_price) || '';
|
|
|
|
|
replacements['{prezzo}'] = prezzo;
|
|
|
|
|
replacements['{prezzo_scontato}'] = prezzo_scontato;
|
|
|
|
|
}
|
|
|
|
|
@@ -1557,9 +1572,9 @@ export const useProducts = defineStore('Products', {
|
|
|
|
|
// Additional replacements based on the content
|
|
|
|
|
const keysToCheck = [
|
|
|
|
|
'{titolo}', '{sottotitolo}', '{categoria}', '{sottocategoria}', '{descr_categoria}',
|
|
|
|
|
'{pagine}', '{isbn}', '{misure}', '{edizione', '{ristampa}', '{argomento}', '{date_pub}', '{date_updated_fromGM}', '{ranking_globale}',
|
|
|
|
|
'{pagine}', '{isbn}', '{misure}', '{edizione}', '{ristampa}', '{argomento}', '{date_pub}', '{date_updated_fromGM}', '{ranking_globale}',
|
|
|
|
|
'{venduti}', '{formato}', '{tipologia}', '{stato}', '{scale}', '{descr_trafiletto_catalogo}',
|
|
|
|
|
'{link_macro}', '{qta}', '{image_link}', '{imagefile}', '{debug}'
|
|
|
|
|
'{link_macro}', '{qta}', '{image_link}', '{imagefile}', '{casaeditrice}', '{debug}'
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
for (const key of keysToCheck) {
|
|
|
|
|
@@ -1578,19 +1593,22 @@ export const useProducts = defineStore('Products', {
|
|
|
|
|
replacements[key] = myproduct.productInfo.catprods && myproduct.productInfo.catprods.length > 0 ? this.getCatProdDescrStrByIdCatProd(myproduct.productInfo.catprods![0].name) : '';
|
|
|
|
|
break;
|
|
|
|
|
case '{pagine}':
|
|
|
|
|
replacements[key] = myproduct.arrvariazioni![0].pagine || '';
|
|
|
|
|
replacements[key] = myproduct.arrvariazioni?.[0]?.pagine || '';
|
|
|
|
|
break;
|
|
|
|
|
case '{isbn}':
|
|
|
|
|
replacements[key] = myproduct.productInfo.code || '';
|
|
|
|
|
break;
|
|
|
|
|
case '{misure}':
|
|
|
|
|
replacements[key] = myproduct.arrvariazioni![0].misure || '';
|
|
|
|
|
replacements[key] = myproduct.arrvariazioni?.[0]?.misure || '';
|
|
|
|
|
break;
|
|
|
|
|
case '{casaeditrice}':
|
|
|
|
|
replacements[key] = this.getCasaEditriceByIdPublisher(myproduct.productInfo.idPublisher)
|
|
|
|
|
break;
|
|
|
|
|
case '{edizione}':
|
|
|
|
|
replacements[key] = myproduct.arrvariazioni![0].edizione || '';
|
|
|
|
|
replacements[key] = myproduct.arrvariazioni?.[0]?.edizione || '';
|
|
|
|
|
break;
|
|
|
|
|
case '{ristampa}':
|
|
|
|
|
replacements[key] = myproduct.arrvariazioni![0].ristampa || '';
|
|
|
|
|
replacements[key] = myproduct.arrvariazioni?.[0]?.ristampa || '';
|
|
|
|
|
break;
|
|
|
|
|
case '{argomento}':
|
|
|
|
|
replacements[key] = this.getCatProdsStrByCatProds(myproduct.productInfo.catprods!) || '';
|
|
|
|
|
@@ -1608,10 +1626,10 @@ export const useProducts = defineStore('Products', {
|
|
|
|
|
replacements[key] = myproduct.productInfo.totVen! || '0';
|
|
|
|
|
break;
|
|
|
|
|
case '{formato}':
|
|
|
|
|
replacements[key] = this.getDescrByIdTipoFormato(myproduct.arrvariazioni[0].idTipoFormato || 0)
|
|
|
|
|
replacements[key] = this.getDescrByIdTipoFormato(myproduct.arrvariazioni?.[0]?.idTipoFormato || 0)
|
|
|
|
|
break;
|
|
|
|
|
case '{tipologia}':
|
|
|
|
|
replacements[key] = this.getDescrByIdTipologia(myproduct.arrvariazioni[0].idTipologia || 0);
|
|
|
|
|
replacements[key] = this.getDescrByIdTipologia(myproduct.arrvariazioni?.[0]?.idTipologia || 0);
|
|
|
|
|
break;
|
|
|
|
|
case '{stato}':
|
|
|
|
|
replacements[key] = this.getDescrStatiProdottoByIdStatoProdotto(myproduct.productInfo.idStatoProdotto || '');
|
|
|
|
|
@@ -1623,7 +1641,7 @@ export const useProducts = defineStore('Products', {
|
|
|
|
|
replacements[key] = myproduct.productInfo.link_macro || '';
|
|
|
|
|
break;
|
|
|
|
|
case '{qta}':
|
|
|
|
|
replacements[key] = myproduct.arrvariazioni![0].quantita || '';
|
|
|
|
|
replacements[key] = myproduct.arrvariazioni?.[0]?.quantita || '';
|
|
|
|
|
break;
|
|
|
|
|
case '{image_link}':
|
|
|
|
|
replacements[key] = myproduct.productInfo.image_link || '';
|
|
|
|
|
|