DashboardClientProposals.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <div class="scroll-wrapper">
  3. <div class="scroll-track q-pb-md q-px-md">
  4. <q-card v-for="item in data" :key="item.id" class="proposal-card shadow-card" :flat="false">
  5. <div class="row no-wrap items-center">
  6. <q-avatar :style="avatarColors[item.id % avatarColors.length]" class="text-weight-bold q-mx-auto">
  7. <img v-if="item.provider_photo" :src="item.provider_photo" style="object-fit:cover;border-radius:50%;" />
  8. <span v-else>{{ item.provider_name?.slice(0, 1) ?? '—' }}</span>
  9. </q-avatar>
  10. <!-- LABEL -->
  11. <div class="type">
  12. {{ $t('dashboard_client.client_proposals.candidate') }} <span>{{
  13. $t('dashboard_client.client_proposals.custom') }}</span>
  14. </div>
  15. <div class="content">
  16. <!-- HEADER -->
  17. <div class="row justify-between items-center text-text ">
  18. <div>
  19. <div class="name">
  20. {{ item.provider_name }}
  21. <span class="age">{{ $t('dashboard_client.client_proposals.age', { idade: item.idade }) }}</span>
  22. </div>
  23. <span class="rating">
  24. <q-icon name="star" size="11px" />
  25. {{ item.average_rating }}
  26. </span>
  27. </div>
  28. </div>
  29. <!-- DATA -->
  30. <div class="datetime">
  31. {{ formatDate(item.date) }} <br />
  32. {{ $t('dashboard_client.next_schedules.from') }} {{ formatTime(item.start_time) }} {{
  33. $t('dashboard_client.next_schedules.to') }} {{ formatTime(item.end_time) }}
  34. </div>
  35. <!-- PREÇO -->
  36. <div class="price">
  37. {{ filterCurrency(chooseprice(item.period_type, item.daily_price_8h)) }}
  38. <span class="text-price-label col-6">
  39. {{ formatLabelByPeriodType(item.period_type) }}
  40. </span>
  41. <span class="distance">
  42. {{ $t('dashboard_client.client_proposals.distance') }} {{ (item.distance_km ?? '--') + ' km' }}
  43. </span>
  44. </div>
  45. <!-- BOTÕES -->
  46. <div class="actions">
  47. <q-btn label="recusar" flat class="btn-reject" @click="() => handleRefuseProposal(item.id)" />
  48. <q-btn label="aceitar" class="btn-accept" @click="() => handleAcceptProposal(item.id)" />
  49. </div>
  50. </div>
  51. </div>
  52. </q-card>
  53. </div>
  54. </div>
  55. </template>
  56. <script setup>
  57. import { acceptProposal, refuseProposal } from 'src/api/customSchedules'
  58. import { chooseprice, formatLabelByPeriodType, filterCurrency } from 'src/helpers/utils'
  59. defineProps({
  60. data: {
  61. type: Array,
  62. default: () => []
  63. }
  64. })
  65. const emit = defineEmits(['refreshData'])
  66. const avatarColors = [
  67. { background: '#ffd5df', color: '#932e57' },
  68. { background: '#d7e8ff', color: '#2158a8' },
  69. { background: '#dfd', color: '#2a7a3b' },
  70. { background: '#ffe5cc', color: '#8a4500' },
  71. ];
  72. const formatTime = (time) => {
  73. if (!time) return '';
  74. const [hour, minute] = time.split(':');
  75. return `${hour}:${minute}`;
  76. };
  77. const formatDate = (date) => {
  78. if (!date) return '';
  79. const d = new Date(date);
  80. const weekday = d.toLocaleDateString('pt-BR', {
  81. weekday: 'long'
  82. });
  83. const day = String(d.getDate()).padStart(2, '0');
  84. const month = String(d.getMonth() + 1).padStart(2, '0');
  85. return `${weekday}, ${day}-${month}`;
  86. };
  87. const handleRefuseProposal = async (proposalId) => {
  88. // isLoading.value = true
  89. try {
  90. await refuseProposal(proposalId)
  91. // await loadProposals()
  92. emit('refreshData')
  93. } catch (error) {
  94. console.log(error);
  95. } finally {
  96. // isLoading.value = false
  97. }
  98. }
  99. const handleAcceptProposal = async (proposalId) => {
  100. // isLoading.value = true
  101. try {
  102. await acceptProposal(proposalId)
  103. emit('refreshData')
  104. // onDialogOK()
  105. } catch (error) {
  106. console.log(error);
  107. } finally {
  108. // isLoading.value = false
  109. }
  110. }
  111. </script>
  112. <style scoped lang="scss">
  113. .scroll-wrapper {
  114. overflow-x: auto;
  115. scrollbar-width: none;
  116. }
  117. .scroll-track {
  118. display: flex;
  119. gap: 12px;
  120. }
  121. .scroll-wrapper::-webkit-scrollbar {
  122. display: none;
  123. }
  124. .proposal-card {
  125. position: relative;
  126. min-width: 330px;
  127. max-width: 330px;
  128. min-height: 115px;
  129. border-radius: 18px;
  130. padding: 12px;
  131. background: white;
  132. flex-shrink: 0;
  133. }
  134. /* alinhar topo */
  135. .proposal-card .row:first-child {
  136. align-items: flex-start !important;
  137. }
  138. .row.justify-between {
  139. align-items: flex-start !important;
  140. padding-right: 70px; // espaço pro preço
  141. }
  142. .content {
  143. width: 100%;
  144. display: flex;
  145. flex-direction: column;
  146. justify-content: space-between;
  147. gap: 2px;
  148. }
  149. /* nome */
  150. .name {
  151. font-size: 14px;
  152. font-weight: 600;
  153. color: #5a3eff;
  154. }
  155. .age {
  156. font-size: 11px;
  157. color: #999;
  158. font-weight: 400;
  159. }
  160. /* rating */
  161. .rating {
  162. font-size: 11px;
  163. color: #444;
  164. }
  165. /* distância */
  166. .distance {
  167. font-size: 11px;
  168. color: #777;
  169. font-weight: 500;
  170. }
  171. .price .distance {
  172. font-size: 9px; // 👈 menor
  173. color: #777;
  174. margin-top: 4px; // 👈 desce um pouco
  175. font-weight: 400;
  176. }
  177. /* data */
  178. .datetime {
  179. font-size: 10px;
  180. color: #8f8f8f;
  181. margin-top: 2px;
  182. line-height: 1.2;
  183. }
  184. /* preço topo direito */
  185. .price {
  186. position: absolute;
  187. top: 12px;
  188. right: 12px;
  189. font-size: 15px;
  190. font-weight: 700;
  191. color: #6b4eff;
  192. display: flex;
  193. flex-direction: column;
  194. align-items: flex-end;
  195. }
  196. .text-price-label {
  197. font-size: 10px;
  198. color: #999;
  199. font-weight: 400;
  200. }
  201. .type {
  202. position: absolute;
  203. left: 12px;
  204. top: 72px;
  205. font-size: 10px;
  206. color: #6b4eff;
  207. display: flex;
  208. flex-direction: column;
  209. align-items: flex-start;
  210. line-height: 1.1;
  211. }
  212. .type span {
  213. font-weight: 600;
  214. }
  215. .type span {
  216. font-weight: 600;
  217. }
  218. /* avatar alinhado */
  219. .q-avatar {
  220. margin-left: 0 !important;
  221. margin-right: 10px !important;
  222. }
  223. /* botões */
  224. .actions {
  225. display: flex;
  226. justify-content: flex-end;
  227. gap: 8px;
  228. margin-top: auto;
  229. }
  230. .btn-reject {
  231. background: #eee6ff;
  232. color: #6b4eff;
  233. border-radius: 20px;
  234. padding: 3px 12px;
  235. font-size: 11px;
  236. }
  237. .btn-accept {
  238. background: linear-gradient(90deg, #6b4eff, #9f6bff);
  239. color: white;
  240. border-radius: 20px;
  241. padding: 3px 12px;
  242. font-size: 11px;
  243. }
  244. </style>