diff --git a/app/Architecture/ExceptionHandler.php b/app/Architecture/ExceptionHandler.php
index 746f3e1..c63890d 100644
--- a/app/Architecture/ExceptionHandler.php
+++ b/app/Architecture/ExceptionHandler.php
@@ -5,6 +5,9 @@ declare(strict_types=1);
namespace Toby\Architecture;
use Illuminate\Foundation\Exceptions\Handler;
+use Inertia\Inertia;
+use Symfony\Component\HttpFoundation\Response;
+use Throwable;
class ExceptionHandler extends Handler
{
@@ -13,4 +16,19 @@ class ExceptionHandler extends Handler
"password",
"password_confirmation",
];
+
+ public function render($request, Throwable $e): Response
+ {
+ $response = parent::render($request, $e);
+
+ if (app()->environment("production") && in_array($response->status(), [500, 503, 429, 419, 404, 403, 401], true)) {
+ return Inertia::render("Error", [
+ "status" => $response->status(),
+ ])
+ ->toResponse($request)
+ ->setStatusCode($response->status());
+ }
+
+ return $response;
+ }
}
diff --git a/resources/js/Pages/Error.vue b/resources/js/Pages/Error.vue
new file mode 100644
index 0000000..76bfd45
--- /dev/null
+++ b/resources/js/Pages/Error.vue
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+ {{ error.message }}
+
+
+
+
+ Wróć do strony głównej
+
+
+
+
+
+
+
+
+
diff --git a/resources/js/Shared/Pagination.vue b/resources/js/Shared/Pagination.vue
index 3cd59e6..4e5975c 100644
--- a/resources/js/Shared/Pagination.vue
+++ b/resources/js/Shared/Pagination.vue
@@ -21,11 +21,11 @@
- Wyświetlanie
+ Wyświetlanie od
{{ pagination.from }}
- od
- {{ pagination.to }}
do
+ {{ pagination.to }}
+ z
{{ pagination.total }}
wyników
diff --git a/tests/Feature/MonthlyUsageTest.php b/tests/Feature/MonthlyUsageTest.php
index c11ec5b..ecb3a8a 100644
--- a/tests/Feature/MonthlyUsageTest.php
+++ b/tests/Feature/MonthlyUsageTest.php
@@ -14,7 +14,7 @@ class MonthlyUsageTest extends FeatureTestCase
public function testAdministatorCanSeeVacationsMonthlyUsage(): void
{
- $admin = User::factory()->admin()->createQuietly();
+ $admin = User::factory()->admin()->create();
$this->actingAs($admin)
->get("/vacation/monthly-usage")
@@ -23,7 +23,7 @@ class MonthlyUsageTest extends FeatureTestCase
public function testEmployeeCannotSeeVacationsMonthlyUsage(): void
{
- $user = User::factory()->createQuietly();
+ $user = User::factory()->create();
$this->actingAs($user)
->get("/vacation/monthly-usage")
diff --git a/tests/Feature/VacationCalendarTest.php b/tests/Feature/VacationCalendarTest.php
index 0a8c3a1..c87457a 100644
--- a/tests/Feature/VacationCalendarTest.php
+++ b/tests/Feature/VacationCalendarTest.php
@@ -14,7 +14,7 @@ class VacationCalendarTest extends FeatureTestCase
public function testAdministrativeApproverCanDownloadTimesheet(): void
{
- $administrativeApprover = User::factory()->administrativeApprover()->createQuietly();
+ $administrativeApprover = User::factory()->administrativeApprover()->create();
$this->actingAs($administrativeApprover)
->get("/vacation/timesheet/january")
@@ -23,7 +23,7 @@ class VacationCalendarTest extends FeatureTestCase
public function testEmployeeCannotDownloadTimesheet(): void
{
- $user = User::factory()->createQuietly();
+ $user = User::factory()->create();
$this->actingAs($user)
->get("/vacation/timesheet/january")
diff --git a/tests/Feature/VacationRequestTest.php b/tests/Feature/VacationRequestTest.php
index 3888cb1..2d0514f 100644
--- a/tests/Feature/VacationRequestTest.php
+++ b/tests/Feature/VacationRequestTest.php
@@ -80,7 +80,7 @@ class VacationRequestTest extends FeatureTestCase
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
"comment" => "Comment for the vacation request.",
])
- ->assertSessionHasNoErrors();
+ ->assertRedirect();
$this->assertDatabaseHas("vacation_requests", [
"user_id" => $user->id,
@@ -115,7 +115,7 @@ class VacationRequestTest extends FeatureTestCase
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
"comment" => "Comment for the vacation request.",
])
- ->assertSessionHasNoErrors();
+ ->assertRedirect();
$this->assertDatabaseHas("vacation_requests", [
"user_id" => $user->id,
@@ -152,7 +152,7 @@ class VacationRequestTest extends FeatureTestCase
"comment" => "Comment for the vacation request.",
"flowSkipped" => true,
])
- ->assertSessionHasNoErrors();
+ ->assertRedirect();
$this->assertDatabaseHas("vacation_requests", [
"user_id" => $user->id,
@@ -182,7 +182,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($technicalApprover)
->post("/vacation/requests/{$vacationRequest->id}/accept-as-technical")
- ->assertSessionHasNoErrors();
+ ->assertRedirect();
$vacationRequest->refresh();
@@ -205,7 +205,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($administrativeApprover)
->post("/vacation/requests/{$vacationRequest->id}/accept-as-administrative")
- ->assertSessionHasNoErrors();
+ ->assertRedirect();
$vacationRequest->refresh();
@@ -236,7 +236,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($technicalApprover)
->post("/vacation/requests/{$vacationRequest->id}/reject")
- ->assertSessionHasNoErrors();
+ ->assertRedirect();
$vacationRequest->refresh();
@@ -434,7 +434,7 @@ class VacationRequestTest extends FeatureTestCase
public function testEmployeeCanSeeOnlyHisVacationRequests(): void
{
- $user = User::factory()->createQuietly();
+ $user = User::factory()->create();
$this->actingAs($user)
->get("/vacation/requests")
@@ -443,8 +443,8 @@ class VacationRequestTest extends FeatureTestCase
public function testEmployeeCannotCreateVacationRequestForAnotherEmployee(): void
{
- $user = User::factory()->createQuietly();
- $anotherUser = User::factory()->createQuietly();
+ $user = User::factory()->create();
+ $anotherUser = User::factory()->create();
$currentYearPeriod = YearPeriod::current();
@@ -461,7 +461,7 @@ class VacationRequestTest extends FeatureTestCase
public function testEmployeeCanCancelVacationRequestWithWaitingForAdministrativeStatus(): void
{
- $user = User::factory()->createQuietly();
+ $user = User::factory()->create();
$currentYearPeriod = YearPeriod::current();
VacationLimit::factory([
@@ -482,7 +482,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user)
->post("/vacation/requests/{$vacationRequest->id}/cancel")
- ->assertSessionHasNoErrors();
+ ->assertRedirect();
$vacationRequest->refresh();
@@ -491,7 +491,7 @@ class VacationRequestTest extends FeatureTestCase
public function testEmployeeCannotCancelVacationRequestWithApprovedStatus(): void
{
- $user = User::factory()->createQuietly();
+ $user = User::factory()->create();
$currentYearPeriod = YearPeriod::current();
VacationLimit::factory([
@@ -517,8 +517,8 @@ class VacationRequestTest extends FeatureTestCase
public function testAdministrativeApproverCanCancelVacationRequestWithApprovedStatus(): void
{
- $user = User::factory()->createQuietly();
- $administrativeApprover = User::factory()->administrativeApprover()->createQuietly();
+ $user = User::factory()->create();
+ $administrativeApprover = User::factory()->administrativeApprover()->create();
$currentYearPeriod = YearPeriod::current();
VacationLimit::factory([
@@ -539,7 +539,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($administrativeApprover)
->post("/vacation/requests/{$vacationRequest->id}/cancel")
- ->assertSessionHasNoErrors();
+ ->assertRedirect();
$vacationRequest->refresh();
@@ -548,7 +548,7 @@ class VacationRequestTest extends FeatureTestCase
public function testEmployeeCanDownloadHisVacationRequestAsPdf(): void
{
- $user = User::factory()->createQuietly();
+ $user = User::factory()->create();
$currentYearPeriod = YearPeriod::current();
VacationLimit::factory([
@@ -569,13 +569,13 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user)
->get("/vacation/requests/{$vacationRequest->id}/download")
- ->assertSessionHasNoErrors();
+ ->assertSuccessful();
}
public function testEmployeeCannotDownloadAnotherEmployeesVacationRequestAsPdf(): void
{
- $user = User::factory()->createQuietly();
- $anotherUser = User::factory()->createQuietly();
+ $user = User::factory()->create();
+ $anotherUser = User::factory()->create();
$currentYearPeriod = YearPeriod::current();
VacationLimit::factory([