Skip to content

Fix notifications page #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.0
php-version: 8.1
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite
tools: composer:v2
coverage: none
Expand Down
3 changes: 2 additions & 1 deletion app/Http/Livewire/NotificationIndicator.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Http\Livewire;

use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;

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

public function render()
public function render(): View
{
$this->hasNotification = $this->setHasNotification(
Auth::user()->unreadNotifications()->count(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@

use App\Policies\NotificationPolicy;
use Carbon\Carbon;
use Filament\Notifications\Notification;
use Illuminate\Contracts\View\View;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Notifications\DatabaseNotification;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;

class Notifications extends Component
class NotificationsPage extends Component
{
use AuthorizesRequests;

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

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

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

public function render(): View
{
return view('livewire.notifications', [
return view('livewire.notifications-page', [
'notifications' => Auth::user()
->unreadNotifications()
->take(10)
Expand Down
12 changes: 7 additions & 5 deletions app/Http/Livewire/Reactions.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Contracts\ReactableInterface;
use App\Models\Reaction;
use Filament\Notifications\Notification;
use Illuminate\Contracts\View\View;
use Illuminate\Support\Facades\Auth;
use Livewire\Component;
Expand All @@ -21,11 +22,12 @@ class Reactions extends Component
public function userReacted(string $reaction): void
{
if (Auth::guest()) {
// @ToDo mettre un nouveau system de notification
// $this->notification()->error(
// 'Oh Oh! Erreur',
// 'Vous devez être connecté pour réagir à ce contenu!'
// );
Notification::make()
->title(__('Oh Oh! Erreur'))
->body(__('Vous devez être connecté pour réagir à ce contenu!'))
->danger()
->duration(5000)
->send();
} else {
/** @var Reaction $react */
$react = Reaction::query()->where('name', $reaction)->first();
Expand Down
Loading