Merge branch 'main' into small-changes
# Conflicts: # tests/Feature/MonthlyUsageTest.php # tests/Feature/VacationCalendarTest.php # tests/Feature/VacationRequestTest.php
This commit is contained in:
commit
a43706f98b
@ -5,6 +5,9 @@ declare(strict_types=1);
|
|||||||
namespace Toby\Architecture;
|
namespace Toby\Architecture;
|
||||||
|
|
||||||
use Illuminate\Foundation\Exceptions\Handler;
|
use Illuminate\Foundation\Exceptions\Handler;
|
||||||
|
use Inertia\Inertia;
|
||||||
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Throwable;
|
||||||
|
|
||||||
class ExceptionHandler extends Handler
|
class ExceptionHandler extends Handler
|
||||||
{
|
{
|
||||||
@ -13,4 +16,19 @@ class ExceptionHandler extends Handler
|
|||||||
"password",
|
"password",
|
||||||
"password_confirmation",
|
"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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
84
resources/js/Pages/Error.vue
Normal file
84
resources/js/Pages/Error.vue
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
<template>
|
||||||
|
<InertiaHead :title="error.title" />
|
||||||
|
<div class="min-h-full px-4 py-16 sm:px-6 sm:py-24 md:grid md:place-items-center lg:px-8">
|
||||||
|
<div class="max-w-max mx-auto">
|
||||||
|
<main class="sm:flex">
|
||||||
|
<p class="text-4xl font-extrabold text-blumilk-600 sm:text-5xl">
|
||||||
|
{{ error.code }}
|
||||||
|
</p>
|
||||||
|
<div class="sm:ml-6">
|
||||||
|
<div class="sm:border-l sm:border-gray-200 sm:pl-6">
|
||||||
|
<h1 class="text-4xl font-extrabold text-gray-900 tracking-tight sm:text-5xl">
|
||||||
|
{{ error.title }}
|
||||||
|
</h1>
|
||||||
|
<p class="mt-1 text-base text-gray-500">
|
||||||
|
{{ error.message }}
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div class="mt-10 flex space-x-3 sm:border-l sm:border-transparent sm:pl-6">
|
||||||
|
<InertiaLink
|
||||||
|
href="/"
|
||||||
|
class="inline-flex items-center px-4 py-3 border border-transparent text-sm leading-4 font-medium rounded-md shadow-sm text-white bg-blumilk-600 hover:bg-blumilk-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blumilk-500"
|
||||||
|
>
|
||||||
|
Wróć do strony głównej
|
||||||
|
</InertiaLink>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import GuestLayout from '@/Shared/Layout/GuestLayout'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'ErrorPage',
|
||||||
|
layout: GuestLayout,
|
||||||
|
props: {
|
||||||
|
status: Number,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
error() {
|
||||||
|
return {
|
||||||
|
401: {
|
||||||
|
code: '401',
|
||||||
|
title: 'Nieuprawniony dostęp',
|
||||||
|
message: 'Aby mieć dostęp do tej strony, musisz się zalogować.',
|
||||||
|
},
|
||||||
|
403: {
|
||||||
|
code: '403',
|
||||||
|
title: 'Zabroniony',
|
||||||
|
message: 'Dostęp do żądanej strony jest zabroniony.',
|
||||||
|
},
|
||||||
|
404: {
|
||||||
|
code: '404',
|
||||||
|
title: 'Nie znaleziono strony',
|
||||||
|
message: 'Przykro nam, ale strona, której szukasz, nie istnieje.',
|
||||||
|
},
|
||||||
|
419: {
|
||||||
|
code: '419',
|
||||||
|
title: 'Strona wygasła',
|
||||||
|
message: 'Ta strona wygasła. Zaloguj się ponownie.',
|
||||||
|
},
|
||||||
|
429: {
|
||||||
|
code: '429',
|
||||||
|
title: 'Przekroczono limit zapytań',
|
||||||
|
message: 'Wysłano ostatnio zbyt wiele zapytań. Poczekaj i spróbuj ponownie później.',
|
||||||
|
},
|
||||||
|
500: {
|
||||||
|
code: '500',
|
||||||
|
title: 'Błąd serwera',
|
||||||
|
message: 'Wystąpił wewnętrzny błąd serwera.',
|
||||||
|
},
|
||||||
|
503: {
|
||||||
|
code: '503',
|
||||||
|
title: 'Serwis niedostępny',
|
||||||
|
message: 'Serwer jest tymczasowo niedostępny. Spróbuj ponownie później.',
|
||||||
|
},
|
||||||
|
}[this.status]
|
||||||
|
},
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
@ -21,11 +21,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
|
<div class="hidden sm:flex-1 sm:flex sm:items-center sm:justify-between">
|
||||||
<div class="text-sm text-gray-700">
|
<div class="text-sm text-gray-700">
|
||||||
Wyświetlanie
|
Wyświetlanie od
|
||||||
<span class="font-medium">{{ pagination.from }}</span>
|
<span class="font-medium">{{ pagination.from }}</span>
|
||||||
od
|
|
||||||
<span class="font-medium">{{ pagination.to }}</span>
|
|
||||||
do
|
do
|
||||||
|
<span class="font-medium">{{ pagination.to }}</span>
|
||||||
|
z
|
||||||
<span class="font-medium">{{ pagination.total }}</span>
|
<span class="font-medium">{{ pagination.total }}</span>
|
||||||
wyników
|
wyników
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,7 +14,7 @@ class MonthlyUsageTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testAdministatorCanSeeVacationsMonthlyUsage(): void
|
public function testAdministatorCanSeeVacationsMonthlyUsage(): void
|
||||||
{
|
{
|
||||||
$admin = User::factory()->admin()->createQuietly();
|
$admin = User::factory()->admin()->create();
|
||||||
|
|
||||||
$this->actingAs($admin)
|
$this->actingAs($admin)
|
||||||
->get("/vacation/monthly-usage")
|
->get("/vacation/monthly-usage")
|
||||||
@ -23,7 +23,7 @@ class MonthlyUsageTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testEmployeeCannotSeeVacationsMonthlyUsage(): void
|
public function testEmployeeCannotSeeVacationsMonthlyUsage(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get("/vacation/monthly-usage")
|
->get("/vacation/monthly-usage")
|
||||||
|
@ -14,7 +14,7 @@ class VacationCalendarTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testAdministrativeApproverCanDownloadTimesheet(): void
|
public function testAdministrativeApproverCanDownloadTimesheet(): void
|
||||||
{
|
{
|
||||||
$administrativeApprover = User::factory()->administrativeApprover()->createQuietly();
|
$administrativeApprover = User::factory()->administrativeApprover()->create();
|
||||||
|
|
||||||
$this->actingAs($administrativeApprover)
|
$this->actingAs($administrativeApprover)
|
||||||
->get("/vacation/timesheet/january")
|
->get("/vacation/timesheet/january")
|
||||||
@ -23,7 +23,7 @@ class VacationCalendarTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testEmployeeCannotDownloadTimesheet(): void
|
public function testEmployeeCannotDownloadTimesheet(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get("/vacation/timesheet/january")
|
->get("/vacation/timesheet/january")
|
||||||
|
@ -80,7 +80,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
||||||
"comment" => "Comment for the vacation request.",
|
"comment" => "Comment for the vacation request.",
|
||||||
])
|
])
|
||||||
->assertSessionHasNoErrors();
|
->assertRedirect();
|
||||||
|
|
||||||
$this->assertDatabaseHas("vacation_requests", [
|
$this->assertDatabaseHas("vacation_requests", [
|
||||||
"user_id" => $user->id,
|
"user_id" => $user->id,
|
||||||
@ -115,7 +115,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
||||||
"comment" => "Comment for the vacation request.",
|
"comment" => "Comment for the vacation request.",
|
||||||
])
|
])
|
||||||
->assertSessionHasNoErrors();
|
->assertRedirect();
|
||||||
|
|
||||||
$this->assertDatabaseHas("vacation_requests", [
|
$this->assertDatabaseHas("vacation_requests", [
|
||||||
"user_id" => $user->id,
|
"user_id" => $user->id,
|
||||||
@ -152,7 +152,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
"comment" => "Comment for the vacation request.",
|
"comment" => "Comment for the vacation request.",
|
||||||
"flowSkipped" => true,
|
"flowSkipped" => true,
|
||||||
])
|
])
|
||||||
->assertSessionHasNoErrors();
|
->assertRedirect();
|
||||||
|
|
||||||
$this->assertDatabaseHas("vacation_requests", [
|
$this->assertDatabaseHas("vacation_requests", [
|
||||||
"user_id" => $user->id,
|
"user_id" => $user->id,
|
||||||
@ -182,7 +182,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
$this->actingAs($technicalApprover)
|
$this->actingAs($technicalApprover)
|
||||||
->post("/vacation/requests/{$vacationRequest->id}/accept-as-technical")
|
->post("/vacation/requests/{$vacationRequest->id}/accept-as-technical")
|
||||||
->assertSessionHasNoErrors();
|
->assertRedirect();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
|
|
||||||
@ -205,7 +205,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
$this->actingAs($administrativeApprover)
|
$this->actingAs($administrativeApprover)
|
||||||
->post("/vacation/requests/{$vacationRequest->id}/accept-as-administrative")
|
->post("/vacation/requests/{$vacationRequest->id}/accept-as-administrative")
|
||||||
->assertSessionHasNoErrors();
|
->assertRedirect();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
$this->actingAs($technicalApprover)
|
$this->actingAs($technicalApprover)
|
||||||
->post("/vacation/requests/{$vacationRequest->id}/reject")
|
->post("/vacation/requests/{$vacationRequest->id}/reject")
|
||||||
->assertSessionHasNoErrors();
|
->assertRedirect();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
|
|
||||||
@ -434,7 +434,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testEmployeeCanSeeOnlyHisVacationRequests(): void
|
public function testEmployeeCanSeeOnlyHisVacationRequests(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get("/vacation/requests")
|
->get("/vacation/requests")
|
||||||
@ -443,8 +443,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testEmployeeCannotCreateVacationRequestForAnotherEmployee(): void
|
public function testEmployeeCannotCreateVacationRequestForAnotherEmployee(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$anotherUser = User::factory()->createQuietly();
|
$anotherUser = User::factory()->create();
|
||||||
|
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
@ -461,7 +461,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testEmployeeCanCancelVacationRequestWithWaitingForAdministrativeStatus(): void
|
public function testEmployeeCanCancelVacationRequestWithWaitingForAdministrativeStatus(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -482,7 +482,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->post("/vacation/requests/{$vacationRequest->id}/cancel")
|
->post("/vacation/requests/{$vacationRequest->id}/cancel")
|
||||||
->assertSessionHasNoErrors();
|
->assertRedirect();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
|
|
||||||
@ -491,7 +491,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testEmployeeCannotCancelVacationRequestWithApprovedStatus(): void
|
public function testEmployeeCannotCancelVacationRequestWithApprovedStatus(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -517,8 +517,8 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testAdministrativeApproverCanCancelVacationRequestWithApprovedStatus(): void
|
public function testAdministrativeApproverCanCancelVacationRequestWithApprovedStatus(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$administrativeApprover = User::factory()->administrativeApprover()->createQuietly();
|
$administrativeApprover = User::factory()->administrativeApprover()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -539,7 +539,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
$this->actingAs($administrativeApprover)
|
$this->actingAs($administrativeApprover)
|
||||||
->post("/vacation/requests/{$vacationRequest->id}/cancel")
|
->post("/vacation/requests/{$vacationRequest->id}/cancel")
|
||||||
->assertSessionHasNoErrors();
|
->assertRedirect();
|
||||||
|
|
||||||
$vacationRequest->refresh();
|
$vacationRequest->refresh();
|
||||||
|
|
||||||
@ -548,7 +548,7 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
public function testEmployeeCanDownloadHisVacationRequestAsPdf(): void
|
public function testEmployeeCanDownloadHisVacationRequestAsPdf(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
@ -569,13 +569,13 @@ class VacationRequestTest extends FeatureTestCase
|
|||||||
|
|
||||||
$this->actingAs($user)
|
$this->actingAs($user)
|
||||||
->get("/vacation/requests/{$vacationRequest->id}/download")
|
->get("/vacation/requests/{$vacationRequest->id}/download")
|
||||||
->assertSessionHasNoErrors();
|
->assertSuccessful();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testEmployeeCannotDownloadAnotherEmployeesVacationRequestAsPdf(): void
|
public function testEmployeeCannotDownloadAnotherEmployeesVacationRequestAsPdf(): void
|
||||||
{
|
{
|
||||||
$user = User::factory()->createQuietly();
|
$user = User::factory()->create();
|
||||||
$anotherUser = User::factory()->createQuietly();
|
$anotherUser = User::factory()->create();
|
||||||
$currentYearPeriod = YearPeriod::current();
|
$currentYearPeriod = YearPeriod::current();
|
||||||
|
|
||||||
VacationLimit::factory([
|
VacationLimit::factory([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user