diff --git a/src/pages/Worker/Card/WorkerNotificationsManager.vue b/src/pages/Worker/Card/WorkerNotificationsManager.vue
index f83223749..03948318e 100644
--- a/src/pages/Worker/Card/WorkerNotificationsManager.vue
+++ b/src/pages/Worker/Card/WorkerNotificationsManager.vue
@@ -5,6 +5,8 @@ import { computed, onMounted, onUpdated, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
+import CrudModel from 'components/CrudModel.vue';
+
const $props = defineProps({
id: {
type: Number,
@@ -14,75 +16,60 @@ const $props = defineProps({
});
const entityId = computed(() => $props.id || route.params.id);
-onMounted(() => fetch());
onUpdated(() => console.log('updated'));
const route = useRoute();
const { t } = useI18n();
const quasar = useQuasar();
-const notifications = ref([]);
-
-async function fetch() {
- try {
- await axios
- .get(`NotificationSubscriptions/${entityId.value}/getList`)
- .then(async (res) => {
- if (res.data) {
- notifications.value = res.data;
- }
- });
- } catch (e) {
- //
- }
-}
-
-async function disableNotification(notification) {
- await axios
- .delete(`NotificationSubscriptions/${notification.id}`)
- .catch(() => (notification.active = true))
- .then((res) => {
- if (res.data) {
- notification.id = null;
- notification.active = false;
- quasar.notify({
- type: 'positive',
- message: t('worker.notificationsManager.unsubscribed'),
- });
- }
- });
-}
-
async function toggleNotification(notification) {
- if (!notification.active) {
- await disableNotification(notification);
- } else {
- await axios
- .post(`NotificationSubscriptions`, {
- notificationFk: notification.notificationFk,
- userFk: entityId.value,
- })
- .catch(() => (notification.active = false))
- .then((res) => {
- if (res.data) {
- notification.id = res.data.id;
- quasar.notify({
- type: 'positive',
- message: t('worker.notificationsManager.subscribed'),
- });
- }
- });
+ if (notification.active) {
+ await axios.delete(`NotificationSubscriptions/${notification.id}`);
+ notification.id = null;
+ notification.active = false;
+ return quasar.notify({
+ type: 'positive',
+ message: t('worker.notificationsManager.unsubscribed'),
+ });
}
+
+ const { data } = await axios.post(`NotificationSubscriptions`, {
+ notificationFk: notification.notificationFk,
+ userFk: entityId.value,
+ });
+
+ notification.id = data.id;
+ quasar.notify({
+ type: 'positive',
+ message: t('worker.notificationsManager.subscribed'),
+ });
}
+
-
+
-
-
-
- {{ row }}
-
+
+
+
+
+
+
+
+ {{ row.name }}
+ {{ row.description }}
+
+
@@ -151,3 +138,11 @@ async function toggleNotification(notification) {
-->
+
+