initial commit
This commit is contained in:
15
resources/views/contacts/create.blade.php
Normal file
15
resources/views/contacts/create.blade.php
Normal file
@@ -0,0 +1,15 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="mb-6">
|
||||
<h1 class="text-2xl font-semibold">New Contact</h1>
|
||||
<p class="mt-1 text-sm text-zinc-600">Add a new contact to your list.</p>
|
||||
</div>
|
||||
|
||||
<div class="rounded-lg border border-zinc-200 bg-white p-6">
|
||||
<form method="post" action="{{ route('contacts.store', $searchQueryParams ?? []) }}">
|
||||
@csrf
|
||||
@include('contacts.partials.form', ['submitLabel' => 'Create'])
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
16
resources/views/contacts/edit.blade.php
Normal file
16
resources/views/contacts/edit.blade.php
Normal file
@@ -0,0 +1,16 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="mb-6">
|
||||
<h1 class="text-2xl font-semibold">Edit Contact</h1>
|
||||
<p class="mt-1 text-sm text-zinc-600">Update contact details.</p>
|
||||
</div>
|
||||
|
||||
<div class="rounded-lg border border-zinc-200 bg-white p-6">
|
||||
<form method="post" action="{{ route('contacts.update', ['contact' => $contact->uuid->toString(), ...($searchQueryParams ?? [])]) }}">
|
||||
@csrf
|
||||
@method('put')
|
||||
@include('contacts.partials.form', ['contact' => $contact, 'submitLabel' => 'Save changes'])
|
||||
</form>
|
||||
</div>
|
||||
@endsection
|
||||
55
resources/views/contacts/index.blade.php
Normal file
55
resources/views/contacts/index.blade.php
Normal file
@@ -0,0 +1,55 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="mb-6 flex items-center justify-end">
|
||||
<a href="{{ route('contacts.create', $searchQueryParams ?? []) }}" class="rounded-md bg-zinc-900 px-4 py-2 text-sm font-semibold text-white">
|
||||
New Contact
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@if ($contacts->count() === 0)
|
||||
<div class="rounded-lg border border-dashed border-zinc-300 bg-white p-8 text-center text-sm text-zinc-600">
|
||||
No contacts found.
|
||||
</div>
|
||||
@else
|
||||
<div class="overflow-hidden rounded-lg border border-zinc-200 bg-white">
|
||||
<table class="min-w-full divide-y divide-zinc-200 text-sm">
|
||||
<thead class="bg-zinc-50 text-left text-xs font-semibold uppercase tracking-wide text-zinc-500">
|
||||
<tr>
|
||||
<th class="px-4 py-3">Name</th>
|
||||
<th class="px-4 py-3">Email</th>
|
||||
<th class="px-4 py-3 text-right">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-zinc-200">
|
||||
@foreach ($contacts as $contact)
|
||||
<tr class="hover:bg-zinc-50">
|
||||
<td class="px-4 py-3">
|
||||
<div class="font-medium text-zinc-900">
|
||||
{{ trim(($contact->firstName ?? '') . ' ' . ($contact->lastName ?? '')) ?: '—' }}
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-4 py-3 text-zinc-700">
|
||||
{{ $contact->email }}
|
||||
</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
<div class="flex items-center justify-end gap-2">
|
||||
<a href="{{ route('contacts.show', ['contact' => $contact->uuid->toString(), ...($searchQueryParams ?? [])]) }}" class="text-zinc-700 hover:text-zinc-900">
|
||||
View
|
||||
</a>
|
||||
<a href="{{ route('contacts.edit', ['contact' => $contact->uuid->toString(), ...($searchQueryParams ?? [])]) }}" class="text-zinc-700 hover:text-zinc-900">
|
||||
Edit
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="mt-6">
|
||||
{{ $contacts->links() }}
|
||||
</div>
|
||||
@endif
|
||||
@endsection
|
||||
57
resources/views/contacts/partials/form.blade.php
Normal file
57
resources/views/contacts/partials/form.blade.php
Normal file
@@ -0,0 +1,57 @@
|
||||
@php
|
||||
$contact = $contact ?? null;
|
||||
@endphp
|
||||
|
||||
<div class="grid gap-4">
|
||||
<div>
|
||||
<label for="first_name" class="text-sm font-medium text-zinc-700">First name</label>
|
||||
<input
|
||||
id="first_name"
|
||||
name="first_name"
|
||||
type="text"
|
||||
value="{{ old('first_name', $contact?->firstName) }}"
|
||||
class="mt-2 w-full rounded-md border border-zinc-300 px-3 py-2 text-sm focus:border-zinc-900 focus:outline-none"
|
||||
/>
|
||||
@error('first_name')
|
||||
<p class="mt-1 text-xs text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="last_name" class="text-sm font-medium text-zinc-700">Last name</label>
|
||||
<input
|
||||
id="last_name"
|
||||
name="last_name"
|
||||
type="text"
|
||||
value="{{ old('last_name', $contact?->lastName) }}"
|
||||
class="mt-2 w-full rounded-md border border-zinc-300 px-3 py-2 text-sm focus:border-zinc-900 focus:outline-none"
|
||||
/>
|
||||
@error('last_name')
|
||||
<p class="mt-1 text-xs text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="email" class="text-sm font-medium text-zinc-700">Email</label>
|
||||
<input
|
||||
id="email"
|
||||
name="email"
|
||||
type="email"
|
||||
value="{{ old('email', $contact?->email) }}"
|
||||
class="mt-2 w-full rounded-md border border-zinc-300 px-3 py-2 text-sm focus:border-zinc-900 focus:outline-none"
|
||||
required
|
||||
/>
|
||||
@error('email')
|
||||
<p class="mt-1 text-xs text-red-600">{{ $message }}</p>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex flex-wrap items-center gap-3">
|
||||
<button type="submit" class="rounded-md bg-zinc-900 px-4 py-2 text-sm font-semibold text-white">
|
||||
{{ $submitLabel }}
|
||||
</button>
|
||||
<a href="{{ route('contacts.index') }}" class="text-sm text-zinc-700 hover:text-zinc-900">
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
41
resources/views/contacts/show.blade.php
Normal file
41
resources/views/contacts/show.blade.php
Normal file
@@ -0,0 +1,41 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="mb-6 flex flex-wrap items-start justify-between gap-4">
|
||||
<div>
|
||||
<h1 class="text-2xl font-semibold">
|
||||
{{ trim(($contact->firstName ?? '') . ' ' . ($contact->lastName ?? '')) ?: 'Contact' }}
|
||||
</h1>
|
||||
<p class="mt-1 text-sm text-zinc-600">{{ $contact->email }}</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('contacts.edit', ['contact' => $contact->uuid->toString(), ...($searchQueryParams ?? [])]) }}" class="rounded-md border border-zinc-300 px-3 py-2 text-sm font-medium text-zinc-700">
|
||||
Edit
|
||||
</a>
|
||||
<form method="post" action="{{ route('contacts.destroy', ['contact' => $contact->uuid->toString(), ...($searchQueryParams ?? [])]) }}" onsubmit="return confirm('Delete this contact?')">
|
||||
@csrf
|
||||
@method('delete')
|
||||
<button type="submit" class="rounded-md bg-red-600 px-3 py-2 text-sm font-semibold text-white">
|
||||
Delete
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-lg border border-zinc-200 bg-white p-6">
|
||||
<dl class="grid gap-4 text-sm">
|
||||
<div>
|
||||
<dt class="font-medium text-zinc-700">First name</dt>
|
||||
<dd class="mt-1 text-zinc-900">{{ $contact->firstName ?? '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="font-medium text-zinc-700">Last name</dt>
|
||||
<dd class="mt-1 text-zinc-900">{{ $contact->lastName ?? '—' }}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt class="font-medium text-zinc-700">Email</dt>
|
||||
<dd class="mt-1 text-zinc-900">{{ $contact->email }}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
</div>
|
||||
@endsection
|
||||
Reference in New Issue
Block a user