pulisce etichette di prova e gestisce la compilazione del profilo utente
All checks were successful
Build and Publish / build (push) Successful in 2m59s
All checks were successful
Build and Publish / build (push) Successful in 2m59s
This commit is contained in:
@@ -9,7 +9,7 @@ export default defineComponent({
|
|||||||
const { showLogin } = useLoginModal();
|
const { showLogin } = useLoginModal();
|
||||||
const authenticated = inject<ComputedRef<boolean>>('authenticated');
|
const authenticated = inject<ComputedRef<boolean>>('authenticated');
|
||||||
const username = inject<ComputedRef<string>>('currentUsername');
|
const username = inject<ComputedRef<string>>('currentUsername');
|
||||||
const utenteAppService = inject<UtenteAppService>('utenteAppService', () => new UtenteAppService());
|
const utenteAppService = inject<UtenteAppService>('utenteAppService', () => new UtenteAppService(), true);
|
||||||
|
|
||||||
const profileIncomplete: Ref<boolean> = ref(false);
|
const profileIncomplete: Ref<boolean> = ref(false);
|
||||||
const checkingProfile: Ref<boolean> = ref(false);
|
const checkingProfile: Ref<boolean> = ref(false);
|
||||||
@@ -23,7 +23,7 @@ export default defineComponent({
|
|||||||
try {
|
try {
|
||||||
checkingProfile.value = true;
|
checkingProfile.value = true;
|
||||||
const utenteApp = await utenteAppService.getCurrentUser();
|
const utenteApp = await utenteAppService.getCurrentUser();
|
||||||
|
console.log('utenteApp', utenteApp);
|
||||||
// Check if essential profile fields are missing
|
// Check if essential profile fields are missing
|
||||||
if (
|
if (
|
||||||
!utenteApp ||
|
!utenteApp ||
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { type Ref, computed, defineComponent, inject, onMounted, ref, watch } from 'vue';
|
import { type ComputedRef, type Ref, computed, defineComponent, inject, onMounted, ref, watch } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
import { useAlertService } from '@/shared/alert/alert.service';
|
import { useAlertService } from '@/shared/alert/alert.service';
|
||||||
@@ -12,6 +12,14 @@ import { useAccountStore } from '@/shared/config/store/account-store';
|
|||||||
import ConfermaService from '../conferma/conferma.service';
|
import ConfermaService from '../conferma/conferma.service';
|
||||||
import PrenotazioneService from './prenotazione.service';
|
import PrenotazioneService from './prenotazione.service';
|
||||||
|
|
||||||
|
import UtenteAppService from '@/entities/utente-app/utente-app.service';
|
||||||
|
import account from '@/router/account.ts';
|
||||||
|
import type { IUtenteApp } from '@/shared/model/utente-app.model.ts';
|
||||||
|
|
||||||
|
import axios from 'axios';
|
||||||
|
|
||||||
|
const baseApiUrl = 'api/utente-apps';
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: 'Prenotazione',
|
name: 'Prenotazione',
|
||||||
setup() {
|
setup() {
|
||||||
@@ -22,6 +30,9 @@ export default defineComponent({
|
|||||||
const alertService = inject('alertService', () => useAlertService(), true);
|
const alertService = inject('alertService', () => useAlertService(), true);
|
||||||
const accountStore = useAccountStore();
|
const accountStore = useAccountStore();
|
||||||
|
|
||||||
|
const authenticated = inject<ComputedRef<boolean>>('authenticated');
|
||||||
|
const utenteAppService = inject<UtenteAppService>('utenteAppService', () => new UtenteAppService(), true);
|
||||||
|
|
||||||
const itemsPerPage = ref(20);
|
const itemsPerPage = ref(20);
|
||||||
const queryCount: Ref<number> = ref(null);
|
const queryCount: Ref<number> = ref(null);
|
||||||
const page: Ref<number> = ref(1);
|
const page: Ref<number> = ref(1);
|
||||||
@@ -49,6 +60,57 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
const isSubmittingConferma = ref(false);
|
const isSubmittingConferma = ref(false);
|
||||||
|
|
||||||
|
// CONTROLLIAMO SE L'UTENTE HA UN PROFILO IMPOSTATO+
|
||||||
|
const profileIncomplete: Ref<boolean> = ref(false);
|
||||||
|
const checkingProfile: Ref<boolean> = ref(false);
|
||||||
|
|
||||||
|
const getCurrentUser = async () => {
|
||||||
|
return new Promise<IUtenteApp>((resolve, reject) => {
|
||||||
|
axios
|
||||||
|
.get(`${baseApiUrl}/current`)
|
||||||
|
.then(res => {
|
||||||
|
resolve(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const checkProfileCompletion = async () => {
|
||||||
|
if (!authenticated.value) {
|
||||||
|
profileIncomplete.value = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
checkingProfile.value = true;
|
||||||
|
const utenteApp = await getCurrentUser();
|
||||||
|
// Check if essential profile fields are missing
|
||||||
|
if (
|
||||||
|
!utenteApp ||
|
||||||
|
!utenteApp.nome ||
|
||||||
|
!utenteApp.cognome ||
|
||||||
|
!utenteApp.dataNascita ||
|
||||||
|
!utenteApp.luogoNascita ||
|
||||||
|
!utenteApp.residente ||
|
||||||
|
!utenteApp.telefono
|
||||||
|
) {
|
||||||
|
profileIncomplete.value = true;
|
||||||
|
} else {
|
||||||
|
console.log('Profile is complete');
|
||||||
|
profileIncomplete.value = false;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
// If UtenteApp doesn't exist, profile is incomplete
|
||||||
|
profileIncomplete.value = true;
|
||||||
|
} finally {
|
||||||
|
checkingProfile.value = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// CHIUDIAMO IL CONTROLLO DEL PROFILO IMPOSTATO
|
||||||
|
|
||||||
const clear = () => {
|
const clear = () => {
|
||||||
page.value = 1;
|
page.value = 1;
|
||||||
};
|
};
|
||||||
@@ -86,6 +148,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await retrievePrenotaziones();
|
await retrievePrenotaziones();
|
||||||
|
await checkProfileCompletion();
|
||||||
});
|
});
|
||||||
|
|
||||||
const removeId: Ref<number> = ref(null);
|
const removeId: Ref<number> = ref(null);
|
||||||
@@ -162,6 +225,10 @@ export default defineComponent({
|
|||||||
await retrievePrenotaziones();
|
await retrievePrenotaziones();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(page, async () => {
|
||||||
|
await checkProfileCompletion();
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
prenotaziones,
|
prenotaziones,
|
||||||
handleSyncList,
|
handleSyncList,
|
||||||
@@ -182,6 +249,10 @@ export default defineComponent({
|
|||||||
totalItems,
|
totalItems,
|
||||||
changeOrder,
|
changeOrder,
|
||||||
t$,
|
t$,
|
||||||
|
authenticated,
|
||||||
|
profileIncomplete,
|
||||||
|
checkingProfile,
|
||||||
|
checkProfileCompletion,
|
||||||
// Role-based
|
// Role-based
|
||||||
isIncaricato,
|
isIncaricato,
|
||||||
prenotazioniPendenti,
|
prenotazioniPendenti,
|
||||||
|
|||||||
@@ -2,6 +2,13 @@
|
|||||||
<div>
|
<div>
|
||||||
<!-- ============================= ROLE_USER VIEW ============================= -->
|
<!-- ============================= ROLE_USER VIEW ============================= -->
|
||||||
<template v-if="!isIncaricato">
|
<template v-if="!isIncaricato">
|
||||||
|
<div class="alert alert-warning" v-if="authenticated && profileIncomplete && !checkingProfile">
|
||||||
|
<span>{{ t$('home.profile.incomplete.message') }}</span>
|
||||||
|
<div>
|
||||||
|
<router-link class="alert-link" to="/account/profile">{{ t$('home.profile.incomplete.link') }}</router-link>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div v-if="authenticated && !profileIncomplete && !checkingProfile">
|
||||||
<h2 id="page-heading" data-cy="PrenotazioneHeading">
|
<h2 id="page-heading" data-cy="PrenotazioneHeading">
|
||||||
<span id="prenotazione">{{ t$('smartbookingApp.prenotazione.home.title') }}</span>
|
<span id="prenotazione">{{ t$('smartbookingApp.prenotazione.home.title') }}</span>
|
||||||
<div class="d-flex justify-content-end">
|
<div class="d-flex justify-content-end">
|
||||||
@@ -150,6 +157,7 @@
|
|||||||
<b-pagination size="md" :total-rows="totalItems" v-model="page" :per-page="itemsPerPage"></b-pagination>
|
<b-pagination size="md" :total-rows="totalItems" v-model="page" :per-page="itemsPerPage"></b-pagination>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- ============================= ROLE_INCARICATO VIEW ============================= -->
|
<!-- ============================= ROLE_INCARICATO VIEW ============================= -->
|
||||||
@@ -211,11 +219,7 @@
|
|||||||
<font-awesome-icon icon="eye"></font-awesome-icon>
|
<font-awesome-icon icon="eye"></font-awesome-icon>
|
||||||
<span class="d-none d-md-inline">{{ t$('entity.action.view') }}</span>
|
<span class="d-none d-md-inline">{{ t$('entity.action.view') }}</span>
|
||||||
</router-link>
|
</router-link>
|
||||||
<button
|
<button class="btn btn-success btn-sm" data-cy="prendiInCaricoButton" @click="prendiInCarico(prenotazione)">
|
||||||
class="btn btn-success btn-sm"
|
|
||||||
data-cy="prendiInCaricoButton"
|
|
||||||
@click="prendiInCarico(prenotazione)"
|
|
||||||
>
|
|
||||||
<font-awesome-icon icon="check"></font-awesome-icon>
|
<font-awesome-icon icon="check"></font-awesome-icon>
|
||||||
<span class="d-none d-md-inline">{{ t$('smartbookingApp.prenotazione.prendiInCarico.button') }}</span>
|
<span class="d-none d-md-inline">{{ t$('smartbookingApp.prenotazione.prendiInCarico.button') }}</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -304,7 +308,11 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- "Prendi in carico" modal -->
|
<!-- "Prendi in carico" modal -->
|
||||||
<b-modal v-model="showPrendiInCaricoModal" :title="t$('smartbookingApp.prenotazione.prendiInCarico.title')" @hidden="closePrendiInCaricoModal">
|
<b-modal
|
||||||
|
v-model="showPrendiInCaricoModal"
|
||||||
|
:title="t$('smartbookingApp.prenotazione.prendiInCarico.title')"
|
||||||
|
@hidden="closePrendiInCaricoModal"
|
||||||
|
>
|
||||||
<div v-if="selectedPrenotazione">
|
<div v-if="selectedPrenotazione">
|
||||||
<p class="text-muted mb-3">
|
<p class="text-muted mb-3">
|
||||||
{{ t$('smartbookingApp.prenotazione.prendiInCarico.subtitle', { id: selectedPrenotazione.id }) }}
|
{{ t$('smartbookingApp.prenotazione.prendiInCarico.subtitle', { id: selectedPrenotazione.id }) }}
|
||||||
|
|||||||
Reference in New Issue
Block a user