Skip to content

Commit

Permalink
- Suppression references au session storage
Browse files Browse the repository at this point in the history
- Reparation Navbar
- Corrections multiples
- Suppression console.log
  • Loading branch information
jvk88511334 committed Jul 8, 2024
1 parent 469756c commit 511c9be
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 40 deletions.
2 changes: 0 additions & 2 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ const backendErrorMessage = ref('')
const backendErrorDescription = ref('')
const drawer = ref(false)
const theme = useTheme()
function setBackendError(error) {
backendError.value = true
let titleMessage = ''
Expand Down
1 change: 0 additions & 1 deletion src/components/MenuDownloadFile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ onMounted(() => {
function downloadFile(filePrefix, extention) {
demandesService.getFile(props.demande.id, props.demande.type, filePrefix, extention)
.then(response => {
console.log(response.data);
const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
Expand Down
10 changes: 6 additions & 4 deletions src/components/Rcr.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ A<template>
</template>

<script setup>
import idrefService from '@/service/IdrefService';
import { onMounted, ref } from 'vue';
import idrefService from '@/service/IdrefService'
import {onMounted, ref} from 'vue'
import {useAuthStore} from '@/store/authStore'
const listRcr = ref([]);
const authStore = useAuthStore()
const listRcr = ref([])
const rcr = defineModel()
const user = JSON.parse(sessionStorage.getItem('user'));
const user = authStore.getUser
const props = defineProps( {isLoading: { type: Boolean}})
onMounted(() => {
Expand Down
41 changes: 23 additions & 18 deletions src/components/Structure/Navbar.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<template>
<v-navigation-drawer v-if="authenticated && drawer" width="18em" temporary>
<v-navigation-drawer v-if="authStore.isAuthenticated && drawer" width="18em" temporary>
<v-list-item three-line>
<v-list-item>
<v-list-item-title class="text-h6 text-wrap">
<p>{{ rights.title }}</p>
</v-list-item-title>
<v-list-item-subtitle class="text-wrap">
<p>{{ rights.message }}</p>
<p>{{ rights.message }}</p>
</v-list-item-subtitle>
</v-list-item>
</v-list-item>
Expand Down Expand Up @@ -108,23 +108,22 @@
</template>

<script setup>
import {ref, computed, onMounted} from 'vue'
import router from '@/router'
import { computed } from 'vue'
import { useRouter } from 'vue-router'
import { useTheme } from 'vuetify'
import { useAuthStore } from '@/store/authStore'
defineProps({
const props = defineProps({
drawer: {
type: Boolean,
required: true,
},
})
const authenticated = computed(() => {
const user = JSON.parse(sessionStorage.getItem('user'))
return !!user;
})
const router = useRouter()
const theme = useTheme()
const authStore = useAuthStore()
const emit = defineEmits(['close'])
function navigateTo(routeName) {
Expand All @@ -138,19 +137,25 @@ function toggleTheme() {
}
const rights = computed(() => {
const user = JSON.parse(sessionStorage.getItem('user'))
if(user.role === 'ADMIN'){
rights.title = `Manager ${user.login}`
rights.message = `ILN ${user.iln} : Vous disposez des
const user = authStore.getUser
if (!user) return { title: '', message: '' }
if (user.role === 'ADMIN') {
return {
title: `Manager ${user.login}`,
message: `ILN ${user.iln} : Vous disposez des
permissions administrateur`
}
}
if(user.role === 'USER'){
rights.title = `Utilisateur ${user.login}`
rights.message = `Vous êtes habilité à intervenir
if (user.role === 'USER') {
return {
title: `Utilisateur ${user.login}`,
message: `Vous êtes habilité à intervenir
sur les exemplaires des RCR
de l'ILN ${user.iln}`
}
}
return rights
return { title: '', message: '' }
})
</script>
Expand Down
3 changes: 2 additions & 1 deletion src/service/DemandesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ export class DemandesService {
email: response.data.email
};
const token = `Bearer ${response.data.accessToken}`
this.client.defaults.headers.common.Authorization = `Bearer ${response.data.accessToken}`;
this.client.defaults.headers.common.Authorization = `Bearer ${response.data.accessToken}`
userData.token = token
const authStore = useAuthStore()
authStore.login(userData, token)
return userData;
Expand Down
3 changes: 3 additions & 0 deletions src/store/authStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export const useAuthStore = defineStore('auth', {
},
setToken(token) {
this.token = token;
},
setUser(user){
this.user = user;
}
},
persist: true // This will persist the store to localStorage
Expand Down
3 changes: 0 additions & 3 deletions src/views/Exemplarisation/ExempTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,6 @@ async function archiverDemande(item) {
}
function onRowClick(item) {
console.log('Ligne cliquée avec la demande :', item.id);
// Faites quelque chose lorsque la ligne est cliquée, par exemple naviguer vers une page de détails de la demande
if (item.etatDemande === 'En préparation' || item.etatDemande === 'A compléter' || item.etatDemande === 'En simulation') {
router.push('/exemplarisation/' + item.id);
}
Expand Down
1 change: 0 additions & 1 deletion src/views/Modification/ModifSteps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ onMounted(() => {
if (props.id) {
demandesService.getDemande(props.id, "MODIF")
.then(response => {
console.log(response.data);
demande.value = response.data;
switch (demande.value.etatDemande) {
case 'En préparation':
Expand Down
2 changes: 0 additions & 2 deletions src/views/Modification/ModifTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,6 @@ async function archiverDemande(item) {
}
function onRowClick(item) {
console.log('Ligne cliquée avec la demande :', item);
// Faites quelque chose lorsque la ligne est cliquée, par exemple naviguer vers une page de détails de la demande
if (item.etatDemande === 'En préparation' || item.etatDemande === 'Préparée' || item.etatDemande === 'A compléter' || item.etatDemande === 'En simulation') {
router.push('/modification/' + item.id);
}
Expand Down
4 changes: 0 additions & 4 deletions src/views/Recouvrement/RecouvTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,9 @@ async function archiverDemande(item) {
}
function onRowClick(item) {
console.log('Ligne cliquée avec la demande :', item.id);
if (item.etatDemande === 'En préparation') {
router.push('/recouvrement/' + item.id);
}
// Faites quelque chose lorsque la ligne est cliquée, par exemple naviguer vers une page de détails de la demande
}
function saveAction() {
Expand Down
3 changes: 1 addition & 2 deletions src/views/Utilisateur/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
></v-text-field>

<v-btn class="mb-8" color="blue" size="large" variant="tonal" block @click="login()">Se connecter</v-btn>
<v-btn @click="redirect()">TEst</v-btn>
</v-card>
</div>
</v-col>
Expand Down Expand Up @@ -78,7 +77,7 @@ const visible = ref(false)
async function login() {
try {
const utilisateur = await service.login(userLogin.value, userPassword.value)
authStore.login(utilisateur)
authStore.login(utilisateur, utilisateur.token)
const user = authStore.user
emit('backendSuccess')
if (user && user.email) {
Expand Down
6 changes: 4 additions & 2 deletions src/views/Utilisateur/ModificationEmail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
import Email from '@/components/Email.vue';
import { ref } from 'vue';
import router from '@/router';
import {useAuthStore} from '@/store/authStore'
const user = ref(JSON.parse(sessionStorage.getItem('user')));
const authStore = useAuthStore()
const user = authStore.getUser
function setEmailUser(email){
user.value.email = email;
sessionStorage.setItem('user',JSON.stringify(user.value));
authStore.set
router.push('Accueil');
}
</script>

0 comments on commit 511c9be

Please sign in to comment.