feat(frontend): add loyalty checkbox to admin and customer payment modals
Add loyalty stamp card checkbox UI to both payment modals. Admin modal: checkbox with card count, applies redemption via /apply-redemption before payment, adjusts amounts accordingly. Customer modal: add amount_paid === 0 guard, extract LOYALTY_DISCOUNT_RATE constant. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -12,6 +12,8 @@ import { SvelteDate } from 'svelte/reactivity';
|
||||
import PolicyPopover from '$lib/components/ui/policyPopover.svelte';
|
||||
import { authStore } from '$lib/stores/auth.svelte';
|
||||
|
||||
const LOYALTY_DISCOUNT_RATE = 0.1;
|
||||
|
||||
interface Props {
|
||||
booking: Booking;
|
||||
onClose: () => void;
|
||||
@@ -242,11 +244,12 @@ import { SvelteDate } from 'svelte/reactivity';
|
||||
let loyaltyEligible = $derived(
|
||||
stamps >= 10 &&
|
||||
!(booking.discounts ?? []).some((d) => d.discount_source === 'loyalty') &&
|
||||
booking.total_amount > 0
|
||||
booking.total_amount > 0 &&
|
||||
booking.amount_paid === 0
|
||||
);
|
||||
|
||||
let loyaltyDiscount = $derived(
|
||||
useLoyalty ? Math.round(booking.total_amount * 100 * 0.1) : 0
|
||||
useLoyalty ? Math.round(booking.total_amount * 100 * LOYALTY_DISCOUNT_RATE) : 0
|
||||
);
|
||||
|
||||
// Deposit policy warning text — dynamic based on booking state
|
||||
@@ -731,7 +734,7 @@ import { SvelteDate } from 'svelte/reactivity';
|
||||
<label for="use-loyalty" class="cursor-pointer select-none">
|
||||
<div class="text-sm font-medium text-fuchsia-900">Use my Loyalty Stamp Card</div>
|
||||
<div class="mt-0.5 text-xs text-fuchsia-700">
|
||||
{stamps} stamps available · 10% off ({formatCurrency(Math.round(booking.total_amount * 100 * 0.1))})
|
||||
{stamps} stamps available · {Math.round(LOYALTY_DISCOUNT_RATE * 100)}% off ({formatCurrency(Math.round(booking.total_amount * 100 * LOYALTY_DISCOUNT_RATE))})
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user