Files
car-tracker/app/javascript/controllers/maintenance_odometer_warning_controller.js
T
bionickatana 0826d267f2
CI / scan_ruby (push) Failing after 1m5s
CI / scan_js (push) Failing after 6s
CI / lint (push) Failing after 1m29s
Finished phase005
2026-09-16 15:34:50 -06:00

21 lines
491 B
JavaScript

import { Controller } from "@hotwired/stimulus"
export default class extends Controller {
static targets = ["odometer", "warning"]
static values = {
currentOdometer: Number,
threshold: Number
}
check() {
const odometer = Number.parseInt(this.odometerTarget.value, 10)
if (Number.isNaN(odometer) || odometer >= this.currentOdometerValue - this.thresholdValue) {
this.warningTarget.hidden = true
return
}
this.warningTarget.hidden = false
}
}