Selaa lähdekoodia

ajuste precos da loja + correcao nao aparecer item inativo

Gustavo Zanatta 1 kuukausi sitten
vanhempi
commit
dcdff7bb7e

+ 2 - 0
src/i18n/locales/en.json

@@ -739,6 +739,8 @@
     "filter_all": "All",
     "filter_recent": "Recent",
     "filter_others": "Others",
+    "price_non_associate": "Price for non-members",
+    "price_associate": "Price for members",
     "btn_interested": "I'm interested",
     "btn_want": "I want",
     "whatsapp_dialog_title": "Talk on WhatsApp",

+ 2 - 0
src/i18n/locales/es.json

@@ -739,6 +739,8 @@
     "filter_all": "Todos",
     "filter_recent": "Recientes",
     "filter_others": "Otros",
+    "price_non_associate": "Precio para no asociado",
+    "price_associate": "Precio para asociado",
     "btn_interested": "Ya me interesa",
     "btn_want": "Lo quiero",
     "whatsapp_dialog_title": "Hablar por WhatsApp",

+ 2 - 0
src/i18n/locales/pt.json

@@ -740,6 +740,8 @@
     "filter_all": "Todos",
     "filter_recent": "Recentes",
     "filter_others": "Outros",
+    "price_non_associate": "Preço para não associado",
+    "price_associate": "Preço para associado",
     "btn_interested": "Já tenho interesse",
     "btn_want": "Eu quero",
     "whatsapp_dialog_title": "Falar no WhatsApp",

+ 22 - 7
src/pages/associado/loja/AssociadoLojaPage.vue

@@ -103,11 +103,19 @@
                   </div>
 
                   <div class="column items-start q-mt-sm">
-                    <span v-if="item.price" class="text-caption text-grey-5 text-strike">
-                      R$ {{ formatPrice(item.price) }}
+                    <span
+                      v-if="priceInfo(item).regular !== null"
+                      class="text-caption text-grey-7"
+                    >
+                      {{ $t("loja.price_non_associate") }}:
+                      R$ {{ formatPrice(priceInfo(item).regular) }}
                     </span>
-                    <span class="text-subtitle1 text-weight-bold text-violet-dark">
-                      R$ {{ formatPrice(displayPrice(item)) }}
+                    <span
+                      v-if="priceInfo(item).associate !== null"
+                      class="text-body2 text-weight-bold text-violet-dark"
+                    >
+                      {{ $t("loja.price_associate") }}:
+                      R$ {{ formatPrice(priceInfo(item).associate) }}
                     </span>
                   </div>
                 </div>
@@ -200,10 +208,17 @@ const selectVariation = (item, variation) => {
 const activeVariation = (item) =>
   selectedVariations.value[item.id] ?? item.variations?.[0] ?? null;
 
-const displayPrice = (item) => {
+const hasPrice = (price) => price !== null && price !== undefined && price !== "";
+
+const priceInfo = (item) => {
   const v = activeVariation(item);
-  if (v?.variation_value != null) return v.variation_value;
-  return item.associate_price ?? item.price;
+  const associate = hasPrice(v?.variation_value) ? v.variation_value : item.associate_price;
+
+  if (hasPrice(item.price) && hasPrice(associate)) {
+    return { regular: item.price, associate };
+  }
+  const single = hasPrice(associate) ? associate : item.price;
+  return { regular: null, associate: hasPrice(single) ? single : null };
 };
 
 const variationTypeLabel = (item) => {

+ 31 - 20
src/pages/loja/LojaPage.vue

@@ -129,23 +129,27 @@
                     </div>
                   </template>
 
-                  <div class="row items-end justify-between q-mt-sm">
-                    <div class="column" style="gap: 1px">
-                      <span class="text-caption text-grey-6">
-                        {{ $t('loja.stock') }}: {{ displayStock(item) }}
-                      </span>
-                      <span class="text-caption text-grey-6">
-                        {{ $t('loja.interests') }}: {{ item.interests_count ?? 0 }}
-                      </span>
-                    </div>
-                    <div class="column items-end" style="gap: 1px">
-                      <span v-if="item.price" class="text-caption text-grey-5 text-strike">
-                        R$ {{ formatPrice(item.price) }}
-                      </span>
-                      <span v-if="displayPrice(item) != null" class="text-subtitle2 text-weight-bold text-violet-dark">
-                        R$ {{ formatPrice(displayPrice(item)) }}
-                      </span>
-                    </div>
+                  <div class="column items-start q-mt-sm" style="gap: 1px">
+                    <span class="text-caption text-grey-6">
+                      {{ $t('loja.stock') }}: {{ displayStock(item) }}
+                    </span>
+                    <span class="text-caption text-grey-6">
+                      {{ $t('loja.interests') }}: {{ item.interests_count ?? 0 }}
+                    </span>
+                    <span
+                      v-if="priceInfo(item).regular !== null"
+                      class="text-caption text-grey-7 q-mt-xs"
+                    >
+                      {{ $t('loja.price_non_associate') }}:
+                      R$ {{ formatPrice(priceInfo(item).regular) }}
+                    </span>
+                    <span
+                      v-if="priceInfo(item).associate !== null"
+                      class="text-body2 text-weight-bold text-violet-dark"
+                    >
+                      {{ $t('loja.price_associate') }}:
+                      R$ {{ formatPrice(priceInfo(item).associate) }}
+                    </span>
                   </div>
                 </div>
 
@@ -221,10 +225,17 @@ const selectVariation = (item, variation) => {
 
 const activeVariation = (item) => selectedVariations.value[item.id] ?? null;
 
-const displayPrice = (item) => {
+const hasPrice = (price) => price !== null && price !== undefined && price !== "";
+
+const priceInfo = (item) => {
   const v = activeVariation(item);
-  if (v && v.variation_value != null) return v.variation_value;
-  return item.associate_price;
+  const associate = hasPrice(v?.variation_value) ? v.variation_value : item.associate_price;
+
+  if (hasPrice(item.price) && hasPrice(associate)) {
+    return { regular: item.price, associate };
+  }
+  const single = hasPrice(associate) ? associate : item.price;
+  return { regular: null, associate: hasPrice(single) ? single : null };
 };
 
 const displayStock = (item) => {