Skip to content

Commit

Permalink
add missing fields
Browse files Browse the repository at this point in the history
  • Loading branch information
keyserfaty committed Sep 28, 2023
1 parent 195e87e commit d4e6c32
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# calculadora

version="1.0.1"; git tag $version && git push origin $version && gh release create $version
version="1.0.13"; git tag $version && git push origin $version && gh release create $version
41 changes: 35 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@
)
const $budgetMoHours = document.querySelectorAll('.budget__mo-hours')

const $budgetAmountAssigned = document.querySelector('.budget__assigned')

const getQtyPeople = () => {
const formClassName = '.step-1-form-field'
const $form = document.querySelector(formClassName)
Expand All @@ -392,13 +394,36 @@
return $selected[0].value
}

const getBudgetAssigned = () => {
return $budgetAmountAssigned.value
}

const getUserEmail = () => {
const formClassName = '.step-5-form-field'
const $form = document.querySelector(formClassName)

return $form.value
}

const getBenefits = () => {
const formClassName = '.step-4-form-field'
const $form = document.querySelector(formClassName)

const $options = $form.querySelectorAll('input[type=\'checkbox\']')
const $selected = Array.from($options).filter((elem) => elem.checked)

return $selected
.map(($s) => $s.id)
.map((name) => name.substring(0, name.lastIndexOf('-')))
}

const getFilteredBenefits = () => {
const formClassName = '.step-4-form-field'
const $form = document.querySelector(formClassName)

const $options = $form.querySelectorAll('input[type=\'checkbox\']')
const $selected = Array.from($options).filter((elem) => elem.checked)

return $selected
.map(($s) => $s.id)
.filter((name) => !BENEFIT_TYPE_HEALTH.includes(name))
Expand Down Expand Up @@ -434,7 +459,7 @@
}

const getAmountPerson = () => {
const benefits = getBenefits()
const benefits = getFilteredBenefits()
const costBenefits = benefits
.map((ben) => BENEFIT_PRICE[ben])
.reduce((res, each) => res + each, 0)
Expand All @@ -444,7 +469,7 @@

const getAmountTotal = () => {
const qtyPeople = getQtyPeople()
const benefits = getBenefits()
const benefits = getFilteredBenefits()
const costBenefits = benefits
.map((ben) => BENEFIT_PRICE[ben])
.reduce((res, each) => res + each, 0)
Expand All @@ -453,14 +478,14 @@
}

const getQtyProviders = () => {
const benefits = getBenefits()
const benefits = getFilteredBenefits()
const qtyCountries = getQtyCountries()

return benefits.length * qtyCountries
}

const getMoHours = () => {
const benefits = getBenefits()
const benefits = getFilteredBenefits()
const qtyCountries = getQtyCountries()
console.log({ benefits, qtyCountries })

Expand All @@ -469,7 +494,7 @@

const replaceResultsAll = () => {
const qtyPeople = getQtyPeople()
const benefits = getBenefits()
const benefits = getFilteredBenefits()
const qtyCountries = getQtyCountries()
const flags = getFlags()
const amountPerson = getAmountPerson()
Expand Down Expand Up @@ -502,6 +527,8 @@
const qtyProviders = getQtyProviders()
const moHours = getMoHours()
const countries = getCountries()
const email = getUserEmail()
const budgetAssigned = getBudgetAssigned()

const data = {
qtyPeople,
Expand All @@ -512,7 +539,9 @@
amountTotal,
qtyProviders,
moHours,
countries
countries,
email,
budgetAssigned
}

return fetch('https://3562-24-232-110-208.ngrok-free.app/', { // todo: replace
Expand Down

0 comments on commit d4e6c32

Please sign in to comment.