Skip to content

Commit

Permalink
Merge pull request #25 from HE-Arc/17-notifications
Browse files Browse the repository at this point in the history
17 notifications
  • Loading branch information
katsulon authored Dec 12, 2024
2 parents 4410349 + affd846 commit 9a9152f
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 30 deletions.
2 changes: 1 addition & 1 deletion timeliner/app/Http/Controllers/TimelineController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function show($id)
}

return redirect()->route('timeline.index')
->with('success',"You don't have access.");
->withErrors(["You don't have access."]);
}

public function create()
Expand Down
26 changes: 26 additions & 0 deletions timeliner/app/View/Components/Notification.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

namespace App\View\Components;

use Closure;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;

class Notification extends Component
{
/**
* Create a new component instance.
*/
public function __construct()
{
//
}

/**
* Get the view / contents that represent the component.
*/
public function render(): View|Closure|string
{
return view('components.notification');
}
}
2 changes: 1 addition & 1 deletion timeliner/resources/js/formfunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function toggleElementById(id) {
}

function confirmDelete() {
return confirm('Are you sure you want to delete this?');
return confirm('Are you sure you want to delete this? This action cannot be undone.');
}

document.addEventListener('DOMContentLoaded', () => {
Expand Down
16 changes: 16 additions & 0 deletions timeliner/resources/views/components/notification.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Notification -->
@if (session('success'))
<div class="alert alert-success">
{{ session('success') }}
</div>
@elseif (session('info'))
<div class="alert alert-info">
{{ session('info') }}
</div>
@elseif($errors->any())
<div class="alert alert-danger">
@foreach ($errors->all() as $error)
<div>{{ $error }}</div>
@endforeach
</div>
@endif
14 changes: 1 addition & 13 deletions timeliner/resources/views/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,7 @@
</h2>
</x-slot>

@if (session('success'))
<div class="alert alert-success">
{{ session('success') }}
</div>
@elseif($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<x-notification/>

<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
Expand Down
2 changes: 1 addition & 1 deletion timeliner/resources/views/layouts/app.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</div>
</header>
@endisset

<main>
{{ $slot }}
</main>
Expand Down
14 changes: 1 addition & 13 deletions timeliner/resources/views/timeline/timeline.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,7 @@
</h2>
</x-slot>

@if (session('success'))
<div class="alert alert-success">
{{ session('success') }}
</div>
@elseif($errors->any())
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<x-notification/>

<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
Expand Down
5 changes: 4 additions & 1 deletion timeliner/routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@
require __DIR__.'/auth.php';

Route::resource('timeline', TimelineController::class);
Route::resource('comment', CommentController::class)->only(['store', 'destroy', 'update']);

Route::post('comment', [CommentController::class, 'store'])->name('comment.store');
Route::delete('comment/{comment}', [CommentController::class, 'destroy'])->name('comment.destroy');
Route::put('comment/{comment}', [CommentController::class, 'update'])->name('comment.update');

0 comments on commit 9a9152f

Please sign in to comment.