refactor(product): update cost and sale price handling in form and mask cost price display

This commit is contained in:
Yoga Pangestu 2025-10-16 21:16:21 +07:00
parent 2219534a73
commit afa7323002
3 changed files with 9 additions and 8 deletions

View File

@ -8,6 +8,7 @@
use App\Traits\Datatable\WithPrependColumn; use App\Traits\Datatable\WithPrependColumn;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Blade; use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Str;
use Rappasoft\LaravelLivewireTables\DataTableComponent; use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column; use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Columns\ArrayColumn; use Rappasoft\LaravelLivewireTables\Views\Columns\ArrayColumn;
@ -37,7 +38,7 @@ public function columns(): array
->html(), ->html(),
Column::make('Harga Beli', 'cost_price') Column::make('Harga Beli', 'cost_price')
->label(fn ($row, $column) => currency($row->cost_price, 'Rp')) ->label(fn ($row, $column) => Str::mask(currency($row->cost_price, 'Rp'), '*', 2))
->searchable() ->searchable()
->sortable(), ->sortable(),

View File

@ -111,8 +111,8 @@ private function prepareSavedData()
return [ return [
'name' => $this->name, 'name' => $this->name,
'sku' => $this->sku, 'sku' => $this->sku,
'cost_price' => $this->cost_price, 'cost_price' => replaceCurrency($this->cost_price),
'sale_price' => $this->sale_price, 'sale_price' => replaceCurrency($this->sale_price),
'description' => $this->description, 'description' => $this->description,
'outlet_ids' => $this->outlet_ids, 'outlet_ids' => $this->outlet_ids,
'image' => $this->image, 'image' => $this->image,

View File

@ -20,15 +20,15 @@
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<flux:field> <flux:field>
<flux:label>Nama <span class="text-red-500 ms-1">*</span></flux:label> <flux:label>Nama <span class="text-red-500 ms-1">*</span></flux:label>
<flux:input placeholder="Masukkan nama produk" <flux:input placeholder="Contoh: Air Zam Zam"
wire:model.live.debounce.500ms="form.name" autofocus autocomplete="off" /> wire:model.live.debounce.500ms="form.name" autofocus autocomplete="off" />
<flux:error name="form.name" /> <flux:error name="form.name" />
</flux:field> </flux:field>
<flux:field> <flux:field>
<flux:label>SKU <span class="text-red-500 ms-1">*</span></flux:label> <flux:label>SKU <span class="text-red-500 ms-1">*</span></flux:label>
<flux:input placeholder="Masukkan stock keeping unit" <flux:input placeholder="Contoh: 001" wire:model.live.debounce.500ms="form.sku"
wire:model.live.debounce.500ms="form.sku" autocomplete="off" copyable /> autocomplete="off" copyable />
<flux:error name="form.sku" /> <flux:error name="form.sku" />
</flux:field> </flux:field>
@ -56,8 +56,8 @@
<div class="md:col-span-2"> <div class="md:col-span-2">
<flux:editor label="Deskripsi" wire:model="form.description" <flux:editor label="Deskripsi" wire:model="form.description"
placeholder="Masukkan deskripsi" auotocomplete="off" placeholder="Air Zamzam adalah air suci yang berasal dari sumur Zamzam di Masjidil Haram, Makkah, Arab Saudi"
class="**:data-[slot=content]:min-h-[100px]!" /> auotocomplete="off" class="**:data-[slot=content]:min-h-[100px]!" />
</div> </div>
</div> </div>
</flux:card> </flux:card>