0
0
Fork 0

changed the boss or user check to the backend

This commit is contained in:
Pau 2022-12-27 14:25:44 +01:00
parent f98c82185f
commit 3824ea62c9
1 changed files with 18 additions and 15 deletions

View File

@ -3,7 +3,6 @@ import { onMounted, computed, ref, onUpdated } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import { useState } from 'src/composables/useState';
import { useSession } from 'src/composables/useSession';
import axios from 'axios';
@ -22,7 +21,6 @@ const route = useRoute();
const { t } = useI18n();
const { getToken } = useSession();
const quasar = useQuasar();
const state = useState();
const entityId = computed(() => {
return $props.id || route.params.id;
@ -52,7 +50,6 @@ const workerFilter = {
};
const notificationAcls = ref([]);
const allowedEditing = ref(false);
async function fetch() {
const { data } = await axios.get(`Workers/${entityId.value}`, {
@ -170,10 +167,6 @@ async function fetch() {
console.log(e);
}
if (state.getUser().value.id == data.user.id) {
allowedEditing.value = true;
}
worker.value = data;
}
@ -217,13 +210,24 @@ async function toggleNotif(notif, chip) {
message: t('worker.notificationsManager.subscribed'),
});
} else {
await axios.post(`NotificationSubscriptions/deleteSubscription`, {
notificationId: notif.id + '',
userId: entityId.value,
headers: {
Authorization: getToken(),
const token = await getToken();
const tokenUser = await axios.get(`AccessTokens/${token}/user`);
console.log(tokenUser);
await axios.post(
`NotificationSubscriptions/deleteNotification`,
{
userId: entityId.value,
notificationId: notif.id,
authorId: tokenUser.data.id,
},
});
{
headers: {
Authorization: getToken(),
},
}
);
quasar.notify({
type: 'positive',
message: t('worker.notificationsManager.unsubscribed'),
@ -243,7 +247,6 @@ async function toggleNotif(notif, chip) {
<q-item>
<div v-for="notif in notificationAcls" :key="notif.id">
<q-chip
:disable="!allowedEditing"
v-if="notif.active"
:key="notif.id"
:label="notif.name"
@ -272,7 +275,7 @@ async function toggleNotif(notif, chip) {
</q-item-section>
<q-item-section side top>
<q-toggle
:disable="!notif.allowed || !allowedEditing"
:disable="!notif.allowed"
checked-icon="check"
unchecked-icon="close"
indeterminate-icon="block"