diff --git a/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/38969543_extrait-de-louis-sullivan-form-follow-function.-de-la-tour-de-bureaux-artistiquement-consideree.pdf.txt b/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/38969543_extrait-de-louis-sullivan-form-follow-function.-de-la-tour-de-bureaux-artistiquement-consideree.pdf.txt index cb27a3c..803203f 100644 --- a/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/38969543_extrait-de-louis-sullivan-form-follow-function.-de-la-tour-de-bureaux-artistiquement-consideree.pdf.txt +++ b/public/content/projects/1_miss-dior-blooming-bouquet/1_client-brief/38969543_extrait-de-louis-sullivan-form-follow-function.-de-la-tour-de-bureaux-artistiquement-consideree.pdf.txt @@ -6,4 +6,31 @@ Uuid: s0lNtRA0Z7ybTCWG ---- -Template: document \ No newline at end of file +Template: document + +---- + +Comments: + +m2vpa4tb: + page: + uri: > + projects/miss-dior-blooming-bouquet/client-brief + title: Brief client + file: + uuid: file://s0lNtRA0Z7ybTCWG + pageIndex: 1 + replies: [ ] + text: test + user: + name: Utilisateur Dior + email: utilisateur@dior.com + uuid: user://HfuumN8s + role: client + date: 2024-10-30T10:54:49+01:00 + id: m2vpa4tb + type: comment + isRead: false + position: + x: null + y: null \ No newline at end of file diff --git a/public/site/plugins/comments/routes/create.php b/public/site/plugins/comments/routes/create.php index 6059ca9..4449822 100644 --- a/public/site/plugins/comments/routes/create.php +++ b/public/site/plugins/comments/routes/create.php @@ -40,7 +40,7 @@ return [ 'comments' => $comments ]); - $user->sendNotification('comments', $newComment->toArray()); + $user->sendNotification('comments', $newComment); return getFileData($newFile); } diff --git a/public/site/plugins/comments/src/BaseComment.php b/public/site/plugins/comments/src/BaseComment.php index 6b5d6d7..9b2f976 100644 --- a/public/site/plugins/comments/src/BaseComment.php +++ b/public/site/plugins/comments/src/BaseComment.php @@ -13,6 +13,7 @@ class BaseComment { protected $date; protected $id; protected $type; + protected $isRead; public function __construct($data) { $page = $data['page']; @@ -44,6 +45,7 @@ class BaseComment { $this->date = $date; $this->id = $id; $this->type = $type; + $this->isRead = false; } public function page() { @@ -78,6 +80,20 @@ class BaseComment { return $this->type; } + public function isRead() { + return $this->isRead; + } + + public function read() { + $this->isRead = true; + return $this->isRead; + } + + public function unread() { + $this->isRead = false; + return $this->isRead; + } + public function toArray() { return [ 'page' => $this->page, @@ -88,6 +104,7 @@ class BaseComment { 'date' => $this->date, 'id' => $this->id, 'type' => $this->type, + 'isRead' => $this->isRead ]; } } diff --git a/public/site/plugins/notifications/index.php b/public/site/plugins/notifications/index.php index acfa800..10130ae 100644 --- a/public/site/plugins/notifications/index.php +++ b/public/site/plugins/notifications/index.php @@ -3,5 +3,8 @@ Kirby::plugin('adrienpayet/pdc-notifications', [ 'routes' => [ require(__DIR__ . '/routes/mark-as-read.php'), + ], + 'userMethods' => [ + 'sendNotification' => require(__DIR__ . '/user-methods/send.php') ] ]); diff --git a/public/site/plugins/notifications/user-methods/send.php b/public/site/plugins/notifications/user-methods/send.php index dbf9f04..d10eb31 100644 --- a/public/site/plugins/notifications/user-methods/send.php +++ b/public/site/plugins/notifications/user-methods/send.php @@ -1,6 +1,6 @@ users()->not($this) as $otherUser) { try { $notifications = $otherUser->notifications()->isNotEmpty() @@ -10,11 +10,8 @@ return function ($group, $data) { if (!isset($notifications[$group])) { $notifications[$group] = []; } - - $data['isRead'] = false; - - $notifications[$group][$data['id']] = $data; + $notifications[$group][$item->id()] = $item->toArray(); $otherUser->update([ 'notifications' => $notifications diff --git a/src/stores/user.js b/src/stores/user.js index 706f3ca..cb62ef4 100644 --- a/src/stores/user.js +++ b/src/stores/user.js @@ -1,8 +1,12 @@ import { defineStore } from "pinia"; -import { ref } from "vue"; +import { ref, computed } from "vue"; export const useUserStore = defineStore("user", () => { const user = ref(null); - return { user }; + const notifications = computed(() => { + return user.value.notifications; + }); + + return { user, notifications }; }); diff --git a/src/views/Notifications.vue b/src/views/Notifications.vue index 09bd53e..cc132bb 100644 --- a/src/views/Notifications.vue +++ b/src/views/Notifications.vue @@ -2,12 +2,15 @@

Status

-
{ return [ @@ -129,18 +132,16 @@ const tabs = computed(() => { ]; }); -const comments = user?.notifications?.comments - ? Object.values(user.notifications.comments) - : []; - -const notifications = [...comments]; +const allNotifications = computed(() => { + return Object.values(notifications.value); +}); function changeTab(newValue) { currentTab.value = newValue; } const isEmpty = computed(() => { - return comments.length === 0; + return notifications.value.length === 0; });