Skip to content

Commit

Permalink
fix(user-form): fixed null company code because user admin create by …
Browse files Browse the repository at this point in the history
…seeder
  • Loading branch information
mahatmamahardhikach committed Nov 12, 2024
1 parent 43f2fcc commit f4ced5f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 12 deletions.
9 changes: 7 additions & 2 deletions app/Livewire/FormCompanyOption.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@ public function updatedCompanyCode(string $companyCode): void
{
$this->dispatch('set-company', $companyCode);
}

/**
* Handle set company event.
*
* @param string $companyCode
* @return void
*/
#[On('set-company')]
public function setCompany($companyCode): void
public function setCompany(string $companyCode): void
{
$this->companyCode = $companyCode;
}
Expand Down
7 changes: 1 addition & 6 deletions app/Livewire/PageFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,8 @@ class PageFilter extends Component

public $filter = true;

public $companyId;

public $branchFilter = false;

public $brands;

/**
* Renders the view for the page filter.
*
Expand All @@ -32,7 +28,6 @@ public function render(): View
{
return view('livewire.page-filter', [
'companies' => Company::all(),
'brands' => $this->brands,
]);
}
}
}
4 changes: 4 additions & 0 deletions app/Livewire/ProfileCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public function mount(): void
$this->userDetail = UserDetail::where('nik', $this->nik)->first();
$this->user = $this->userDetail->user;
}

if (!$this->user) {
$this->user = auth()->user();
}
}

/**
Expand Down
5 changes: 4 additions & 1 deletion app/Livewire/UserDetailForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ public function setDetail($details): void
}

#[On('set-company')]
public function setCompany($companyCode): void
/**
* @param string $companyCode
*/
public function setCompany(string $companyCode): void
{
$this->details['company_code'] = $companyCode;
$this->company = Company::where('code', $companyCode)->first();
Expand Down
6 changes: 5 additions & 1 deletion app/Livewire/UserForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,14 @@ public function setUser(): void
{
$this->userDetail = UserDetail::where('user_id', $this->user->id)->first();
$this->setDetail($this->userDetail->toArray());

$this->name = $this->user->name;
$this->email = $this->user->email;

if (is_null($this->userDetail->company_code)) {
return;
}

$this->companyCode = $this->userDetail->company_code;
$this->dispatch('set-company', $this->companyCode);
$this->branchCode = $this->userDetail->branch_code;
Expand Down
3 changes: 1 addition & 2 deletions resources/views/components/layouts/app.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>{{ $title ?? '' }} | {{ config('app.name') }}</title>
Expand All @@ -17,7 +16,7 @@
<link rel="manifest" href="{{asset('/site.webmanifest')}}">

@vite(['resources/scss/app.scss', 'resources/scss/icons.scss'])
@vite(['resources/js/config.js'])
{{-- @vite(['resources/js/config.js'])--}}
@livewireStyles
</head>

Expand Down

0 comments on commit f4ced5f

Please sign in to comment.