DashboardPage.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <div class="dashboard-page bg-page">
  3. <template v-if="loading">
  4. <div class="row items-center justify-center full-width bg-surface" style="height: 80vh">
  5. <q-spinner-dots color="primary" />
  6. </div>
  7. </template>
  8. <template v-else>
  9. <DashboardHeaderBar
  10. :data="headerBar"
  11. :notifications="notifications"
  12. />
  13. <DashboardRegistrationIncomplete v-if="!registrationComplete" />
  14. <DashboardSummaryInfos v-else :data="summaryInfos" />
  15. <DashboardPaymentIncomplete v-if="!hasPaymentMethods" />
  16. <DashboardPendingSchedules
  17. v-if="pendingSchedules.length > 0"
  18. :data="pendingSchedules"
  19. @view-details="openAcceptedDialog"
  20. @cancel="cancelSchedule"
  21. />
  22. <DashboardTodaySchedules v-if="todaySchedules.length > 0" :data="todaySchedules" @rate="openRatingDialog" />
  23. <DashboardScrollAreaSchedules />
  24. <DashboardClientProposals :data="clientProposals" @refresh-data="reloadDashboard" />
  25. <DashboardPendingCustomSchedules v-if="clientProposals.length === 0" />
  26. <DashboardNextSchedules v-if="nextSchedules.length > 0" :data="nextSchedules" @view-details="openNextScheduleDialog" />
  27. <DashboardLastDoneSchedules v-if="lastDoneSchedules.length > 0" :data="lastDoneSchedules" />
  28. <DashboardFavoriteProviders v-if="favoriteProviders.length > 0" :data="favoriteProviders" />
  29. <DashboardProvidersClose v-if="providersClose.length > 0" :data="providersClose" />
  30. </template>
  31. </div>
  32. </template>
  33. <script setup>
  34. import DashboardHeaderBar from 'src/components/dashboard/DashboardHeaderBar.vue';
  35. import DashboardSummaryInfos from 'src/components/dashboard/DashboardSummaryInfos.vue';
  36. import DashboardRegistrationIncomplete from 'src/components/dashboard/DashboardRegistrationIncomplete.vue';
  37. import DashboardPaymentIncomplete from 'src/components/dashboard/DashboardPaymentIncomplete.vue';
  38. import DashboardPendingSchedules from 'src/components/dashboard/DashboardPendingSchedules.vue';
  39. import ScheduleAcceptedDialog from 'src/components/dashboard/ScheduleAcceptedDialog.vue';
  40. import DashboardScrollAreaSchedules from 'src/components/dashboard/DashboardScrollAreaSchedules.vue';
  41. import DashboardNextSchedules from 'src/components/dashboard/DashboardNextSchedules.vue';
  42. import DashboardLastDoneSchedules from 'src/components/dashboard/DashboardLastDoneSchedules.vue';
  43. import DashboardFavoriteProviders from 'src/components/dashboard/DashboardFavoriteProviders.vue';
  44. import DashboardProvidersClose from 'src/components/dashboard/DashboardProvidersClose.vue';
  45. import DashboardTodaySchedules from 'src/components/dashboard/DashboardTodaySchedules.vue';
  46. import FinalSuccesModal from '../schedules/components/FinalSuccesModal.vue';
  47. import DashboardPendingCustomSchedules from 'src/pages/dashboard/components/DashboardPendingCustomSchedules.vue';
  48. import DashboardClientProposals from 'src/pages/dashboard/components/DashboardClientProposals.vue';
  49. import { useRouter } from 'vue-router'
  50. import { onMounted, ref, computed } from 'vue';
  51. import { useDialogPluginComponent, useQuasar } from 'quasar';
  52. import { dadosDashboard } from 'src/api/dashboard';
  53. import { userStore } from 'src/stores/user';
  54. import ScheduleCancelDialog from 'src/components/dashboard/ScheduleCancelDialog.vue';
  55. import NextSchedulesDetailsDialog from 'src/components/dashboard/NextSchedulesDetailsDialog.vue';
  56. import ScheduleRatingDialog from 'src/components/dashboard/ScheduleRatingDialog.vue';
  57. const router = useRouter()
  58. const $q = useQuasar();
  59. const store = userStore();
  60. const { onDialogOK } = useDialogPluginComponent();
  61. const hasPaymentMethods = ref(true);
  62. const headerBar = ref({});
  63. const summaryInfos = ref({});
  64. const pendingSchedules = ref([]);
  65. const nextSchedules = ref([]);
  66. const clientProposals = ref([]);
  67. const lastDoneSchedules = ref([]);
  68. const favoriteProviders = ref([]);
  69. const providersClose = ref([]);
  70. const todaySchedules = ref([]);
  71. const notifications = ref([]);
  72. const loading = ref(true);
  73. const showSuccessModal = ref(router.currentRoute.value.fullPath.includes('showSuccessModal') || false);
  74. const registrationComplete = computed(() => store.user?.registration_complete ?? true);
  75. const openAcceptedDialog = (schedule) => {
  76. $q.dialog({
  77. component: ScheduleAcceptedDialog,
  78. componentProps: { schedule }
  79. }).onOk(() => {
  80. reloadDashboard();
  81. });
  82. };
  83. const reloadDashboard = async () => {
  84. loading.value = true;
  85. const response = await dadosDashboard();
  86. if (response) {
  87. headerBar.value = response.headerBar;
  88. summaryInfos.value = response.summaryInfos;
  89. pendingSchedules.value = response.pendingSchedules ?? [];
  90. nextSchedules.value = response.nextSchedules ?? [];
  91. lastDoneSchedules.value = response.lastDoneSchedules ?? [];
  92. favoriteProviders.value = response.favoriteProviders ?? [];
  93. providersClose.value = response.providersClose ?? [];
  94. clientProposals.value = response.schedulesProposals ?? [];
  95. todaySchedules.value = response.todaySchedules ?? [];
  96. notifications.value = response.notifications ?? [];
  97. hasPaymentMethods.value = response.has_payment_methods ?? true;
  98. }
  99. if( showSuccessModal.value == true) {
  100. $q.dialog({
  101. component: FinalSuccesModal
  102. })
  103. showSuccessModal.value = false;
  104. router.replace({ path: router.currentRoute.value.path, query: {} });
  105. }
  106. loading.value = false;
  107. };
  108. const openNextScheduleDialog = (schedule) => {
  109. $q.dialog({
  110. component: NextSchedulesDetailsDialog,
  111. componentProps: { schedule }
  112. }).onOk(() => {
  113. reloadDashboard();
  114. });
  115. };
  116. const cancelSchedule = (schedule) => {
  117. console.log(schedule)
  118. $q.dialog({
  119. component: ScheduleCancelDialog,
  120. componentProps: { schedule: schedule }
  121. }).onDismiss(() => {
  122. onDialogOK(reloadDashboard());
  123. })
  124. }
  125. const openRatingDialog = (schedule) => {
  126. $q.dialog({
  127. component: ScheduleRatingDialog,
  128. componentProps: { schedule }
  129. }).onOk(() => {
  130. reloadDashboard()
  131. })
  132. }
  133. onMounted(async () => {
  134. await reloadDashboard();
  135. });
  136. </script>
  137. <style scoped>
  138. .dashboard-page {
  139. width: 100%;
  140. min-height: 100%;
  141. box-sizing: border-box;
  142. }
  143. </style>