feat: add Social Accounts Livewire CRUD page

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Doar Mihai
2026-07-18 15:05:55 +03:00
co-authored by Claude Sonnet 5
parent 3f46eecff8
commit cee5b1976b
4 changed files with 256 additions and 3 deletions
@@ -0,0 +1,96 @@
<div>
<div class="flex justify-between items-center mb-4">
<h1 class="text-xl font-semibold">Social Accounts</h1>
<button wire:click="create" class="bg-blue-600 text-white px-4 py-2 rounded">Add Account</button>
</div>
<table class="w-full bg-white border border-gray-200 rounded">
<thead>
<tr class="text-left border-b border-gray-200">
<th class="p-3">Network</th>
<th class="p-3">Username</th>
<th class="p-3">Email</th>
<th class="p-3">Password</th>
<th class="p-3">Type</th>
<th class="p-3"></th>
</tr>
</thead>
<tbody>
@foreach ($accounts as $account)
<tr wire:key="account-{{ $account->id }}" class="border-b border-gray-100">
<td class="p-3">{{ ucfirst($account->network) }}</td>
<td class="p-3">{{ $account->username }}</td>
<td class="p-3">{{ $account->email }}</td>
<td class="p-3">
@if ($revealedId === $account->id)
{{ $account->password }}
@else
••••••••
@endif
<button wire:click="toggleReveal({{ $account->id }})" class="text-xs text-blue-600 ml-2">
{{ $revealedId === $account->id ? 'Hide' : 'Show' }}
</button>
</td>
<td class="p-3">{{ $account->type ? ucfirst($account->type) : '—' }}</td>
<td class="p-3 text-right space-x-2">
<button wire:click="edit({{ $account->id }})" class="text-blue-600">Edit</button>
<button wire:click="delete({{ $account->id }})" wire:confirm="Delete this account?" class="text-red-600">Delete</button>
</td>
</tr>
@endforeach
</tbody>
</table>
@if ($showForm)
<div class="fixed inset-0 bg-black/30 flex items-center justify-center">
<div class="bg-white p-6 rounded w-full max-w-md space-y-4">
<h2 class="text-lg font-semibold">{{ $editingId ? 'Edit Account' : 'Add Account' }}</h2>
<div>
<label class="block text-sm font-medium">Network</label>
<select wire:model="network" class="w-full border rounded p-2">
<option value="">Select network</option>
@foreach ($networks as $network)
<option value="{{ $network }}">{{ ucfirst($network) }}</option>
@endforeach
</select>
@error('network') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
<div>
<label class="block text-sm font-medium">Username</label>
<input type="text" wire:model="username" class="w-full border rounded p-2">
@error('username') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
<div>
<label class="block text-sm font-medium">Email</label>
<input type="text" wire:model="email" class="w-full border rounded p-2">
@error('email') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
<div>
<label class="block text-sm font-medium">Password</label>
<input type="text" wire:model="password" class="w-full border rounded p-2">
@error('password') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
<div>
<label class="block text-sm font-medium">Type</label>
<select wire:model="type" class="w-full border rounded p-2">
<option value="">None</option>
@foreach ($types as $t)
<option value="{{ $t }}">{{ ucfirst($t) }}</option>
@endforeach
</select>
@error('type') <span class="text-red-600 text-sm">{{ $message }}</span> @enderror
</div>
<div class="flex justify-end gap-2">
<button wire:click="$set('showForm', false)" class="px-4 py-2">Cancel</button>
<button wire:click="save" class="bg-blue-600 text-white px-4 py-2 rounded">Save</button>
</div>
</div>
</div>
@endif
</div>