Forráskód Böngészése

fix: :bug: correcao das validacoes e informacoes da dashboard cliente

foram corrigidas as validacoes e informacoes exibidas na dashboard do cliente, passando parametros corretos

fase: dev
Gustavo Zanatta 3 hete
szülő
commit
c0238eaae7

+ 32 - 18
src/components/dashboard/DashboardFavoriteProviders.vue

@@ -5,34 +5,30 @@
     <div class="scroll-track">
       <q-card
         v-for="item in data"
-        :key="item.id"
+        :key="item.provider_id"
         class="fav-card shadow-card bg-surface card-border"
         :flat="false"
       >
         <q-card-section class="q-pa-sm column text-text">
           <div class="row items-start no-wrap q-gutter-x-sm">
             <div class="col-3">
-              <q-avatar :style="avatarColors[item.id % avatarColors.length]" size="46px" class="text-weight-bold">
+              <q-avatar :style="avatarColors[item.provider_id % avatarColors.length]" size="46px" class="text-weight-bold">
                 {{ item.provider_name?.slice(0,1).toUpperCase() ?? '—' }}
               </q-avatar>
             </div>
-            <div class="col-9 row">
-              <div class="col-6 column full-height justify-between">
-                <div class="column q-gutter-y-xs">
-                  <span class="text-fav-name">{{ item.provider_name ?? 'Prestador' }}</span>
-                  <div class="row items-center q-gutter-x-xs">
-                    <q-icon name="mdi-star" color="warning" size="sm" />
-                    <span class="text-fav-name">{{ item.average_rating ?? '-' }}</span>
-                  </div>
-                </div>
-              </div>
-              <div class="column col-5 items-end justify-end">
-                <q-btn
-                  rounded color="primary"
-                  padding="1px 5px" size="sm"
-                  :label="$t('dashboard_client.favorites.view_schedule')"
-                />
+            <div class="col-9 column q-gutter-y-xs">
+              <span class="text-fav-name">{{ item.provider_name ?? 'Prestador' }}</span>
+              <div v-if="item.average_rating != null" class="row items-center q-gutter-x-xs">
+                <q-icon name="mdi-star" color="warning" size="sm" />
+                <span class="text-fav-name">{{ Number(item.average_rating).toFixed(1) }}</span>
               </div>
+              <span class="text-fav-price">{{ bestPrice(item) }}</span>
+              <q-btn
+                rounded color="primary"
+                padding="1px 5px" size="sm"
+                class="q-mt-xs"
+                :label="$t('dashboard_client.favorites.view_schedule')"
+              />
             </div>
           </div>
         </q-card-section>
@@ -42,14 +38,32 @@
 </template>
 
 <script setup>
+import { formatCurrency } from 'src/helpers/utils';
+import { useI18n } from 'vue-i18n';
+
 defineProps({ data: { type: Array, default: () => [] } });
 
+const { t } = useI18n();
+
 const avatarColors = [
   { background: '#ffd5df', color: '#932e57' },
   { background: '#d7e8ff', color: '#2158a8' },
   { background: '#dfd',    color: '#2a7a3b' },
   { background: '#ffe5cc', color: '#8a4500' },
 ];
+
+const bestPrice = (item) => {
+  const prices = [
+    item.daily_price_2h,
+    item.daily_price_4h,
+    item.daily_price_6h,
+    item.daily_price_8h,
+  ].filter(p => p != null && Number(p) > 0);
+
+  if (!prices.length) return t('dashboard_client.favorites.no_price');
+  const min = Math.min(...prices.map(Number));
+  return t('dashboard_client.favorites.from') + ' ' + formatCurrency(min);
+};
 </script>
 
 <style scoped lang="scss">

+ 1 - 1
src/components/dashboard/DashboardLastDoneSchedules.vue

@@ -10,7 +10,7 @@
         :flat="false"
       >
         <q-card-section class="column items-center q-pa-md q-gutter-y-xs text-text">
-          <q-avatar :style="avatarColors[item.id % avatarColors.length]" size="56px" class="text-weight-bold">
+          <q-avatar :style="avatarColors[item.provider_id % avatarColors.length]" size="56px" class="text-weight-bold">
             {{ item.provider_name?.slice(0,1).toUpperCase() ?? '—' }}
           </q-avatar>
           <span class="text-done-name">{{ item.provider_name ?? 'Prestador' }}</span>

+ 2 - 5
src/components/dashboard/DashboardNextSchedules.vue

@@ -42,8 +42,8 @@
               <div class="col-5">
                 <div class="full-height column justify-end">
                   <div class="row text-pill-place">
-                    <q-icon :name="addressIcon(item.address_type)" size="15px" color="primary" />
-                    <span class="row items-end">{{ addressLabel(item.address?.address_type) }}</span>
+                    <q-icon :name="addressIcon(item.address?.address_type ?? item.custom_address_type)" size="15px" color="primary" />
+                    <span class="row items-end">{{ addressLabel(item.address?.address_type ?? item.custom_address_type) }}</span>
                   </div>
                 </div>
               </div>
@@ -55,7 +55,6 @@
                   {{ item.total_amount && item.total_amount !== '0.00' ? formatCurrency(item.total_amount) : $t('dashboard_client.next_schedules.to_combine') }}
                 </span>
                 <span class="text-price-label col-6">
-                  <!-- {{ item.schedule_type === 'custom' ? $t('dashboard_client.next_schedules.custom') : $t('dashboard_client.next_schedules.default') }} -->
                   {{ formatLabelByPeriodType(item.period_type) }}
                 </span>
               </div>
@@ -107,11 +106,9 @@ const formatDayMonth = (iso) => {
 const addressIcon = (type) => type === 'home' ? 'mdi-home-outline' : 'mdi-office-building-outline';
 
 const addressLabel = (type) => {
-  console.log(type)
   if (type === 'home') return t('address.types.commercial.home');
   if (type === 'apartment') return t('dashboard_client.next_schedules.place_apartment');
   if (type === 'commercial') return t('address.types.commercial');
-
   return t('dashboard_client.next_schedules.place_unknown');
 };
 

+ 8 - 8
src/components/dashboard/DashboardProvidersClose.vue

@@ -12,14 +12,14 @@
     <div class="column">
       <q-card
         v-for="p in data"
-        :key="p.id"
+        :key="p.provider_id"
         class="card-border bg-page text-text q-mb-sm"
         :flat="false"
       >
         <q-card-section class="row no-wrap q-pa-sm">
           <div class="row no-wrap full-width">
             <div class="col-2">
-              <q-avatar :style="avatarColors[p.id % avatarColors.length]" class="text-weight-bold">
+              <q-avatar :style="avatarColors[p.provider_id % avatarColors.length]" class="text-weight-bold">
                 {{ p.provider_name?.slice(0,1).toUpperCase() ?? '—' }}
               </q-avatar>
             </div>
@@ -32,7 +32,7 @@
                   <div class="row items-center">
                     <q-icon name="mdi-star" color="warning" size="16px" />
                     <span class="text-provider-close-rating">
-                      {{ (p.average_rating ?? '-') + ' (' + (p.total_reviews ?? 0) + ')' }}
+                      {{ p.average_rating != null ? (Number(p.average_rating).toFixed(1) + ' (' + (p.total_reviews ?? 0) + ')') : ('(' + (p.total_reviews ?? 0) + ')') }}
                     </span>
                   </div>
                   <div class="row items-center">
@@ -89,15 +89,15 @@ const periodTypeMap = ref({
 const showCorrectValues = (p) => {
   switch (currentPeriodType.value) {
     case 8:
-      return p.daily_price_8h ? formatCurrency(p.daily_price_8h) : '-';
+      return p.daily_price_8h ? formatCurrency(p.daily_price_8h) : t('dashboard_client.providers_close.no_price');
     case 6:
-      return p.daily_price_6h ? formatCurrency(p.daily_price_6h) : '-';
+      return p.daily_price_6h ? formatCurrency(p.daily_price_6h) : t('dashboard_client.providers_close.no_price');
     case 4:
-      return p.daily_price_4h ? formatCurrency(p.daily_price_4h) : '-';
+      return p.daily_price_4h ? formatCurrency(p.daily_price_4h) : t('dashboard_client.providers_close.no_price');
     case 2:
-      return p.daily_price_2h ? formatCurrency(p.daily_price_2h) : '-';
+      return p.daily_price_2h ? formatCurrency(p.daily_price_2h) : t('dashboard_client.providers_close.no_price');
     default:
-      return '-';
+      return t('dashboard_client.providers_close.no_price');
   }
 };
 

+ 0 - 1
src/composables/useInputRules.js

@@ -63,7 +63,6 @@ export const useInputRules = () => {
 };
 
 function isValidCPF(cpf) {
-  console.log("isValidCPF", cpf);
   if (!cpf) return false;
   cpf = cpf.replace(/[^\d]+/g, "");
   if (cpf.length !== 11) return false;

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

@@ -345,7 +345,9 @@
     },
     "favorites": {
       "title": "Favorites",
-      "view_schedule": "view schedule"
+      "view_schedule": "view schedule",
+      "from": "from",
+      "no_price": "no price"
     },
     "providers_close": {
       "title": "Near you",
@@ -354,7 +356,8 @@
       "until_6h": "Up to 6h",
       "until_4h": "Up to 4h",
       "until_2h": "Up to 2h",
-      "place_home": "Home"
+      "place_home": "Home",
+      "no_price": "to arrange"
     }
   },
   "profile": {

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

@@ -345,7 +345,9 @@
     },
     "favorites": {
       "title": "Favoritos",
-      "view_schedule": "ver agenda"
+      "view_schedule": "ver agenda",
+      "from": "desde",
+      "no_price": "sin precio"
     },
     "providers_close": {
       "title": "Cerca de ti",
@@ -354,7 +356,8 @@
       "until_6h": "Hasta 6h",
       "until_4h": "Hasta 4h",
       "until_2h": "Hasta 2h",
-      "place_home": "Casa"
+      "place_home": "Casa",
+      "no_price": "a convenir"
     }
   },
   "profile": {

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

@@ -345,7 +345,9 @@
     },
     "favorites": {
       "title": "Favoritos",
-      "view_schedule": "ver agenda"
+      "view_schedule": "ver agenda",
+      "from": "a partir de",
+      "no_price": "sem preço"
     },
     "providers_close": {
       "title": "Perto de você",
@@ -354,7 +356,8 @@
       "until_6h": "Até 6h",
       "until_4h": "Até 4h",
       "until_2h": "Até 2h",
-      "place_home": "Casa"
+      "place_home": "Casa",
+      "no_price": "a combinar"
     }
   },
   "profile": {