fix(user): menghapus status suspend

- menyesuaikan logika resign date
- memperbaiki select data untuk resign date dan view nya
This commit is contained in:
Yoga Pangestu 2025-11-13 13:27:54 +07:00
parent 9dac7abd1d
commit 637b35c63f
4 changed files with 13 additions and 16 deletions

View File

@ -11,14 +11,12 @@ enum UserStatus: int
case ACTIVE = 1; case ACTIVE = 1;
case INACTIVE = 2; case INACTIVE = 2;
case SUSPENDED = 3;
public function label() public function label()
{ {
return match ($this) { return match ($this) {
self::ACTIVE => 'Aktif', self::ACTIVE => 'Aktif',
self::INACTIVE => 'Tidak Aktif', self::INACTIVE => 'Tidak Aktif',
self::SUSPENDED => 'Suspend',
}; };
} }
@ -27,7 +25,6 @@ public function color()
return match ($this) { return match ($this) {
self::ACTIVE => 'emerald', self::ACTIVE => 'emerald',
self::INACTIVE => 'yellow', self::INACTIVE => 'yellow',
self::SUSPENDED => 'red',
}; };
} }
@ -36,7 +33,6 @@ public function gradient(): string
return match ($this) { return match ($this) {
self::ACTIVE => 'bg-gradient-to-b from-emerald-800 to-emerald-400', self::ACTIVE => 'bg-gradient-to-b from-emerald-800 to-emerald-400',
self::INACTIVE => 'bg-gradient-to-b from-yellow-800 to-yellow-400', self::INACTIVE => 'bg-gradient-to-b from-yellow-800 to-yellow-400',
self::SUSPENDED => 'bg-gradient-to-b from-red-800 to-red-400',
}; };
} }
} }

View File

@ -149,10 +149,10 @@ public function update()
$data = $this->all(); $data = $this->all();
if ($data['status'] == UserStatus::SUSPENDED->value) { if ($data['status'] == UserStatus::INACTIVE->value) {
$data['closed_date'] = now()->toDateString(); $data['resign_date'] = now();
} else { } else {
$data['closed_date'] = null; $data['resign_date'] = null;
} }
DB::transaction(function () use ($data) { DB::transaction(function () use ($data) {
@ -170,6 +170,7 @@ public function update()
'hire_date' => $data['hire_date'], 'hire_date' => $data['hire_date'],
'address' => $data['address'], 'address' => $data['address'],
'gender' => $data['gender'], 'gender' => $data['gender'],
'resign_date' => $data['resign_date'],
]); ]);
$this->user->outlets()->sync($this->outlet_ids); $this->user->outlets()->sync($this->outlet_ids);

View File

@ -52,6 +52,10 @@ protected function loadEmployees()
], ],
'birthdate' => formatDate($employee->birthdate), 'birthdate' => formatDate($employee->birthdate),
'birth_age' => getAge($employee->birthdate), 'birth_age' => getAge($employee->birthdate),
'hire_date' => formatDate($employee->hire_date),
'hire_ago' => timeAgo($employee->hire_date),
'resign_date' => formatDate($employee->resign_date),
'resign_ago' => timeAgo($employee->resign_date),
'user' => [ 'user' => [
'id' => $employee->user?->id, 'id' => $employee->user?->id,
'hash' => $employee->user?->hash, 'hash' => $employee->user?->hash,
@ -60,10 +64,6 @@ protected function loadEmployees()
'status' => [ 'status' => [
'gradient' => $employee->user?->status->gradient(), 'gradient' => $employee->user?->status->gradient(),
], ],
'hire_date' => formatDate($employee->user?->hire_date),
'hire_ago' => timeAgo($employee->user?->hire_date),
'resign_date' => formatDate($employee->user?->resign_date),
'resign_ago' => timeAgo($employee->user?->resign_date),
], ],
'referral_code' => $employee->user?->referralCode?->code, 'referral_code' => $employee->user?->referralCode?->code,
'outlets' => $employee->user?->outlets?->pluck('name')->toArray() ?? [], 'outlets' => $employee->user?->outlets?->pluck('name')->toArray() ?? [],

View File

@ -137,16 +137,16 @@ class="text-gray-700 dark:text-gray-300">{{ $employee['birthdate'] }}</span>
<span class="font-medium text-gray-900 dark:text-white">Tgl <span class="font-medium text-gray-900 dark:text-white">Tgl
Bergabung:</span> Bergabung:</span>
<span <span
class="text-gray-700 dark:text-gray-300">{{ $employee['user']['hire_date'] }}</span> class="text-gray-700 dark:text-gray-300">{{ $employee['hire_date'] }}</span>
<span class="text-gray-500">({{ $employee['user']['hire_ago'] }})</span> <span class="text-gray-500">({{ $employee['hire_ago'] }})</span>
</div> </div>
@if ($employee['user']['resign_date']) @if ($employee['resign_date'])
<div> <div>
<span class="font-medium text-gray-900 dark:text-white">Tgl <span class="font-medium text-gray-900 dark:text-white">Tgl
Resign:</span> Resign:</span>
<span <span
class="text-gray-700 dark:text-gray-300">{{ $employee['user']['resign_date'] }}</span> class="text-gray-700 dark:text-gray-300">{{ $employee['resign_date'] }}</span>
<span class="text-gray-500">({{ $employee['user']['resign_ago'] }})</span> <span class="text-gray-500">({{ $employee['resign_ago'] }})</span>
</div> </div>
@endif @endif
</div> </div>