Skip to content

Commit

Permalink
Complete UI update
Browse files Browse the repository at this point in the history
  • Loading branch information
Raccoon254 committed Jun 24, 2024
1 parent d353d6c commit a491506
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 6 deletions.
5 changes: 1 addition & 4 deletions app/Livewire/UserEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ class UserEdit extends Component

protected $rules = [
'name' => 'required|string|max:255',
'email' => 'required|email|max:255|unique:users,email',
'phone' => 'nullable|string|max:15',
'location' => 'nullable|string|max:255',
'profile_photo' => 'nullable|image|max:1024', // Limit size to 1MB
Expand Down Expand Up @@ -50,9 +49,7 @@ public function save(): Redirector | Redirect | RedirectResponse
'role' => $this->role,
]);

session()->flash('message', 'User profile updated successfully.');

return redirect()->route('users.show', $this->user->id);
return back()->with('message', 'User updated successfully');
}

public function render(): View
Expand Down
46 changes: 44 additions & 2 deletions resources/views/livewire/user-edit.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,45 @@
<div>
{{ --Todo edit all user data here --}}
<div class="max-w-7xl mx-auto py-10 sm:px-6 lg:px-8">
@if (session()->has('message'))
<div class="bg-green-100 mb-4 border border-green-400 text-green-700 px-4 py-3 rounded relative" role="alert">
<span class="block sm:inline">{{ session('message') }}</span>
</div>
@endif

<form wire:submit.prevent="save" enctype="multipart/form-data">
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2">
<div>
<label for="name" class="block text-sm font-medium text-gray-700">Name</label>
<input type="text" wire:model="name" id="name" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md" required>
@error('name') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>

<div>
<label for="phone" class="block text-sm font-medium text-gray-700">Phone</label>
<input type="text" wire:model="phone" id="phone" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
@error('phone') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>

<div>
<label for="location" class="block text-sm font-medium text-gray-700">Location</label>
<input type="text" wire:model="location" id="location" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
@error('location') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>

<div>
<label for="role" class="block text-sm font-medium text-gray-700">Role</label>
<select wire:model="role" id="role" class="mt-1 block w-full shadow-sm sm:text-sm border-gray-300 rounded-md">
<option value="writer">Writer</option>
<option value="client">Client</option>
<option value="admin">Admin</option>
</select>
@error('role') <span class="text-red-500 text-sm">{{ $message }}</span> @enderror
</div>
</div>

<div class="mt-6">
<button type="submit" class="inline-flex items-center px-4 py-2 bg-blue-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-blue-500 focus:outline-none focus:border-blue-700 focus:ring focus:ring-blue-200 active:bg-blue-600 disabled:opacity-25 transition">
Save
</button>
</div>
</form>
</div>

0 comments on commit a491506

Please sign in to comment.