ScheduleAcceptedDialog.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <q-dialog ref="dialogRef" @hide="onDialogHide">
  3. <q-card class="accepted-dialog-card bg-surface" :flat="false">
  4. <q-card-section class="column items-center q-pt-lg q-pb-sm">
  5. <q-avatar size="80px" :style="avatarStyle" class="text-h5 q-mb-sm">
  6. {{ schedule.provider_name?.slice(0, 2).toUpperCase() ?? '??' }}
  7. </q-avatar>
  8. <div class="font16 fontbold provider-name">{{ schedule.provider_name }}</div>
  9. <div class="font14 fontmedium text-text">{{ schedule.address?.district || '' }}</div>
  10. </q-card-section>
  11. <q-card-section class="text-center q-pt-xs q-pb-md">
  12. <div class="accepted-title font16 fontbold">
  13. {{ $t('dashboard_client.pending_schedules.accepted_title') }}
  14. </div>
  15. </q-card-section>
  16. <q-separator />
  17. <q-card-section class="q-py-md q-px-lg">
  18. <div class="detail-row">
  19. <span class="text-primary font14 fontmedium">{{ $t('dashboard_client.pending_schedules.detail_date') }}</span>
  20. <span class="detail-value">{{ formattedDate }}</span>
  21. </div>
  22. <div class="detail-row">
  23. <span class="text-primary font14 fontmedium">{{ $t('dashboard_client.pending_schedules.detail_time') }}</span>
  24. <span class="detail-valued text-text">
  25. {{ schedule.start_time?.slice(0, 5) }} {{ $t('dashboard_client.next_schedules.to') }} {{ schedule.end_time?.slice(0, 5) }}
  26. </span>
  27. </div>
  28. <div class="detail-row">
  29. <span class="text-primary font14 fontmedium">{{ $t('dashboard_client.pending_schedules.detail_value') }}</span>
  30. <span class="detail-value">{{ formatCurrency(schedule.total_amount) }}</span>
  31. </div>
  32. <div class="detail-row">
  33. <span class="text-primary font14 fontmedium">{{ $t('dashboard_client.pending_schedules.detail_service_fee') }}</span>
  34. <span class="detail-value">{{ formatCurrency(serviceFee) }}</span>
  35. </div>
  36. <q-separator class="q-my-sm" />
  37. <div class="text-center">
  38. <span class="text-primary font14 fontmedium">{{ $t('dashboard_client.pending_schedules.detail_total') }}</span>
  39. <span class="total-value font14 fontbold q-ml-sm">{{ formatCurrency(total) }}</span>
  40. </div>
  41. </q-card-section>
  42. <q-card-section class="q-pt-none q-pb-lg q-px-lg column q-gutter-y-sm">
  43. <q-btn
  44. rounded
  45. color="primary"
  46. class="payment-btn full-width"
  47. padding="4px 12px"
  48. :label="$t('dashboard_client.pending_schedules.btn_payment')"
  49. @click="onGoToPayment"
  50. />
  51. <q-btn
  52. flat
  53. no-caps
  54. color="grey-6"
  55. class="full-width"
  56. padding="4px 12px"
  57. :label="$t('dashboard_client.pending_schedules.btn_cancel')"
  58. @click="onDialogHide"
  59. />
  60. </q-card-section>
  61. </q-card>
  62. </q-dialog>
  63. </template>
  64. <script setup>
  65. import { computed } from 'vue'
  66. import { useDialogPluginComponent, useQuasar } from 'quasar'
  67. import { formatCurrency } from 'src/helpers/utils'
  68. import { usePaymentStore } from 'src/stores/payment'
  69. import SchedulePaymentDialog from './SchedulePaymentDialog.vue'
  70. import SchedulePaymentPixDialog from './SchedulePaymentPixDialog.vue'
  71. const props = defineProps({
  72. schedule: {
  73. type: Object,
  74. required: true
  75. }
  76. })
  77. defineEmits([...useDialogPluginComponent.emits])
  78. const { dialogRef, onDialogHide, onDialogOK } = useDialogPluginComponent()
  79. const $q = useQuasar()
  80. const paymentStore = usePaymentStore()
  81. const SERVICE_FEE_RATE = 0.11
  82. const serviceFee = computed(() => Number(props.schedule.total_amount) * SERVICE_FEE_RATE)
  83. const total = computed(() => Number(props.schedule.total_amount) + serviceFee.value)
  84. const onGoToPayment = () => {
  85. const hasValidPixPayment = !!paymentStore.getValidPixPayment(props.schedule.id)
  86. $q.dialog({
  87. component: hasValidPixPayment ? SchedulePaymentPixDialog : SchedulePaymentDialog,
  88. componentProps: {
  89. schedule: props.schedule,
  90. total: total.value,
  91. },
  92. }).onOk(() => {
  93. onDialogOK()
  94. })
  95. }
  96. const formattedDate = computed(() => {
  97. if (props.schedule.formatted_date) return props.schedule.formatted_date
  98. const raw = String(props.schedule.date || '')
  99. const m = raw.match(/^(\d{4})-(\d{2})-(\d{2})/)
  100. if (!m) return raw
  101. const d = new Date(+m[1], +m[2] - 1, +m[3])
  102. return d.toLocaleDateString('pt-BR', { day: '2-digit', month: 'long', year: 'numeric' })
  103. })
  104. const avatarColors = [
  105. { background: '#ffd5df', color: '#932e57' },
  106. { background: '#d7e8ff', color: '#2158a8' },
  107. { background: '#dfd', color: '#2a7a3b' },
  108. { background: '#ffe5cc', color: '#8a4500' },
  109. ]
  110. const avatarStyle = computed(() => avatarColors[props.schedule.id % avatarColors.length])
  111. </script>
  112. <style scoped lang="scss">
  113. .accepted-dialog-card {
  114. width: 320px;
  115. max-width: 92vw;
  116. border-radius: 20px !important;
  117. overflow: hidden;
  118. }
  119. .accepted-title {
  120. line-height: 1.3;
  121. color: #8B5CF6;
  122. }
  123. .provider-name {
  124. color: #8B5CF6;
  125. }
  126. .detail-row {
  127. display: flex;
  128. justify-content: space-between;
  129. align-items: center;
  130. padding: 4px 0;
  131. }
  132. .detail-label {
  133. color: #8a8a9a;
  134. }
  135. .detail-value {
  136. color: #3a3a4a;
  137. }
  138. .total-value {
  139. color: #3a3a4a;
  140. }
  141. .payment-btn {
  142. height: 48px;
  143. }
  144. </style>