Jelajahi Sumber

Merge branch 'fix/diaria-kay-correções' of Softpar/sfp_front_vue_diarista_cliente into development

zntt 1 hari lalu
induk
melakukan
5601ae7e7d

+ 70 - 0
src/components/dashboard/DashboardPendingSchedules.vue

@@ -103,6 +103,24 @@
               />
             </div>
 
+            <div class="schedule-info">
+  <div class="schedule-info-item">
+    <q-icon
+      name="mdi-calendar-outline"
+      size="14px"
+    />
+    <span>{{ displayDate(item) }}</span>
+  </div>
+
+  <div class="schedule-info-item">
+    <q-icon
+      name="mdi-clock-outline"
+      size="14px"
+    />
+    <span>{{ displayScheduleTime(item) }}</span>
+  </div>
+</div>
+
             <div class="card-footer row items-center no-wrap">
               <q-btn
                 v-if="type !== 'servicePackage'"
@@ -233,6 +251,34 @@ const displayTime = (item) => {
     : timeAgo;
 };
 
+const displayDate = (item) => {
+  const schedule = isServicePackage.value
+    ? item.schedules?.[0]
+    : item;
+
+  if (!schedule?.date) return "—";
+
+  const date = new Date(schedule.date);
+
+  return date.toLocaleDateString("pt-BR", {
+    day: "2-digit",
+    month: "2-digit",
+    year: "numeric",
+  });
+};
+
+const displayScheduleTime = (item) => {
+  const schedule = isServicePackage.value
+    ? item.schedules?.[0]
+    : item;
+
+  if (!schedule?.start_time || !schedule?.end_time) {
+    return "—";
+  }
+
+  return `${schedule.start_time.slice(0, 5)} às ${schedule.end_time.slice(0, 5)}`;
+};
+
 const seeDetails = (item) => {
   if (isServicePackage.value || item.status === "accepted") {
     emit("view-details", item);
@@ -322,6 +368,30 @@ const seeDetails = (item) => {
   overflow: hidden;
 }
 
+.schedule-info {
+  display: flex;
+  flex-direction: column;
+  align-items: flex-start;
+  gap: 4px;
+  width: 100%;
+  margin: 5px 0 4px;
+  padding: 0 2px;
+  color: #475569;
+  font-size: 10px;
+  font-weight: 500;
+}
+
+.schedule-info-item {
+  display: flex;
+  align-items: center;
+  gap: 5px;
+  white-space: nowrap;
+
+  .q-icon {
+    color: #64748b;
+  }
+}
+
 .progress-fill {
   position: relative;
   height: 100%;

+ 57 - 14
src/components/dashboard/DashboardTodaySchedules.vue

@@ -3,7 +3,7 @@
     <div class="scroll-wrapper">
       <div class="scroll-track">
         <q-card
-          v-for="item in data"
+          v-for="item in visibleItems"
           :key="item.id"
           :flat="false"
           class="today-card card-border shadow-card bg-surface"
@@ -218,36 +218,69 @@
 import { avatarColors } from "src/helpers/avatarColors";
 import { getFirstName } from "src/helpers/utils";
 import { useQuasar } from "quasar";
+import { ref, onMounted, onBeforeUnmount, computed } from "vue";
 
 import ProfileHelpDialog from "src/components/profile/ProfileHelpDialog.vue";
 
 
-defineProps({ data: { type: Array, default: () => [] } });
+const props = defineProps({
+  data: {
+    type: Array,
+    default: () => [],
+  },
+});
+
+
 
 const emit = defineEmits(["rate"]);
 
 const $q = useQuasar();
 
+const now = ref(Date.now());
+
+let timer = null;
+
 const cardState = (item) => {
-  switch (item.status) {
-    case "finished":
-      return "finished";
+  if (item.status === "cancelled") {
+    return "cancelled";
+  }
 
-    case "started":
-      return "in_progress";
+  if (item.client_reviewed) {
+    return "finished";
+  }
 
-    case "accepted":
-    case "paid":
-      return "awaiting_code";
+  if (
+    item.status === "accepted" ||
+    item.status === "paid"
+  ) {
+    return "awaiting_code";
+  }
 
-    case "cancelled":
-      return "cancelled";
+  if (
+    item.status === "started" ||
+    item.status === "finished"
+  ) {
+    const [hours, minutes] = (item.end_time || "23:59")
+      .slice(0, 5)
+      .split(":")
+      .map(Number);
 
-    default:
-      return "awaiting_code";
+    const endTime = new Date();
+
+    endTime.setHours(hours, minutes, 0, 0);
+
+    return now.value >= endTime.getTime()
+      ? "finished"
+      : "in_progress";
   }
+
+  return "awaiting_code";
 };
 
+const visibleItems = computed(() => {
+  return props.data.filter((item) => !item.client_reviewed);
+});
+
 const progressByState = (item) => {
   const state = cardState(item);
 
@@ -262,6 +295,16 @@ const progressByState = (item) => {
 const openHelp = () => {
   $q.dialog({ component: ProfileHelpDialog });
 };
+
+onMounted(() => {
+  timer = setInterval(() => {
+    now.value = Date.now();
+  }, 1000);
+});
+
+onBeforeUnmount(() => {
+  clearInterval(timer);
+});
 </script>
 
 <style scoped lang="scss">

+ 17 - 5
src/components/dashboard/SchedulePaymentDialog.vue

@@ -80,11 +80,13 @@
           </div>
         </div>
 
-        <div class="row items-center q-mb-lg">
-          <q-checkbox v-model="agreedToTerms" color="primary" keep-color />
-          <span class="terms-text">
-            {{ $t('payment.agree_prefix') }}
-            <span class="text-primary cursor-pointer text-underline">{{ $t('payment.terms_link') }}</span>
+        <div class="terms-text q-mb-lg">
+          {{ $t('payment.agree_prefix') }}
+          <span
+            class="text-primary cursor-pointer text-underline"
+            @click="openTerms"
+          >
+            {{ $t('payment.terms_link') }}
           </span>
         </div>
 
@@ -118,6 +120,7 @@ import { usePaymentPlatformFees } from 'src/composables/usePaymentPlatformFees'
 import ProfilePaymentAddDialog from 'src/components/profile/ProfilePaymentAddDialog.vue'
 import SchedulePaymentPixDialog from './SchedulePaymentPixDialog.vue'
 import SchedulePaymentProcessingDialog from './SchedulePaymentProcessingDialog.vue'
+import { Browser } from "@capacitor/browser";
 
 const props = defineProps({
   servicePackage: {
@@ -165,6 +168,15 @@ const addressFullText = computed(() => {
 
 const canConfirm = computed(() => selectedMethod.value !== null && agreedToTerms.value)
 
+
+//direcionamento para ttermos e serviços 
+const PRIVACY_POLICY_URL =
+  "https://politicas.softpar.inf.br/politicas/politicaDiaristaCliente.html";
+
+const openTerms = async () => {
+  await Browser.open({ url: PRIVACY_POLICY_URL });
+};
+
 const brandDisplay = (brand) => {
   if (!brand) return ''
   const map = { visa: 'VISA', mastercard: 'Mastercard', elo: 'Elo', hipercard: 'Hipercard', diners: 'Diners', discover: 'Discover' }

+ 1 - 1
src/i18n/locales/en.json

@@ -438,7 +438,7 @@
     },
     "today_schedules": {
       "start_with": "Service starting with",
-      "started_by": "Service started by",
+      "started_by": "Service in progress",
       "finished_by": "Service completed by",
       "code_label": "Code",
       "in_progress": "in progress",

+ 1 - 1
src/i18n/locales/es.json

@@ -438,7 +438,7 @@
     },
     "today_schedules": {
       "start_with": "Servicio iniciado con",
-      "started_by": "Servicio iniciado por",
+      "started_by": "Servicio en curso",
       "finished_by": "Servicio concluido por",
       "code_label": "Código",
       "in_progress": "en progreso",

+ 1 - 1
src/i18n/locales/pt.json

@@ -438,7 +438,7 @@
     },
     "today_schedules": {
       "start_with": "Início do serviço com",
-      "started_by": "Serviço iniciado por",
+      "started_by": "Seriço serviço em andamento",
       "finished_by": "Serviço concluído por",
       "code_label": "Código",
       "in_progress": "em andamento",

+ 26 - 6
src/pages/dashboard/components/DashboardClientProposals.vue

@@ -157,6 +157,8 @@
 <script setup>
 import { acceptProposal, refuseProposal } from "src/api/customSchedules";
 import { avatarColors } from "src/helpers/avatarColors";
+import { useQuasar } from "quasar";
+import SchedulePaymentDialog from "src/components/dashboard/SchedulePaymentDialog.vue";
 
 import {
   chooseprice,
@@ -177,6 +179,7 @@ defineProps({
 });
 
 const { t } = useI18n();
+const $q = useQuasar();
 
 // const formatTime = (time) => {
 //   if (!time) return '';
@@ -220,16 +223,33 @@ const formatWeekday = (iso) => {
 };
 
 const handleAcceptProposal = async (proposalId) => {
-  // isLoading.value = true
   try {
-    await acceptProposal(proposalId);
+    const response = await acceptProposal(proposalId);
+
+    const schedule = response.payload;
+
+    const servicePackage = {
+      id: schedule.id,
+      total_amount: schedule.total_amount,
+      provider: schedule.provider,
+      schedules: [
+        {
+          ...schedule,
+        },
+      ],
+    };
+
+    $q.dialog({
+      component: SchedulePaymentDialog,
+      componentProps: {
+        servicePackage,
+      },
+    }).onOk(() => {
+      emit("refreshData");
+    });
 
-    emit("refreshData");
-    // onDialogOK()
   } catch (error) {
     console.log(error);
-  } finally {
-    // isLoading.value = false
   }
 };