feat: Make voucher tier IDs required, update its form UI, and simplify outlet display in the vouchers table.

This commit is contained in:
Yoga Pangestu 2025-12-20 09:47:49 +07:00
parent 0800503453
commit a2042c918d
3 changed files with 22 additions and 27 deletions

View File

@ -84,15 +84,9 @@ public function columns(): array
ArrayColumn::make('Outlet')
->data(
fn ($value, $row) => $row->outlets->map(fn ($outlet) => [
'name' => $outlet->name,
'stock' => formatCurrencyNumber($outlet->pivot->stock, ''),
])->toArray()
fn ($value, $row) => $row->outlets->pluck('name')->toArray()
)
->outputFormat(fn ($index, $value) => Blade::render('
<div class="flex items-center space-x-2 bg-gray-50 border border-gray-200 rounded-lg px-2 py-1 text-xs">
<span class="font-medium text-gray-700">{{ $value["name"] }}</span>
</div>', ['value' => $value]))
->outputFormat(fn ($index, $value) => Blade::render('<span class="text-xs text-gray-400 border border-gray-400 rounded px-1">'.$value.'</span>'))
->flexRow(['class' => 'gap-2 flex-wrap']),
Column::make('Visibilitas', 'is_show')

View File

@ -78,7 +78,7 @@ public function rules(): array
'summary' => ['required', 'string', 'max:200'],
'start_date' => ['required', 'date', 'after:yesterday'],
'end_date' => ['nullable', 'date', 'after_or_equal:start_date'],
'tier_ids' => ['nullable', 'array'],
'tier_ids' => ['required', 'array', 'min:1'],
'tier_ids.*' => Rule::exists('tiers', 'id'),
'outlet_ids' => ['required', 'array', 'min:1'],
'outlet_ids.*' => Rule::exists('outlets', 'id'),

View File

@ -41,22 +41,22 @@
</flux:field>
<flux:field>
<flux:label>Min. Belanja</flux:label>
<flux:input.group>
<flux:input.group.prefix>Rp</flux:input.group.prefix>
<flux:input placeholder="10.000"
x-mask:dynamic="$money($input, ',')"
wire:model="form.min_purchase" autocomplete="off" />
</flux:input.group>
<flux:error name="form.min_purchase" />
</flux:field>
<flux:label>Min. Belanja</flux:label>
<flux:input.group>
<flux:input.group.prefix>Rp</flux:input.group.prefix>
<flux:input placeholder="10.000"
x-mask:dynamic="$money($input, ',')"
wire:model="form.min_purchase" autocomplete="off" />
</flux:input.group>
<flux:error name="form.min_purchase" />
</flux:field>
<flux:input label="Kuota" placeholder="100" wire:model="form.quota"
x-mask:dynamic="$money($input, ',')" autocomplete="off" />
<flux:input label="Kuota" placeholder="100" wire:model="form.quota"
x-mask:dynamic="$money($input, ',')" autocomplete="off" />
<flux:input label="Batas Per Customer" placeholder="1"
wire:model="form.limit_per_user" x-mask:dynamic="$money($input, ',')"
autocomplete="off" />
<flux:input label="Batas Per Customer" placeholder="1"
wire:model="form.limit_per_user" x-mask:dynamic="$money($input, ',')"
autocomplete="off" />
</div>
</div>
@ -144,11 +144,12 @@
</flux:field>
<flux:field>
<flux:label>Tier</flux:label>
<flux:description>Jika tidak memilih, maka voucher berlaku tanpa membatasi tier.</flux:description>
<flux:select placeholder="Pilih Tier" wire:model="form.tier_ids" multiple searchable variant="listbox">
<flux:label>Tier <span class="text-red-500 ms-1">*</span></flux:label>
<flux:select placeholder="Pilih Tier" wire:model="form.tier_ids" multiple searchable
variant="listbox">
@foreach ($tiers as $key => $value)
<flux:select.option value="{{ $key }}">{{ $value }}</flux:select.option>
<flux:select.option value="{{ $key }}">{{ $value }}
</flux:select.option>
@endforeach
</flux:select>
<flux:error name="form.tier_ids" />