|
|
@@ -5,36 +5,51 @@
|
|
|
<q-spinner-dots color="primary" />
|
|
|
</div>
|
|
|
</template>
|
|
|
+
|
|
|
<template v-else>
|
|
|
<q-pull-to-refresh color="primary" @refresh="onRefresh">
|
|
|
<DashboardHeaderBar
|
|
|
:data="headerBar"
|
|
|
:notifications="notifications"
|
|
|
/>
|
|
|
+
|
|
|
<DashboardRegistrationIncomplete v-if="!registrationComplete" />
|
|
|
+
|
|
|
<DashboardSummaryInfos v-else :data="summaryInfos" />
|
|
|
+
|
|
|
<DashboardPaymentIncomplete v-if="showPaymentBanner" />
|
|
|
+
|
|
|
<AddressIncompleteBanner v-if="!hasLocation" @resolved="reloadDashboard" />
|
|
|
+
|
|
|
<DashboardPendingCustomSchedules v-if="customSchedulesNoProposals.length > 0" />
|
|
|
+
|
|
|
<DashboardClientProposals v-if="clientProposals.length > 0" :data="clientProposals" @refresh-data="reloadDashboard" />
|
|
|
+
|
|
|
<DashboardPendingSchedules
|
|
|
v-if="pendingServicePackages.length > 0"
|
|
|
+ progress-class="progress-fill--urgent"
|
|
|
:data="pendingServicePackages"
|
|
|
:type="'servicePackage'"
|
|
|
- progress-class="progress-fill--urgent"
|
|
|
@view-details="openServicePackagePaymentDialog"
|
|
|
/>
|
|
|
+
|
|
|
<DashboardPendingSchedules
|
|
|
v-if="pendingRequests.length > 0"
|
|
|
- :data="pendingRequests"
|
|
|
progress-class="progress-fill--loop"
|
|
|
+ :data="pendingRequests"
|
|
|
@cancel="openCancelRequestDialog"
|
|
|
/>
|
|
|
+
|
|
|
<DashboardTodaySchedules v-if="todaySchedules.length > 0" :data="todaySchedules" @rate="openRatingDialog" />
|
|
|
+
|
|
|
<DashboardScrollAreaSchedules />
|
|
|
+
|
|
|
<DashboardNextSchedules v-if="nextSchedules.length > 0" :data="nextSchedules" @view-details="openNextScheduleDialog" />
|
|
|
+
|
|
|
<DashboardLastDoneSchedules v-if="lastDoneSchedules.length > 0" :data="lastDoneSchedules" />
|
|
|
+
|
|
|
<DashboardFavoriteProviders v-if="favoriteProviders.length > 0" :data="favoriteProviders" />
|
|
|
+
|
|
|
<DashboardProvidersClose v-if="hasLocation" :data="providersClose" />
|
|
|
</q-pull-to-refresh>
|
|
|
</template>
|
|
|
@@ -42,62 +57,85 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
+import { computed, onMounted, ref } from 'vue';
|
|
|
+import { dadosDashboard } from 'src/api/dashboard';
|
|
|
+import { LocalStorage, useQuasar } from 'quasar';
|
|
|
+import { updateMe } from 'src/api/user';
|
|
|
+import { useI18n } from 'vue-i18n';
|
|
|
+import { usePaymentStore } from 'src/stores/payment';
|
|
|
+import { useRoute, useRouter } from 'vue-router'
|
|
|
+import { userStore } from 'src/stores/user';
|
|
|
+
|
|
|
+import AddressIncompleteBanner from 'src/components/shared/AddressIncompleteBanner.vue';
|
|
|
+import DashboardClientProposals from 'src/pages/dashboard/components/DashboardClientProposals.vue';
|
|
|
+import DashboardFavoriteProviders from 'src/components/dashboard/DashboardFavoriteProviders.vue';
|
|
|
import DashboardHeaderBar from 'src/components/dashboard/DashboardHeaderBar.vue';
|
|
|
-import DashboardSummaryInfos from 'src/components/dashboard/DashboardSummaryInfos.vue';
|
|
|
-import DashboardRegistrationIncomplete from 'src/components/dashboard/DashboardRegistrationIncomplete.vue';
|
|
|
+import DashboardLastDoneSchedules from 'src/components/dashboard/DashboardLastDoneSchedules.vue';
|
|
|
+import DashboardNextSchedules from 'src/components/dashboard/DashboardNextSchedules.vue';
|
|
|
import DashboardPaymentIncomplete from 'src/components/dashboard/DashboardPaymentIncomplete.vue';
|
|
|
+import DashboardPendingCustomSchedules from 'src/pages/dashboard/components/DashboardPendingCustomSchedules.vue';
|
|
|
import DashboardPendingSchedules from 'src/components/dashboard/DashboardPendingSchedules.vue';
|
|
|
-import ScheduleAcceptedDialog from 'src/components/dashboard/ScheduleAcceptedDialog.vue';
|
|
|
-import ScheduleCancelDialog from 'src/components/dashboard/ScheduleCancelDialog.vue';
|
|
|
-import DashboardScrollAreaSchedules from 'src/components/dashboard/DashboardScrollAreaSchedules.vue';
|
|
|
-import DashboardNextSchedules from 'src/components/dashboard/DashboardNextSchedules.vue';
|
|
|
-import DashboardLastDoneSchedules from 'src/components/dashboard/DashboardLastDoneSchedules.vue';
|
|
|
-import DashboardFavoriteProviders from 'src/components/dashboard/DashboardFavoriteProviders.vue';
|
|
|
import DashboardProvidersClose from 'src/components/dashboard/DashboardProvidersClose.vue';
|
|
|
-import AddressIncompleteBanner from 'src/components/shared/AddressIncompleteBanner.vue';
|
|
|
+import DashboardRegistrationIncomplete from 'src/components/dashboard/DashboardRegistrationIncomplete.vue';
|
|
|
+import DashboardScrollAreaSchedules from 'src/components/dashboard/DashboardScrollAreaSchedules.vue';
|
|
|
+import DashboardSummaryInfos from 'src/components/dashboard/DashboardSummaryInfos.vue';
|
|
|
import DashboardTodaySchedules from 'src/components/dashboard/DashboardTodaySchedules.vue';
|
|
|
import FinalSuccesModal from '../schedules/components/FinalSuccesModal.vue';
|
|
|
-import DashboardPendingCustomSchedules from 'src/pages/dashboard/components/DashboardPendingCustomSchedules.vue';
|
|
|
-import DashboardClientProposals from 'src/pages/dashboard/components/DashboardClientProposals.vue';
|
|
|
-import { useRoute, useRouter } from 'vue-router'
|
|
|
-import { onMounted, ref, computed } from 'vue';
|
|
|
-import { useI18n } from 'vue-i18n';
|
|
|
-import { LocalStorage, useQuasar } from 'quasar';
|
|
|
-import { dadosDashboard } from 'src/api/dashboard';
|
|
|
-import { updateMe } from 'src/api/user';
|
|
|
-import { userStore } from 'src/stores/user';
|
|
|
-import NextSchedulesDetailsDialog from 'src/components/dashboard/NextSchedulesDetailsDialog.vue';
|
|
|
-import ScheduleRatingDialog from 'src/components/dashboard/ScheduleRatingDialog.vue';
|
|
|
+import NextSchedulesDetailsDialog from 'src/pages/dashboard/components/schedule/NextSchedulesDetailsDialog.vue';
|
|
|
+import ScheduleAcceptedDialog from 'src/pages/dashboard/components/schedule/ScheduleAcceptedDialog.vue';
|
|
|
+import ScheduleCancelDialog from 'src/pages/dashboard/components/schedule/ScheduleCancelDialog.vue';
|
|
|
+import ScheduleRatingDialog from 'src/pages/dashboard/components/schedule/ScheduleRatingDialog.vue';
|
|
|
|
|
|
-const router = useRouter()
|
|
|
-const route = useRoute()
|
|
|
-const { t } = useI18n();
|
|
|
const $q = useQuasar();
|
|
|
+const paymentStore = usePaymentStore();
|
|
|
+const route = useRoute()
|
|
|
+const router = useRouter()
|
|
|
const store = userStore();
|
|
|
+const { t } = useI18n();
|
|
|
|
|
|
+const clientProposals = ref([]);
|
|
|
+const customSchedulesNoProposals = ref([]);
|
|
|
+const favoriteProviders = ref([]);
|
|
|
+const hasLocation = ref(true);
|
|
|
const hasPaymentMethods = ref(true);
|
|
|
const headerBar = ref({});
|
|
|
-const summaryInfos = ref({});
|
|
|
+const lastDoneSchedules = ref([]);
|
|
|
+const loading = ref(true);
|
|
|
+const nextSchedules = ref([]);
|
|
|
+const notifications = ref([]);
|
|
|
const pendingSchedules = ref([]);
|
|
|
const pendingServicePackages = ref([]);
|
|
|
-const nextSchedules = ref([]);
|
|
|
-const clientProposals = ref([]);
|
|
|
-const customSchedulesNoProposals = ref([]);
|
|
|
-const lastDoneSchedules = ref([]);
|
|
|
-const favoriteProviders = ref([]);
|
|
|
const providersClose = ref([]);
|
|
|
-const todaySchedules = ref([]);
|
|
|
-const notifications = ref([]);
|
|
|
-const loading = ref(true);
|
|
|
-const registrationComplete = computed(() => store.user?.registration_complete ?? true);
|
|
|
const showPaymentBanner = ref(false);
|
|
|
-const hasLocation = ref(true);
|
|
|
|
|
|
const successModalKey = ref(
|
|
|
route.query.success ??
|
|
|
(router.currentRoute.value.fullPath.includes('showSuccessModal') ? 'custom_schedule' : null),
|
|
|
);
|
|
|
|
|
|
+const summaryInfos = ref({});
|
|
|
+const todaySchedules = ref([]);
|
|
|
+
|
|
|
+const pendingRequests = computed(() => {
|
|
|
+ const seenPackages = new Set();
|
|
|
+
|
|
|
+ return pendingSchedules.value.filter((schedule) => {
|
|
|
+ if (schedule.status !== 'pending') return false;
|
|
|
+
|
|
|
+ if (!schedule.service_package_id) return true;
|
|
|
+
|
|
|
+ if (seenPackages.has(schedule.service_package_id)) return false;
|
|
|
+
|
|
|
+ seenPackages.add(schedule.service_package_id);
|
|
|
+
|
|
|
+ return true;
|
|
|
+ });
|
|
|
+});
|
|
|
+
|
|
|
+const registrationComplete = computed(() => store.user?.registration_complete ?? true);
|
|
|
+
|
|
|
+const AUTO_SHOWN_PACKAGES_KEY = "sp_payment_popup_shown_ids";
|
|
|
+
|
|
|
const successModalContents = {
|
|
|
custom_schedule: null,
|
|
|
order_sent: () => ({
|
|
|
@@ -109,21 +147,27 @@ const successModalContents = {
|
|
|
}),
|
|
|
};
|
|
|
|
|
|
-const pendingRequests = computed(() => {
|
|
|
- const seenPackages = new Set();
|
|
|
+let autoOpeningPackageDialog = false;
|
|
|
|
|
|
- return pendingSchedules.value.filter((schedule) => {
|
|
|
- if (schedule.status !== 'pending') return false;
|
|
|
+const maybeOpenSuccessModal = () => {
|
|
|
+ if (!successModalKey.value) return;
|
|
|
|
|
|
- if (!schedule.service_package_id) return true;
|
|
|
+ if (!(successModalKey.value in successModalContents)) {
|
|
|
+ successModalKey.value = null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
- if (seenPackages.has(schedule.service_package_id)) return false;
|
|
|
+ const buildContent = successModalContents[successModalKey.value];
|
|
|
|
|
|
- seenPackages.add(schedule.service_package_id);
|
|
|
+ successModalKey.value = null;
|
|
|
|
|
|
- return true;
|
|
|
+ $q.dialog({
|
|
|
+ component: FinalSuccesModal,
|
|
|
+ componentProps: { content: buildContent ? buildContent() : null },
|
|
|
+ }).onDismiss(() => {
|
|
|
+ router.replace({ path: route.path, query: {} });
|
|
|
});
|
|
|
-});
|
|
|
+};
|
|
|
|
|
|
const openCancelRequestDialog = (schedule) => {
|
|
|
$q.dialog({
|
|
|
@@ -135,17 +179,17 @@ const openCancelRequestDialog = (schedule) => {
|
|
|
};
|
|
|
|
|
|
const openServicePackagePaymentDialog = (servicePackage) => {
|
|
|
+ paymentStore.setPackage(servicePackage);
|
|
|
+
|
|
|
$q.dialog({
|
|
|
component: ScheduleAcceptedDialog,
|
|
|
- componentProps: { servicePackage }
|
|
|
}).onOk(() => {
|
|
|
reloadDashboard();
|
|
|
+ }).onDismiss(() => {
|
|
|
+ paymentStore.clearPackage();
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-const AUTO_SHOWN_PACKAGES_KEY = "sp_payment_popup_shown_ids";
|
|
|
-let autoOpeningPackageDialog = false;
|
|
|
-
|
|
|
const maybeAutoOpenServicePackagePayment = () => {
|
|
|
if (autoOpeningPackageDialog) return;
|
|
|
|
|
|
@@ -159,16 +203,17 @@ const maybeAutoOpenServicePackagePayment = () => {
|
|
|
|
|
|
autoOpeningPackageDialog = true;
|
|
|
LocalStorage.set(AUTO_SHOWN_PACKAGES_KEY, [...shownIds, packageToShow.id]);
|
|
|
+ paymentStore.setPackage(packageToShow);
|
|
|
|
|
|
$q.dialog({
|
|
|
component: ScheduleAcceptedDialog,
|
|
|
- componentProps: { servicePackage: packageToShow },
|
|
|
})
|
|
|
.onOk(() => {
|
|
|
reloadDashboard();
|
|
|
})
|
|
|
.onDismiss(() => {
|
|
|
autoOpeningPackageDialog = false;
|
|
|
+ paymentStore.clearPackage();
|
|
|
});
|
|
|
};
|
|
|
|
|
|
@@ -196,26 +241,6 @@ const reloadDashboard = async (showLoader = true) => {
|
|
|
maybeAutoOpenServicePackagePayment();
|
|
|
};
|
|
|
|
|
|
-const maybeOpenSuccessModal = () => {
|
|
|
- if (!successModalKey.value) return;
|
|
|
-
|
|
|
- if (!(successModalKey.value in successModalContents)) {
|
|
|
- successModalKey.value = null;
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- const buildContent = successModalContents[successModalKey.value];
|
|
|
-
|
|
|
- successModalKey.value = null;
|
|
|
-
|
|
|
- $q.dialog({
|
|
|
- component: FinalSuccesModal,
|
|
|
- componentProps: { content: buildContent ? buildContent() : null },
|
|
|
- }).onDismiss(() => {
|
|
|
- router.replace({ path: route.path, query: {} });
|
|
|
- });
|
|
|
-};
|
|
|
-
|
|
|
const onRefresh = async (done) => {
|
|
|
try {
|
|
|
await reloadDashboard(false);
|
|
|
@@ -254,6 +279,7 @@ onMounted(async () => {
|
|
|
store.markFirstAccessSeen();
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style scoped>
|