DashboardTodaySchedules.vue 7.8 KB

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