DashboardTodaySchedules.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template>
  2. <div class="q-mx-md q-mb-md">
  3. <div class="scroll-wrapper">
  4. <div class="scroll-track">
  5. <q-card
  6. v-for="item in data"
  7. :key="item.id"
  8. class="today-card card-border shadow-card bg-surface"
  9. :flat="false"
  10. >
  11. <q-card-section class="q-pa-md">
  12. <div class="row no-wrap items-start q-mb-xs">
  13. <q-avatar size="40px" class="flex-shrink-0 q-mr-sm">
  14. <img v-if="item.provider_photo" :src="item.provider_photo" />
  15. <span v-else :style="avatarColors[item.id % avatarColors.length]" class="text-weight-bold full-width full-height flex flex-center" style="font-size:14px; border-radius:50%;">
  16. {{ item.provider_name?.slice(0, 2).toUpperCase() ?? '??' }}
  17. </span>
  18. </q-avatar>
  19. <div class="col column no-wrap overflow-hidden justify-center">
  20. <span class="text-body2 text-text leading-tight">
  21. <template v-if="cardState(item) === 'awaiting_code'">{{ $t('dashboard_client.today_schedules.start_with') }}</template>
  22. <template v-else-if="cardState(item) === 'in_progress'">{{ $t('dashboard_client.today_schedules.started_by') }}</template>
  23. <template v-else>{{ $t('dashboard_client.today_schedules.finished_by') }}</template>
  24. <span class="text-weight-bold"> {{ ' ' + item.provider_name ?? '—' }}</span>
  25. </span>
  26. <div class="row items-center q-mt-xs">
  27. <q-icon name="mdi-clock-outline" size="13px" class="q-mr-xs gradient-diarista" />
  28. <span class="text-caption text-grey-5">
  29. <template v-if="cardState(item) !== 'finished'">{{ $t('dashboard_client.next_schedules.from') }} </template>
  30. {{ item.start_time?.slice(0, 5) }} {{ $t('dashboard_client.next_schedules.to') }} {{ item.end_time?.slice(0, 5) }}
  31. </span>
  32. </div>
  33. </div>
  34. <div class="flex-shrink-0 q-ml-sm column items-center justify-start">
  35. <template v-if="cardState(item) === 'awaiting_code'">
  36. <div class="column items-center">
  37. <span class="text-caption text-primary q-mb-xs">{{ $t('dashboard_client.today_schedules.code_label') }}</span>
  38. <div class="code-pill bg-primary">{{ item.code }}</div>
  39. </div>
  40. </template>
  41. <template v-else-if="cardState(item) === 'in_progress'">
  42. <div class="column items-center">
  43. <div class="clock-badge">
  44. <q-icon name="mdi-clock-outline" size="18px" color="white" />
  45. </div>
  46. <span class="badge-status-text text-primary text-weight-bold q-mt-xs">
  47. {{ $t('dashboard_client.today_schedules.in_progress') }}
  48. </span>
  49. </div>
  50. </template>
  51. <template v-else>
  52. <div v-if="item.client_reviewed" class="rate-btn reviewed-badge">
  53. <q-icon name="mdi-star" size="14px" class="q-mr-xs" />
  54. {{ $t('dashboard_client.schedule_rating.reviewed_badge') }}
  55. </div>
  56. <q-btn
  57. v-else
  58. unelevated no-caps
  59. class="rate-btn"
  60. icon="mdi-star-outline"
  61. :label="$t('dashboard_client.today_schedules.rate_btn')"
  62. @click.stop="emit('rate', item)"
  63. />
  64. </template>
  65. </div>
  66. </div>
  67. <div class="progress-track q-mb-sm">
  68. <div class="progress-fill" :class="cardState(item) === 'finished' ? 'progress-fill--finished' : ''" :style="{ width: progressByState(item) + '%' }" />
  69. </div>
  70. <div class="row items-center no-wrap">
  71. <template v-if="cardState(item) !== 'finished'">
  72. <q-btn
  73. flat no-caps dense
  74. :label="$t('dashboard_client.today_schedules.help_btn')"
  75. color="primary"
  76. size="sm"
  77. class="flex-shrink-0"
  78. @click.stop="openHelp"
  79. />
  80. <q-space />
  81. <template v-if="cardState(item) === 'awaiting_code'">
  82. <q-icon name="mdi-map-marker-outline" size="13px" color="grey-6" class="q-mr-xs flex-shrink-0" />
  83. <span class="text-caption text-grey-6 col ellipsis text-right">
  84. {{ [item.address?.address, item.address?.number, item.address?.district].filter(Boolean).join(', ') || '—' }}
  85. </span>
  86. </template>
  87. <template v-else>
  88. <q-icon name="mdi-clock-outline" size="13px" class="q-mr-xs flex-shrink-0 gradient-diarista" />
  89. <span class="text-caption text-grey-6 text-right text-no-wrap">
  90. {{ $t('dashboard_client.today_schedules.end_time_label') }}
  91. <span class="gradient-diarista">{{ item.end_time?.slice(0, 5) }}</span>
  92. </span>
  93. </template>
  94. </template>
  95. </div>
  96. </q-card-section>
  97. </q-card>
  98. </div>
  99. </div>
  100. </div>
  101. </template>
  102. <script setup>
  103. import { useQuasar } from 'quasar'
  104. import ProfileHelpDialog from 'src/components/profile/ProfileHelpDialog.vue'
  105. defineProps({ data: { type: Array, default: () => [] } })
  106. const emit = defineEmits(['rate'])
  107. const $q = useQuasar()
  108. const avatarColors = [
  109. { background: '#ffd5df', color: '#932e57' },
  110. { background: '#d7e8ff', color: '#2158a8' },
  111. { background: '#dfd', color: '#2a7a3b' },
  112. { background: '#ffe5cc', color: '#8a4500' },
  113. ]
  114. const cardState = (item) => {
  115. if (!item.code_verified) return 'awaiting_code'
  116. const [h, m] = (item.end_time || '23:59').slice(0, 5).split(':').map(Number)
  117. const endTime = new Date()
  118. endTime.setHours(h, m, 0, 0)
  119. return new Date() >= endTime ? 'finished' : 'in_progress'
  120. }
  121. const progressByState = (item) => {
  122. const state = cardState(item)
  123. if (state === 'awaiting_code') return 60
  124. if (state === 'in_progress') return 80
  125. return 100
  126. }
  127. const openHelp = () => {
  128. $q.dialog({ component: ProfileHelpDialog })
  129. }
  130. </script>
  131. <style scoped lang="scss">
  132. .scroll-wrapper { overflow: hidden; }
  133. .scroll-track {
  134. display: flex;
  135. flex-direction: row;
  136. gap: 12px;
  137. overflow-x: auto;
  138. overscroll-behavior-x: contain;
  139. scroll-snap-type: x proximity;
  140. padding-bottom: 8px;
  141. &::-webkit-scrollbar { display: none; }
  142. &::after { content: ''; flex: 0 0 1px; }
  143. }
  144. .today-card {
  145. min-width: 80%;
  146. scroll-snap-align: start;
  147. border-radius: 12px;
  148. }
  149. .code-pill {
  150. color: white;
  151. font-weight: 700;
  152. font-size: 15px;
  153. letter-spacing: 2px;
  154. border-radius: 20px;
  155. padding: 4px 14px;
  156. }
  157. .clock-badge {
  158. width: 36px;
  159. height: 36px;
  160. border-radius: 50%;
  161. background: linear-gradient(135deg, #8B5CF6, #EC4899);
  162. display: flex;
  163. align-items: center;
  164. justify-content: center;
  165. }
  166. .badge-status-text {
  167. font-size: 10px;
  168. white-space: nowrap;
  169. }
  170. .rate-btn {
  171. background: #EC4899;
  172. color: white;
  173. font-weight: 700;
  174. font-size: 13px;
  175. white-space: nowrap;
  176. border-radius: 10px !important;
  177. min-width: 72px;
  178. min-height: 56px;
  179. padding: 6px 10px;
  180. display: flex;
  181. flex-direction: column;
  182. align-items: center;
  183. justify-content: center;
  184. gap: 4px;
  185. }
  186. .reviewed-badge {
  187. cursor: default;
  188. opacity: 0.85;
  189. font-size: 11px;
  190. }
  191. .progress-track {
  192. width: 100%;
  193. height: 5px;
  194. background: #E2E8F0;
  195. border-radius: 3px;
  196. overflow: hidden;
  197. }
  198. .progress-fill {
  199. height: 100%;
  200. border-radius: 3px;
  201. background: linear-gradient(90deg, #8B5CF6, #EC4899);
  202. transition: width 0.4s ease;
  203. &--finished {
  204. background: #22c55e;
  205. }
  206. }
  207. </style>