Skip to content

Commit 60bc9af

Browse files
authored
Fix notifications page (#82)
* 🎨 Fix ambiguous notifications between filament and livewire app project component * build production assets * 💚 Update ci tests
1 parent 90b460b commit 60bc9af

File tree

16 files changed

+118
-89296
lines changed

16 files changed

+118
-89296
lines changed

.github/workflows/tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ jobs:
1313
- name: Setup PHP
1414
uses: shivammathur/setup-php@v2
1515
with:
16-
php-version: 8.0
16+
php-version: 8.1
1717
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
1818
tools: composer:v2
1919
coverage: none

app/Http/Livewire/NotificationIndicator.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Http\Livewire;
44

5+
use Illuminate\Contracts\View\View;
56
use Illuminate\Support\Facades\Auth;
67
use Livewire\Component;
78

@@ -18,7 +19,7 @@ public function setHasNotification(int $count): bool
1819
return $count > 0;
1920
}
2021

21-
public function render()
22+
public function render(): View
2223
{
2324
$this->hasNotification = $this->setHasNotification(
2425
Auth::user()->unreadNotifications()->count(),

app/Http/Livewire/Notifications.php renamed to app/Http/Livewire/NotificationsPage.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44

55
use App\Policies\NotificationPolicy;
66
use Carbon\Carbon;
7+
use Filament\Notifications\Notification;
78
use Illuminate\Contracts\View\View;
89
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
910
use Illuminate\Notifications\DatabaseNotification;
1011
use Illuminate\Support\Facades\Auth;
1112
use Livewire\Component;
1213

13-
class Notifications extends Component
14+
class NotificationsPage extends Component
1415
{
1516
use AuthorizesRequests;
1617

@@ -36,15 +37,18 @@ public function markAsRead(string $notificationId): void
3637
// @phpstan-ignore-next-line
3738
$this->notification->markAsRead();
3839

39-
// @ToDo mettre un nouveau system de notification
40-
// $this->notification()->success('Notification', 'Cette notification a été marquée comme lue.');
40+
Notification::make()
41+
->title(__('Cette notification a été marquée comme lue.'))
42+
->success()
43+
->seconds(5)
44+
->send();
4145

4246
$this->emit('NotificationMarkedAsRead', Auth::user()->unreadNotifications()->count());
4347
}
4448

4549
public function render(): View
4650
{
47-
return view('livewire.notifications', [
51+
return view('livewire.notifications-page', [
4852
'notifications' => Auth::user()
4953
->unreadNotifications()
5054
->take(10)

app/Http/Livewire/Reactions.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use App\Contracts\ReactableInterface;
66
use App\Models\Reaction;
7+
use Filament\Notifications\Notification;
78
use Illuminate\Contracts\View\View;
89
use Illuminate\Support\Facades\Auth;
910
use Livewire\Component;
@@ -21,11 +22,12 @@ class Reactions extends Component
2122
public function userReacted(string $reaction): void
2223
{
2324
if (Auth::guest()) {
24-
// @ToDo mettre un nouveau system de notification
25-
// $this->notification()->error(
26-
// 'Oh Oh! Erreur',
27-
// 'Vous devez être connecté pour réagir à ce contenu!'
28-
// );
25+
Notification::make()
26+
->title(__('Oh Oh! Erreur'))
27+
->body(__('Vous devez être connecté pour réagir à ce contenu!'))
28+
->danger()
29+
->duration(5000)
30+
->send();
2931
} else {
3032
/** @var Reaction $react */
3133
$react = Reaction::query()->where('name', $reaction)->first();

0 commit comments

Comments
 (0)