ServiceTimeSelectionDialog.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <template>
  2. <q-dialog ref="dialogRef" @hide="onDialogHide">
  3. <q-card class="card-border bg-surface text-text time-card">
  4. <!-- Fechar -->
  5. <q-btn
  6. flat round dense
  7. icon="mdi-close-circle-outline"
  8. color="grey-5"
  9. class="absolute-top-right q-mt-sm q-mr-sm"
  10. @click="onDialogCancel"
  11. />
  12. <!-- Título -->
  13. <q-card-section class="text-center q-pt-lg q-pb-xs">
  14. <div class="text-subtitle1 text-weight-bold text-text">
  15. {{ serviceType.label }}
  16. <span class="text-weight-regular text-grey-6">{{ '(' + serviceType.hoursCount + 'h)' }}</span>
  17. </div>
  18. <div class="text-caption text-grey-6 q-mt-xs">
  19. {{ $t('scheduling_page.time_selection.subtitle') }}
  20. </div>
  21. </q-card-section>
  22. <!-- Slots de horário -->
  23. <q-card-section class="q-pt-xs">
  24. <div class="row q-col-gutter-xs">
  25. <div
  26. v-for="slot in timeSlots"
  27. :key="slot.value"
  28. class="col-6"
  29. >
  30. <q-radio
  31. v-model="selectedSlot"
  32. :val="slot.value"
  33. :label="slot.label"
  34. color="primary"
  35. keep-color
  36. dense
  37. />
  38. </div>
  39. </div>
  40. </q-card-section>
  41. <!-- Refeição (apenas 6h e 8h) -->
  42. <template v-if="hasMealSection">
  43. <q-separator class="q-mx-md" />
  44. <q-card-section class="q-py-sm">
  45. <div class="text-body2 text-weight-bold text-text q-mb-sm text-center">
  46. {{ $t('scheduling_page.time_selection.meal_section') }}
  47. </div>
  48. <div class="row justify-center q-gutter-x-xl">
  49. <q-radio
  50. v-model="selectedMeal"
  51. val="offer"
  52. :label="$t('scheduling_page.time_selection.meal_offer')"
  53. color="primary"
  54. keep-color
  55. dense
  56. />
  57. <q-radio
  58. v-model="selectedMeal"
  59. val="no_offer"
  60. :label="$t('scheduling_page.time_selection.meal_no_offer')"
  61. color="primary"
  62. keep-color
  63. dense
  64. />
  65. </div>
  66. </q-card-section>
  67. </template>
  68. <!-- Botão continuar -->
  69. <q-card-actions class="q-px-md q-pb-xs q-pt-sm">
  70. <q-btn
  71. unelevated
  72. rounded
  73. no-caps
  74. :label="$t('scheduling_page.time_selection.continue')"
  75. color="secondary"
  76. class="full-width"
  77. @click="handleContinue"
  78. />
  79. </q-card-actions>
  80. <!-- Nota de pausa -->
  81. <div v-if="pauseNote" class="text-center text-caption text-primary q-pb-md">
  82. {{ pauseNote }}
  83. </div>
  84. </q-card>
  85. </q-dialog>
  86. </template>
  87. <script setup>
  88. import { ref, computed } from 'vue';
  89. import { useDialogPluginComponent } from 'quasar';
  90. import { useI18n } from 'vue-i18n';
  91. const props = defineProps({
  92. serviceType: { type: Object, required: true },
  93. provider: { type: Object, required: true },
  94. selectedDate:{ type: String, required: true },
  95. });
  96. defineEmits([...useDialogPluginComponent.emits]);
  97. const { dialogRef, onDialogHide, onDialogCancel, onDialogOK } = useDialogPluginComponent();
  98. const { t } = useI18n();
  99. const selectedSlot = ref(null);
  100. const selectedMeal = ref(null);
  101. // Gera todos os slots possíveis de 7h até 20h para a duração dada
  102. const timeSlots = computed(() => {
  103. const h = props.serviceType.hoursCount;
  104. const slots = [];
  105. for (let start = 7; start + h <= 20; start++) {
  106. const end = start + h;
  107. slots.push({
  108. value: `${start}-${end}`,
  109. label: `${start}h às ${end}h`,
  110. });
  111. }
  112. return slots;
  113. });
  114. const hasMealSection = computed(() =>
  115. props.serviceType.hoursCount >= 6
  116. );
  117. const pauseNote = computed(() => {
  118. const map = { 8: t('scheduling_page.time_selection.pause_note_8h'), 6: t('scheduling_page.time_selection.pause_note_6h'), 4: t('scheduling_page.time_selection.pause_note_4h') };
  119. return map[props.serviceType.hoursCount] ?? null;
  120. });
  121. // Função que ira pegar os valores para o banco de dados
  122. function handleContinue(){
  123. if(!selectedSlot.value) {
  124. return;
  125. }
  126. if(hasMealSection.value && !selectedMeal.value) {
  127. return;
  128. }
  129. onDialogOK({
  130. slot: selectedSlot.value,
  131. meal: selectedMeal.value,
  132. date: props.selectedDate,
  133. serviceType: props.serviceType,
  134. })
  135. };
  136. </script>
  137. <style scoped lang="scss">
  138. .time-card {
  139. width: min(88vw, 360px);
  140. }
  141. </style>