update layout control vm
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
@props(['invoice'])
|
||||
|
||||
<flux:modal name="renewal-modal" class="md:w-[28rem]">
|
||||
<div class="space-y-6" x-data="{ submitting: false, plan: '12', months: 12 }">
|
||||
<div class="space-y-6" x-data="{ submitting: false, plan: '12', months: 12, unitPrice: 0, total: 0 }" x-init="
|
||||
(() => {
|
||||
const p = {{ (int) ($invoice->invoiceItem->first()?->getProductAttribute()?->price_sale ?? $invoice->invoiceItem->first()?->getProductAttribute()?->price ?? 0) }};
|
||||
unitPrice = p; total = p * months;
|
||||
$watch('plan', value => { months = (value === 'other') ? months : parseInt(value); total = unitPrice * months; });
|
||||
$watch('months', value => { if (plan === 'other') { total = unitPrice * (parseInt(value) || 0); } });
|
||||
})()
|
||||
">
|
||||
<div>
|
||||
<flux:heading size="lg">{{ __('Gia hạn dịch vụ') }}</flux:heading>
|
||||
<flux:text class="mt-2">{{ __('Chọn thời hạn gia hạn hoặc nhập số tháng mong muốn.') }}</flux:text>
|
||||
@@ -30,6 +37,11 @@
|
||||
</flux:field>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 text-sm text-gray-700">
|
||||
<div class="flex justify-between"><span>{{ __('Đơn giá / tháng') }}</span><span x-text="new Intl.NumberFormat('vi-VN').format(unitPrice) + ' đ'"></span></div>
|
||||
<div class="flex justify-between font-semibold"><span>{{ __('Tổng tiền') }}</span><span x-text="new Intl.NumberFormat('vi-VN').format(total) + ' đ'"></span></div>
|
||||
</div>
|
||||
|
||||
<div class="flex gap-2 justify-end mt-6">
|
||||
<flux:modal.close>
|
||||
<flux:button variant="ghost">{{ __('Hủy') }}</flux:button>
|
||||
|
||||
Reference in New Issue
Block a user