This commit is contained in:
Kamil Niemczycki 2023-08-03 22:37:57 +02:00
parent 620217e1d5
commit 6a033d108c
Signed by: kamilniemczycki
GPG Key ID: 04D4E2012F969213
5 changed files with 85 additions and 4 deletions

View File

@ -6,6 +6,7 @@ namespace App\Http\Controllers\Dashboard;
use App\Http\Controllers\Controller;
use App\Http\Resources\MessageCollection;
use App\Http\Resources\MessageResource;
use App\Models\Message;
use Inertia\Response as InertiaResponse;
@ -13,7 +14,14 @@ class MessageController extends Controller
{
public function index() : InertiaResponse {
return inertia('Messages/Index', [
'messages' => new MessageCollection(Message::all()),
'messages' => new MessageCollection(Message::query()->orderByDesc('id')->get()),
]);
}
public function show(Message $message) : InertiaResponse
{
return inertia('Messages/Show', [
'message' => new MessageResource($message),
]);
}
}

View File

@ -72,12 +72,12 @@ function copySlug(slug) {
as="button"
class="px-3 py-3 text-lime-600 hover:text-lime-800 border-t-2 border-b-2 border-transparent hover:border-b-lime-600"
:href="`/dashboard/cv/${cv.token}/edit`"
title="Edytuj projekt"><FontAwesomeIcon :icon="['fas', 'pen-to-square']" /></InertiaLink>
title="Edytuj CV"><FontAwesomeIcon :icon="['fas', 'pen-to-square']" /></InertiaLink>
<InertiaLink
as="button"
class="px-3 py-3 text-red-600 hover:text-red-800"
:href="`/dashboard/cv/${cv.token}/delete`"
title="Usuń projekt z listy"><FontAwesomeIcon :icon="['fas', 'trash']" /></InertiaLink>
title="Usuń CV z listy"><FontAwesomeIcon :icon="['fas', 'trash']" /></InertiaLink>
</td>
</InertiaLink>
</tbody>

View File

@ -42,7 +42,7 @@ defineProps({
as="button"
class="px-3 py-3 text-red-600 hover:text-red-800"
:href="`/dashboard/message/${message.id}/delete`"
title="Usuń projekt z listy"><FontAwesomeIcon :icon="['fas', 'trash']" /></InertiaLink>
title="Usuń wiadomość z listy"><FontAwesomeIcon :icon="['fas', 'trash']" /></InertiaLink>
</td>
</InertiaLink>
</tbody>

View File

@ -0,0 +1,71 @@
<script setup>
import { computed } from 'vue';
const props = defineProps({
message: {
type: Object,
required: true,
},
});
const splitMessage = computed(() => props.message.message.split("\n"));
</script>
<template>
<InertiaHead title="Szczegóły wiadomości" />
<div class="p-4">
<header class="flex justify-between items-center pb-4">
<div class="flex items-center gap-2">
<InertiaLink
as="button"
href="/dashboard/message"
class="px-2 text-xl text-gray-700 hover:text-black"
title="Wróć do listy wiadomości"><FontAwesomeIcon :icon="['fas', 'caret-left']" /></InertiaLink>
<h1 class="text-3xl font-roboto font-light">Szczegóły wiadomości</h1>
</div>
<div class="flex gap-3 sm:gap-2">
<InertiaLink
as="button"
:href="`/dashboard/message/${message.id}/delete`"
class="flex items-center gap-2 px-2 py-1 text-red-600 hover:text-white hover:bg-red-600 rounded-md"
title="Usuń wiadomość"
><FontAwesomeIcon :icon="['fas', 'trash']" /><span class="hidden sm:inline-block">Usuń</span></InertiaLink>
</div>
</header>
<div class="mb-4">
<header>
<h2 class="text-2xl font-roboto font-light pb-3">Podstawowe informacje</h2>
</header>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<div class="text-gray-500 pb-0.5">ID</div>
<p class="w-full min-w-full max-w-full px-2.5 py-2 border-b-2 rounded-md bg-white whitespace-nowrap overflow-hidden overflow-ellipsis">{{ message.id }}</p>
</div>
<div>
<div class="text-gray-500 pb-0.5">Nadawca</div>
<p class="w-full min-w-full max-w-full px-2.5 py-2 border-b-2 rounded-md bg-white">{{ message.sender }}</p>
</div>
<div>
<div class="text-gray-500 pb-0.5">E-mail</div>
<p class="w-full min-w-full max-w-full px-2.5 py-2 border-b-2 rounded-md bg-white">{{ message.email }}</p>
</div>
</div>
</div>
<div class="mb-4">
<header>
<h2 class="text-2xl font-roboto font-light pb-3">Treść wiadomości</h2>
</header>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div class="col-span-1 sm:col-span-2">
<div class="text-gray-500 pb-0.5">Wiadomość</div>
<div class="w-full min-w-full max-w-full px-2.5 py-2 border-b-2 rounded-md bg-white">
<p
v-for="(messageLine, key) in splitMessage"
:key="key"
>{{ messageLine }}</p>
</div>
</div>
</div>
</div>
</div>
</template>

View File

@ -10,6 +10,8 @@ Route::name('admin.')->group(function () {
Route::name('message.')->prefix('message')->group(function (): void {
Route::get('', 'MessageController@index')
->name('index');
Route::get('{message}', 'MessageController@show')
->name('show');
});
Route::name('cv.')->prefix('cv')->group(function (): void {
Route::get('', 'CVController@index')