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 Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Str;
use Rappasoft\LaravelLivewireTables\DataTableComponent;
use Rappasoft\LaravelLivewireTables\Views\Column;
use Rappasoft\LaravelLivewireTables\Views\Columns\ArrayColumn;
@ -37,7 +38,7 @@ public function columns(): array
->html(),
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()
->sortable(),

View File

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

View File

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