style: fix prefer-const and prettier formatting issues
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
onComplete: (payment: PaymentResult) => void;
|
||||
}
|
||||
|
||||
let { booking, onClose, onComplete }: Props = $props();
|
||||
const { booking, onClose, onComplete }: Props = $props();
|
||||
|
||||
type PaymentStatus =
|
||||
| 'idle'
|
||||
@@ -47,17 +47,17 @@
|
||||
let paymentResult = $state<PaymentResult | null>(null);
|
||||
let error = $state<string | null>(null);
|
||||
|
||||
let stamps = $derived(booking.user?.loyalty_stamps ?? 0);
|
||||
const stamps = $derived(booking.user?.loyalty_stamps ?? 0);
|
||||
let useLoyalty = $state(false);
|
||||
|
||||
let loyaltyEligible = $derived(
|
||||
const loyaltyEligible = $derived(
|
||||
stamps >= 10 &&
|
||||
!(booking.discounts ?? []).some((d: BookingDiscount) => d.discount_source === 'loyalty') &&
|
||||
booking.total_amount > 0 &&
|
||||
booking.amount_paid === 0
|
||||
);
|
||||
|
||||
let loyaltyDiscount = $derived(
|
||||
const loyaltyDiscount = $derived(
|
||||
useLoyalty ? Math.round(booking.total_amount * 100 * LOYALTY_DISCOUNT_RATE) : 0
|
||||
);
|
||||
|
||||
@@ -203,13 +203,15 @@
|
||||
return service.override_price ?? service.price ?? 0;
|
||||
}
|
||||
|
||||
let subtotal = $derived((booking.services ?? []).reduce((sum, s) => sum + getServicePrice(s), 0));
|
||||
let discountSum = $derived(
|
||||
const subtotal = $derived(
|
||||
(booking.services ?? []).reduce((sum, s) => sum + getServicePrice(s), 0)
|
||||
);
|
||||
const discountSum = $derived(
|
||||
(booking.discounts ?? []).reduce((sum, d) => sum + d.discount_amount, 0)
|
||||
);
|
||||
let netTotal = $derived(Math.max(0, subtotal - discountSum));
|
||||
const netTotal = $derived(Math.max(0, subtotal - discountSum));
|
||||
|
||||
let tipPercentages = $derived.by(() => {
|
||||
const tipPercentages = $derived.by(() => {
|
||||
if (netTotal <= 0) return [];
|
||||
return [
|
||||
{ pct: 10, amount: Math.round(netTotal * 0.1 * 100) / 100 },
|
||||
@@ -218,7 +220,7 @@
|
||||
];
|
||||
});
|
||||
|
||||
let tipMultiplier = $derived(
|
||||
const tipMultiplier = $derived(
|
||||
selectedTipPercent !== null
|
||||
? 1 + selectedTipPercent / 100
|
||||
: customTipAmount && parseFloat(customTipAmount) > 0
|
||||
@@ -226,8 +228,8 @@
|
||||
: 1
|
||||
);
|
||||
|
||||
let totalWithTip = $derived(tipEnabled ? netTotal * tipMultiplier : netTotal);
|
||||
let tipDisplay = $derived(
|
||||
const totalWithTip = $derived(tipEnabled ? netTotal * tipMultiplier : netTotal);
|
||||
const tipDisplay = $derived(
|
||||
selectedTipPercent !== null
|
||||
? `${selectedTipPercent}%`
|
||||
: customTipAmount && parseFloat(customTipAmount) > 0
|
||||
@@ -235,7 +237,7 @@
|
||||
: ''
|
||||
);
|
||||
|
||||
let totalDue = $derived(tipEnabled ? totalWithTip : netTotal);
|
||||
const totalDue = $derived(tipEnabled ? totalWithTip : netTotal);
|
||||
|
||||
function formatCurrency(value: number): string {
|
||||
return new Intl.NumberFormat('en-GB', {
|
||||
@@ -378,8 +380,8 @@
|
||||
});
|
||||
|
||||
let cashAmount = $state<string>('');
|
||||
let cashAmountNum = $derived(cashAmount === '' ? 0 : parseFloat(cashAmount));
|
||||
let changeDue = $derived(cashAmountNum > totalDue ? cashAmountNum - totalDue : 0);
|
||||
const cashAmountNum = $derived(cashAmount === '' ? 0 : parseFloat(cashAmount));
|
||||
const changeDue = $derived(cashAmountNum > totalDue ? cashAmountNum - totalDue : 0);
|
||||
let extraAsTip = $state(false);
|
||||
|
||||
function handleCashInput(e: Event) {
|
||||
@@ -511,7 +513,7 @@
|
||||
giftCardId = formatted;
|
||||
}
|
||||
|
||||
let giftCardValid = $derived(useAccountBalance || giftCardId.replace(/-/g, '').length === 12);
|
||||
const giftCardValid = $derived(useAccountBalance || giftCardId.replace(/-/g, '').length === 12);
|
||||
|
||||
async function handleGiftCardPayment() {
|
||||
if (!giftCardValid) {
|
||||
|
||||
Reference in New Issue
Block a user