Pārlūkot izejas kodu

ajustes agendamento, somente parceiro/admin seta data hora + notificacao para o associado

Gustavo Zanatta 1 mēnesi atpakaļ
vecāks
revīzija
afa7fe58de

+ 4 - 4
src/api/appointment.js

@@ -29,8 +29,8 @@ export const getPartnerAppointments = async () => {
   return data.payload;
 };
 
-export const approveAppointmentParceiro = async (id) => {
-  const { data } = await api.put(`/parceiro/appointment/${id}/approve`);
+export const approveAppointmentParceiro = async (id, payload) => {
+  const { data } = await api.put(`/parceiro/appointment/${id}/approve`, payload);
   return data.payload;
 };
 
@@ -52,8 +52,8 @@ export const getAdminAppointmentsPaginated = async ({ page = 1, perPage = 10, fi
   return { data: { result: data.payload } };
 };
 
-export const approveAppointment = async (id) => {
-  const { data } = await api.put(`/appointment/${id}/approve`);
+export const approveAppointment = async (id, payload) => {
+  const { data } = await api.put(`/appointment/${id}/approve`, payload);
   return data.payload;
 };
 

+ 56 - 0
src/components/ApproveAppointmentDialog.vue

@@ -0,0 +1,56 @@
+<template>
+  <q-dialog ref="dialogRef" persistent @hide="onDialogHide">
+    <q-card style="min-width: 340px">
+      <q-card-section>
+        <div class="text-h6">{{ $t('agendamento.definir_data_hora') }}</div>
+      </q-card-section>
+
+      <q-card-section>
+        <q-form ref="formRef" class="q-gutter-sm">
+          <DefaultInputDatePicker
+            v-model:untreated-date="date"
+            :label="$t('common.terms.date')"
+            :rules="[inputRules.required]"
+            placeholder="dd/mm/aaaa"
+            lazy-rules
+          />
+          <DefaultInput
+            v-model="time"
+            :label="$t('common.terms.hour2')"
+            :rules="[inputRules.required]"
+            mask="##:##"
+            placeholder="HH:MM"
+          />
+        </q-form>
+      </q-card-section>
+
+      <q-card-actions align="right">
+        <q-btn flat :label="$t('common.actions.cancel')" @click="onDialogCancel" />
+        <q-btn color="positive" :label="$t('common.actions.confirm')" @click="onConfirm" />
+      </q-card-actions>
+    </q-card>
+  </q-dialog>
+</template>
+
+<script setup>
+import { ref, useTemplateRef } from "vue";
+import { useDialogPluginComponent } from "quasar";
+import { useInputRules } from "src/composables/useInputRules";
+import DefaultInput from "src/components/defaults/DefaultInput.vue";
+import DefaultInputDatePicker from "src/components/defaults/DefaultInputDatePicker.vue";
+
+defineEmits([...useDialogPluginComponent.emits]);
+
+const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent();
+const { inputRules } = useInputRules();
+
+const formRef = useTemplateRef("formRef");
+const date = ref("");
+const time = ref("");
+
+const onConfirm = async () => {
+  const valid = await formRef.value?.validate();
+  if (!valid) return;
+  onDialogOK({ date: date.value, time: time.value });
+};
+</script>

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

@@ -58,7 +58,7 @@
       "download_boleto": "Download Boleto",
       "copy_paste_code": "Copy and paste the code below to make the payment",
       "go_home": "Go Home",
-      "close": "Fechar"
+      "close": "Close"
     },
     "terms": {
       "actions": "Actions",
@@ -644,7 +644,7 @@
     "nova_solicitacao":           "New Request",
     "visao_geral":                "Overview",
     "aprovados_automaticamente":  "Auto Approved",
-    "confirm_approve":            "Confirm approval of this appointment?",
+    "definir_data_hora":          "Set date and time",
     "confirm_reject":             "Confirm rejection of this appointment?",
     "status": {
       "pendente":   "Pending",

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

@@ -58,7 +58,8 @@
       "download_boleto": "Descargar Boleto",
       "copy_paste_code": "Copie y pegue el código a continuación para realizar el pago",
       "go_home": "Ir al Inicio",
-      "close": "Fechar"
+      "close": "Cerrar",
+      "confirm": "Confirmar"
     },
     "terms": {
       "actions": "Acciones",
@@ -643,7 +644,7 @@
     "nova_solicitacao":           "Nueva Solicitud",
     "visao_geral":                "Vista General",
     "aprovados_automaticamente":  "Aprobados Automáticamente",
-    "confirm_approve":            "¿Confirmar aprobación de esta cita?",
+    "definir_data_hora":          "Definir fecha y hora",
     "confirm_reject":             "¿Confirmar rechazo de esta cita?",
     "status": {
       "pendente":   "Pendiente",

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

@@ -58,7 +58,8 @@
       "download_boleto": "Baixar Boleto",
       "copy_paste_code": "Copie e cole o código abaixo para efetuar o pagamento",
       "go_home": "Ir para o Início",
-      "close": "Fechar"
+      "close": "Fechar",
+      "confirm": "Confirmar"
     },
     "terms": {
       "actions": "Ações",
@@ -644,7 +645,7 @@
     "nova_solicitacao":           "Nova Solicitação",
     "visao_geral":                "Visão Geral",
     "aprovados_automaticamente":  "Aprovados Automaticamente",
-    "confirm_approve":            "Confirmar aprovação deste agendamento?",
+    "definir_data_hora":          "Definir data e horário",
     "confirm_reject":             "Confirmar recusa deste agendamento?",
     "status": {
       "pendente":   "Pendente",

+ 12 - 17
src/pages/agendamentos/AppointmentsAdminPage.vue

@@ -183,7 +183,7 @@
 </template>
 
 <script setup>
-import { ref, computed, onMounted, useTemplateRef } from "vue";
+import { ref, computed, onMounted, useTemplateRef, nextTick } from "vue";
 import { useQuasar } from "quasar";
 import { useI18n } from "vue-i18n";
 import { useInputRules } from "src/composables/useInputRules";
@@ -195,6 +195,7 @@ import DefaultInputDatePicker from "src/components/defaults/DefaultInputDatePick
 import AssociadoSelect from "src/components/selects/AssociadoSelect.vue";
 import PartnerAgreementSelect from "src/components/selects/PartnerAgreementSelect.vue";
 import PartnerAgreementServiceSelect from "src/components/selects/PartnerAgreementServiceSelect.vue";
+import ApproveAppointmentDialog from "src/components/ApproveAppointmentDialog.vue";
 
 import {
   getAdminCounters,
@@ -295,11 +296,11 @@ const loadCounters = async () => {
   try {
     counters.value = await getAdminCounters();
   } catch {
-    // silent — counters show '—'
+    // silent
   }
 };
 
-const resetForm = () => {
+const resetForm = async () => {
   form.value = {
     associado: null,
     partner: null,
@@ -308,6 +309,7 @@ const resetForm = () => {
     time: "",
     observations: "",
   };
+  await nextTick();
   formRef.value?.resetValidation();
 };
 
@@ -324,11 +326,10 @@ const submitAppointment = async () => {
       date: form.value.date,
       observations: form.value.observations || null,
     });
-    $q.notify({ type: "positive", message: t("http.success") });
-    resetForm();
+    await resetForm();
     await loadCounters();
   } catch {
-    $q.notify({ type: "negative", message: t("http.errors.failed") });
+    // silent
   } finally {
     submitting.value = false;
   }
@@ -336,23 +337,17 @@ const submitAppointment = async () => {
 
 const onApprove = (row) => {
   if (row.status !== "pendente") return;
-  $q.dialog({
-    title: t("common.ui.messages.confirm_action"),
-    message: t("agendamento.confirm_approve"),
-    cancel: true,
-    persistent: true,
-  }).onOk(async () => {
-    actionId.value = row.id;
+  $q.dialog({ component: ApproveAppointmentDialog }).onOk(async ({ date, time }) => {
+    actionId.value   = row.id;
     actionType.value = "approve";
     try {
-      await approveAppointment(row.id);
+      await approveAppointment(row.id, { date, time });
       tableKey.value++;
       await loadCounters();
-      $q.notify({ type: "positive", message: t("http.success") });
     } catch {
-      $q.notify({ type: "negative", message: t("http.errors.failed") });
+      // silent
     } finally {
-      actionId.value = null;
+      actionId.value   = null;
       actionType.value = null;
     }
   });

+ 1 - 4
src/pages/associado/agendamentos/AgendamentosPage.vue

@@ -147,7 +147,6 @@
 
 <script setup>
 import { ref, reactive, computed, watch, useTemplateRef } from "vue";
-import { useQuasar } from "quasar";
 import { useI18n } from "vue-i18n";
 import { createAppointment, getMyAppointments, updateAppointment } from "src/api/appointment";
 import { useInputRules } from "src/composables/useInputRules";
@@ -157,7 +156,6 @@ import DefaultInputDatePicker from "src/components/defaults/DefaultInputDatePick
 import PartnerAgreementSelect from "src/components/selects/PartnerAgreementSelect.vue";
 import PartnerAgreementServiceSelect from "src/components/selects/PartnerAgreementServiceSelect.vue";
 import { userStore } from "src/stores/user";
-const $q = useQuasar();
 const { t } = useI18n();
 const { inputRules } = useInputRules();
 const appointmentFormRef = useTemplateRef("appointmentFormRef");
@@ -259,11 +257,10 @@ const submitAppointment = async () => {
       payload.user_id = user.user.id;
       await createAppointment(payload);
     }
-    $q.notify({ type: "positive", message: t("http.success") });
     resetForm();
     activeTab.value = "meus";
   } catch {
-    $q.notify({ type: "negative", message: t("http.errors.failed") });
+    // silent
   } finally {
     submitting.value = false;
   }

+ 5 - 9
src/pages/parceiros-convenios/AgendamentosParceiroPage.vue

@@ -113,6 +113,7 @@ import {
   rejectAppointmentParceiro,
 } from "src/api/appointment";
 import DefaultHeaderPage from "src/components/layout/DefaultHeaderPage.vue";
+import ApproveAppointmentDialog from "src/components/ApproveAppointmentDialog.vue";
 
 const $q = useQuasar();
 const { t } = useI18n();
@@ -169,22 +170,17 @@ const formatDateTime = (date, time) => {
 
 const onApprove = (row) => {
   if (row.status !== "pendente") return;
-  $q.dialog({
-    title: t("common.ui.messages.confirm_action"),
-    message: t("agendamento.confirm_approve"),
-    cancel: true,
-    persistent: true,
-  }).onOk(async () => {
-    actionId.value = row.id;
+  $q.dialog({ component: ApproveAppointmentDialog }).onOk(async ({ date, time }) => {
+    actionId.value   = row.id;
     actionType.value = "approve";
     try {
-      await approveAppointmentParceiro(row.id);
+      await approveAppointmentParceiro(row.id, { date, time });
       row.status = "confirmado";
       $q.notify({ type: "positive", message: t("http.success") });
     } catch {
       $q.notify({ type: "negative", message: t("http.errors.failed") });
     } finally {
-      actionId.value = null;
+      actionId.value   = null;
       actionType.value = null;
     }
   });