Ver código fonte

feat: :sparkles: feat (agendamentos) botao agendar dos favoritos com redirecionamento

foi adicionado redirecionamento ao agendamento diretamente para o prestador no bloco de favoritos da dashboard

fase:dev | origin:escopo
Gustavo Zanatta 1 semana atrás
pai
commit
791d61b3da

+ 10 - 35
src/components/dashboard/DashboardFavoriteProviders.vue

@@ -23,7 +23,6 @@
                 <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> -->
             </div>
             <div class="col-4 column q-mt-auto">
               <q-btn
@@ -31,6 +30,7 @@
                 padding="1px 5px"
                 size="sm"
                 :label="$t('dashboard_client.favorites.view_schedule')"
+                @click="goToScheduling(item)"
               />
             </div>
           </div>
@@ -41,18 +41,12 @@
 </template>
 
 <script setup>
-// import { formatCurrency } from 'src/helpers/utils';
-// import { useI18n } from 'vue-i18n';
-
-// import { formatCurrency } from 'src/helpers/utils';
-// import { useI18n } from 'vue-i18n';
+import { useQuasar } from 'quasar';
+import SchedulingDialog from 'src/pages/search/components/SchedulingDialog.vue';
 
 defineProps({ data: { type: Array, default: () => [] } });
 
-// const { t } = useI18n();
-
-// const { t } = useI18n();
-
+const $q = useQuasar();
 const avatarColors = [
   { background: '#ffd5df', color: '#932e57' },
   { background: '#d7e8ff', color: '#2158a8' },
@@ -60,31 +54,12 @@ const avatarColors = [
   { 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);
-// };
-
-/*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);
-};*/
+const goToScheduling = (provider) => {
+  $q.dialog({
+    component: SchedulingDialog,
+    componentProps: { provider },
+  });
+};
 </script>
 
 <style scoped lang="scss">

+ 2 - 2
src/pages/search/components/OrderSummaryDialog.vue

@@ -113,7 +113,7 @@ const props = defineProps({
 
 defineEmits([...useDialogPluginComponent.emits]);
 
-const { dialogRef } = useDialogPluginComponent();
+const { dialogRef, onDialogOK } = useDialogPluginComponent();
 const $q = useQuasar();
 const { t, locale } = useI18n();
 const store = userStore();
@@ -323,7 +323,7 @@ const submitOrder = async () => {
   try {
     await createSchedule(payload);
     $q.notify({ type: 'positive', message: t('scheduling_page.order_summary.submit_success') });
-    dialogRef.value.hide();
+    onDialogOK();
   } catch (err) {
     const msg = err?.response?.data?.message
       ?? err?.message

+ 3 - 5
src/pages/search/components/SchedulingDialog.vue

@@ -302,21 +302,19 @@ const onDateSelected = (val) => {
   }).onOk((booking) => {
 
     bookings.value.push(booking);
-
     $q.dialog({
       component: OrderSummaryDialog,
       componentProps: {
         provider: props.provider,
         initialBooking: booking
       }
-    });
-
+    }).onOk(() => {
+      dialogRef.value.hide();
+    })
   });
-
 });
 };
 
-
 const loadAvailability = async () => {
   loadingAvailability.value = true;