1import { Controller } from '@hotwired/stimulus' 2 3const formatEuroPrice = (amount) => { 4 return new Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(amount) 5} 6 7export default class extends Controller { 8 static targets = [ 'offer', 'arrival', 'accomodation', 'previewPrice', 'cashbackBadge' ] 9 connect() { 10 } 11 12 async run() { 13 const res = await fetch('/bookings/price_calc', { 14 body: JSON.stringify({ 15 booking: { 16 course_offer_id: this.offerId, 17 accomodation_id: this.accomodationId, 18 arrival_id: this.arrivalId 19 } 20 }), 21 headers: { 22 'Content-Type': 'application/json', 23 'Accept': 'application/json' 24 }, 25 method: 'POST' 26 }) 27 28 const { price } = await res.json() 29 30 this.previewPriceTarget.value = formatEuroPrice(price) 31 if(price > 500) { 32 this.cashbackBadgeTarget.classList.remove('d-none') 33 } else { 34 this.cashbackBadgeTarget.classList.add('d-none') 35 } 36 } 37 38 get offerId() { 39 return this.offerTarget.value 40 } 41 42 get accomodationId() { 43 return this.hasAccomodationTarget ? this.accomodationTarget.value : '' 44 } 45 46 get arrivalId() { 47 return this.hasArrivalTarget ? this.arrivalTarget.value : '' 48 } 49};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.