DashboardProvidersClose.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div class="q-mx-md q-mb-lg">
  3. <div class="row items-center justify-between no-wrap q-mb-sm">
  4. <div class="dashboard-section-title gradient-diarista">{{ $t('dashboard_client.providers_close.title') }}</div>
  5. <div class="text-text-light">
  6. <q-btn flat color="text-light" icon="mdi-chevron-left" @click="setPeriodTypePrevious"/>
  7. <span>{{ showCorrectLabels() }}</span>
  8. <q-btn flat color="text-light" icon="mdi-chevron-right" @click="setPeriodTypeNext"/>
  9. </div>
  10. </div>
  11. <div class="column">
  12. <q-card
  13. v-for="p in data"
  14. :key="p.provider_id"
  15. class="card-border bg-page text-text q-mb-sm"
  16. :flat="false"
  17. >
  18. <q-card-section class="row no-wrap q-pa-sm">
  19. <div class="row no-wrap full-width">
  20. <div class="col-2">
  21. <q-avatar :style="avatarColors[p.provider_id % avatarColors.length]" class="text-weight-bold">
  22. {{ p.provider_name?.slice(0,1).toUpperCase() ?? '—' }}
  23. </q-avatar>
  24. </div>
  25. <div class="col-10 row">
  26. <div class="column col-9 justify-between">
  27. <span class="text-provider-close-name">{{ p.provider_name ?? 'Prestador' }}</span>
  28. <span class="text-provider-close-region">{{ p.district }}</span>
  29. <div class="row items-center justify-between q-pr-lg">
  30. <div class="row items-center">
  31. <q-icon name="mdi-star" color="warning" size="16px" />
  32. <span class="text-provider-close-rating">
  33. {{ p.average_rating != null ? (Number(p.average_rating).toFixed(1) + ' (' + (p.total_reviews ?? 0) + ')') : ('(' + (p.total_reviews ?? 0) + ')') }}
  34. </span>
  35. </div>
  36. <div class="row items-center">
  37. <q-icon name="mdi-broom" color="secondary" size="16px" />
  38. <span class="text-provider-close-jobs">{{ p.total_services ?? 0 }}</span>
  39. </div>
  40. <div class="row items-center">
  41. <q-icon name="mdi-map-marker-outline" color="text" size="16px" />
  42. <span class="text-provider-close-jobs">{{ 0 + ' km' }}</span>
  43. </div>
  44. </div>
  45. </div>
  46. <div class="column col-3 justify-between text-center items-center">
  47. <span class="text-provider-close-price">
  48. {{ showCorrectValues(p) }}
  49. </span>
  50. <div class="full-width">
  51. <q-btn
  52. unelevated rounded no-caps
  53. color="primary"
  54. size="sm"
  55. padding="3px 12px"
  56. :label="$t('dashboard_client.providers_close.schedule')"
  57. />
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. </q-card-section>
  63. </q-card>
  64. </div>
  65. </div>
  66. </template>
  67. <script setup>
  68. import { formatCurrency } from 'src/helpers/utils';
  69. import { ref } from 'vue';
  70. import { useI18n } from 'vue-i18n';
  71. defineProps({ data: { type: Array, default: () => [] } });
  72. const { t } = useI18n();
  73. const currentPeriodType = ref(8);
  74. const periodTypeMap = ref({
  75. 2: 'daily_price_2h',
  76. 4: 'daily_price_4h',
  77. 6: 'daily_price_6h',
  78. 8: 'daily_price_8h',
  79. });
  80. const showCorrectValues = (p) => {
  81. switch (currentPeriodType.value) {
  82. case 8:
  83. return p.daily_price_8h ? formatCurrency(p.daily_price_8h) : t('dashboard_client.providers_close.no_price');
  84. case 6:
  85. return p.daily_price_6h ? formatCurrency(p.daily_price_6h) : t('dashboard_client.providers_close.no_price');
  86. case 4:
  87. return p.daily_price_4h ? formatCurrency(p.daily_price_4h) : t('dashboard_client.providers_close.no_price');
  88. case 2:
  89. return p.daily_price_2h ? formatCurrency(p.daily_price_2h) : t('dashboard_client.providers_close.no_price');
  90. default:
  91. return t('dashboard_client.providers_close.no_price');
  92. }
  93. };
  94. const showCorrectLabels = () => {
  95. switch (currentPeriodType.value) {
  96. case 8:
  97. return t('dashboard_client.providers_close.until_8h');
  98. case 6:
  99. return t('dashboard_client.providers_close.until_6h');
  100. case 4:
  101. return t('dashboard_client.providers_close.until_4h');
  102. case 2:
  103. return t('dashboard_client.providers_close.until_2h');
  104. default:
  105. return '';
  106. }
  107. };
  108. const setPeriodTypePrevious = () => {
  109. const previousPeriod = currentPeriodType.value - 2;
  110. if (periodTypeMap.value[previousPeriod]) {
  111. currentPeriodType.value = previousPeriod;
  112. }
  113. };
  114. const setPeriodTypeNext = () => {
  115. const nextPeriod = currentPeriodType.value + 2;
  116. if (periodTypeMap.value[nextPeriod]) {
  117. currentPeriodType.value = nextPeriod;
  118. }
  119. };
  120. const avatarColors = [
  121. { background: '#ffd5df', color: '#932e57' },
  122. { background: '#d7e8ff', color: '#2158a8' },
  123. { background: '#dfd', color: '#2a7a3b' },
  124. { background: '#ffe5cc', color: '#8a4500' },
  125. ];
  126. </script>
  127. <style scoped lang="scss">
  128. </style>