<?php

namespace App\Livewire\Studio\Setting;

use App\Livewire\Forms\Studio\Setting\ProfileForm;
use App\Models\Employee;
use App\Traits\WithAuthorization;
use App\Traits\WithToast;
use App\Traits\WithUpdatedData;
use Livewire\Attributes\Title;
use Livewire\Component;

#[Title('Profil')]
class Profile extends Component
{
    use WithAuthorization, WithToast, WithUpdatedData;

    public ProfileForm $form;

    public function mount(Employee $employee)
    {
        $this->form->setProfile($employee);
    }

    public function update()
    {
        $this->canOrAbort('update profile');

        $this->form->update();

        $this->toast('Profil berhasil diperbarui.');
    }

    public function render()
    {
        return view('livewire.studio.setting.profile', [
            'pageTitle' => 'Profil',
        ]);
    }
}
