feat: update raw material status management to use status enum instead of is_active
This commit is contained in:
parent
03ea092d39
commit
1db67a9a07
@ -176,13 +176,15 @@ public function delete(RawMaterial $rawMaterial, User $user): void
|
||||
|
||||
public function toggleStatus(RawMaterial $rawMaterial, array $validated, User $user): void
|
||||
{
|
||||
$isActive = $validated['status'] === 'active';
|
||||
|
||||
$rawMaterial->update([
|
||||
'is_active' => (bool) $validated['is_active'],
|
||||
'is_active' => $isActive,
|
||||
]);
|
||||
|
||||
$this->cacheForgetByPattern('master:raw_materials:*');
|
||||
|
||||
$statusLabel = $validated['is_active'] ? 'aktif' : 'nonaktif';
|
||||
$statusLabel = $isActive ? 'aktif' : 'nonaktif';
|
||||
|
||||
$this->notifyOwner(
|
||||
'Ubah Status Bahan Baku',
|
||||
@ -306,7 +308,7 @@ public function applyToggleStatus(OwnerVerificationRequest $verificationRequest)
|
||||
$newPayload = $this->payloadNew($verificationRequest);
|
||||
|
||||
$rawMaterial->update([
|
||||
'is_active' => (bool) ($newPayload['is_active'] ?? false),
|
||||
'is_active' => ($newPayload['status'] ?? 'inactive') === 'active',
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import { toast } from 'vue-sonner';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Switch } from '@/components/ui/switch';
|
||||
import { useCan } from '@/composables/useCan';
|
||||
import { ProductStatus } from '@/constants/active-status';
|
||||
import { toggle_status } from '@/routes/admin/master/raw_materials';
|
||||
import type { RawMaterialListItem } from '@/types/raw-material';
|
||||
|
||||
@ -37,11 +38,13 @@ function toggleStatus(checked: boolean) {
|
||||
return;
|
||||
}
|
||||
|
||||
const newStatus = checked ? ProductStatus.ACTIVE : ProductStatus.INACTIVE;
|
||||
|
||||
processing.value = true;
|
||||
isActive.value = checked;
|
||||
|
||||
router.patch(toggle_status.url(props.material.id), {
|
||||
is_active: checked,
|
||||
status: newStatus,
|
||||
}, {
|
||||
preserveScroll: true,
|
||||
onError: (errors: any) => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user