diff --git a/insurance-calculator-app/src/main/resources/static/js/person.js b/insurance-calculator-app/src/main/resources/static/js/person.js new file mode 100644 index 0000000..68c4312 --- /dev/null +++ b/insurance-calculator-app/src/main/resources/static/js/person.js @@ -0,0 +1,69 @@ +function addPerson() { + let personsContainer = document.getElementById("persons-container"); + let index = document.getElementsByClassName("person-card").length; + let personTemplate = ` +
+
+

Person ${index + 1}

+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+ +
+ + +
+
+
`; + personsContainer.insertAdjacentHTML('beforeend', personTemplate); +} + +function removePerson() { + let personsContainer = document.getElementById("persons-container"); + let personForms = document.getElementsByClassName("person-card"); + if (personForms.length > 0) { + personsContainer.removeChild(personForms[personForms.length - 1]); + } +} + +document.addEventListener('DOMContentLoaded', (event) => { + const agreementDateFrom = document.getElementById('agreementDateFrom'); + const agreementDateTo= document.getElementById('agreementDateTo'); + + const today = new Date(); + + const dateFrom = new Date(); + dateFrom.setDate(today.getDate() + 1); + + const dateTo = new Date(); + dateTo.setDate(today.getDate() + 2); + + agreementDateFrom.value = dateFrom.toISOString().split('T')[0]; + agreementDateTo.value = dateTo.toISOString().split('T')[0]; +}); + +function clearForm() { + window.location.href = window.location.href.split('?')[0]; +} diff --git a/insurance-calculator-app/src/main/resources/templates/travel-calculate-premium-v2.html b/insurance-calculator-app/src/main/resources/templates/travel-calculate-premium-v2.html index 54c12c9..55f94c5 100644 --- a/insurance-calculator-app/src/main/resources/templates/travel-calculate-premium-v2.html +++ b/insurance-calculator-app/src/main/resources/templates/travel-calculate-premium-v2.html @@ -38,9 +38,9 @@

Travel Insurance Premium Calculation

-
+
-
+

Person

@@ -88,10 +88,12 @@

Person

- - - - +
+ + + + +
@@ -120,89 +122,16 @@

Travel Insurance Premium Calculation ERRORS

- - -

-
- + +