<?php

namespace App\Livewire\Studio\Setting;

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

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

    public AccountForm $form;

    public function mount(User $user)
    {
        $this->form->setAccount($user);
    }

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

        $this->form->update();

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

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