feat:onboarding flow for new users

This commit is contained in:
hackerESQ
2024-10-22 20:29:54 -05:00
parent 5756fa06d7
commit b6a123a90f
14 changed files with 184 additions and 41 deletions
@@ -0,0 +1,55 @@
<?php
use App\Models\Portfolio;
use App\Models\User;
use Illuminate\Support\Facades\Auth;
use Livewire\Attributes\Rule;
use Livewire\Volt\Component;
new class extends Component {
// props
public Portfolio $portfolio;
public User $user;
#[Rule('required|string|confirmed')]
public string $password;
#[Rule('required|string')]
public string $password_confirmation;
// methods
public function updatePassword()
{
$this->validate();
$this->user->password = Hash::make($this->password);
$this->user->save();
Auth::login($this->user, true);
return redirect(route('portfolio.show', ['portfolio' => $this->portfolio->id]));
}
}; ?>
<x-form wire:submit="updatePassword" class="">
<div class="mt-2">
<x-input wire:model="password" label="{{ __('Password') }}" class="block mt-1 w-full" type="password" required autocomplete="new-password" autofocus />
</div>
<div class="mt-2">
<x-input wire:model="password_confirmation" label="{{ __('Confirm Password') }}" class="block mt-1 w-full" type="password" required autocomplete="new-password" />
</div>
<div class="flex items-center justify-end mt-2">
<x-button class="btn-primary" type="submit">
{{ __('Create Password') }}
</x-button>
</div>
</x-form>
@@ -6,7 +6,7 @@ use Livewire\Attributes\Rule;
use Livewire\Volt\Component;
use Illuminate\Support\Collection;
use Mary\Traits\Toast;
use App\Notifications\InvitedToPortfolioNotification;
use App\Notifications\InvitedOnboardingNotification;
new class extends Component {
@@ -105,7 +105,7 @@ new class extends Component {
if (!empty($sync['attached'])) {
foreach($sync['attached'] as $newUserId) {
User::find($newUserId)->notify(new InvitedToPortfolioNotification($this->portfolio, auth()->user()));
User::find($newUserId)->notify(new InvitedOnboardingNotification($this->portfolio, auth()->user()));
};
}
@@ -150,30 +150,38 @@ new class extends Component {
<x-list-item
:item="$user"
avatar="profile_photo_url"
value="name"
no-separator
class="!-my-2 rounded"
x-data="{ loading: false, timeout: null }"
>
<x-slot:value>
{{ $user->name }}
@if (auth()->user()->id == $user->id)
({{ __('you') }})
@endif
</x-slot:value>
<x-slot:sub-value>
{{ $user->email }}
</x-slot:sub-value>
<x-slot:actions>
@if (auth()->user()->id != $user->id)
<x-select
class="select select-ghost border-none focus:outline-none focus:ring-0"
:options="[['id' => 0, 'name' => __('Read only')], ['id' => 1, 'name' => __('Full access')]]"
wire:model.live.number="permissions.{{ $user->id }}.full_access"
/>
@if($user->id != auth()->user()->id)
<x-button
class="btn-sm btn-ghost btn-circle"
wire:click="deleteUser('{{ $user->id }}')"
spinner="deleteUser"
spinner="deleteUser('{{ $user->id }}')"
>
<x-icon name="o-x-mark" class="w-4" />
</x-button>
</x-button>
@endif
</x-slot:actions>
</x-list-item>
@endforeach