diff --git a/src/forms/ButtonReset.js b/src/forms/ButtonReset.js index 68808938..e804ac5e 100644 --- a/src/forms/ButtonReset.js +++ b/src/forms/ButtonReset.js @@ -4,6 +4,8 @@ import React from 'react'; import { BigButton } from './inputs'; +const BLANK_CALLBACK = function () {}; + const ButtonReset = function ({ children, onClick, overrides }) { if (!overrides) { @@ -15,7 +17,7 @@ const ButtonReset = function ({ children, onClick, overrides }) { header: ``, message: `default`, leaveText: `Start New Client`, - callback: () => {}, + callback: { BLANK_CALLBACK }, }); }; @@ -28,7 +30,7 @@ const ButtonReset = function ({ children, onClick, overrides }) { ); -}; // End +}; // Ends export { ButtonReset }; diff --git a/src/forms/CurrentBenefits.js b/src/forms/CurrentBenefits.js index ae2ee407..6b9dda98 100644 --- a/src/forms/CurrentBenefits.js +++ b/src/forms/CurrentBenefits.js @@ -5,6 +5,8 @@ import cloneDeep from 'lodash/cloneDeep'; // PROJECT COMPONENTS import { FormPartsContainer } from './FormPartsContainer'; import { ControlledRadioYesNo } from './inputs'; + +// DATA import { allBenefitOrders } from '../programs/allBenefitOrders'; @@ -23,45 +25,48 @@ import { allBenefitOrders } from '../programs/allBenefitOrders'; */ class CurrentBenefitsContent extends React.Component { handleRadioChange = (event, inputProps) => { - const benefitName = inputProps.name; - - const route = 'benefits'; - - const value = cloneDeep(this.props.current.benefits); + const benefitName = inputProps.name, + route = `benefits`, + value = cloneDeep(this.props.current.benefits); if (inputProps.value) { value.push(benefitName); value.sort( // Make sure benefits are in the correct order (a, b) => { - const aIndex = this.props.benefits.indexOf(a); - const bIndex = this.props.benefits.indexOf(b); + // `props.benefits` is list of available benefits + const aIndex = this.props.benefits.indexOf(a), + bIndex = this.props.benefits.indexOf(b); return aIndex - bIndex; } ); - } - else { + } else { const index = value.indexOf(benefitName); if (index >= 0) { value.splice(index, 1); } - } + } // ends if input value - this.props.updateClientValue(event, { route, value, time: 'current' }); - }; + this.props.updateClientValue(event, { route, value, time: `current` }); + }; // Ends handleRadioChange() render() { - const { current, translations, benefits } = this.props; + const { + current, + translations, + benefits, + } = this.props; const components = []; for (let benefitIndex = 0; benefitIndex < benefits.length; benefitIndex++) { - const benefit = benefits[ benefitIndex ]; - - const translationKey = `i_has_${benefit}_label`; + const benefit = benefits[ benefitIndex ], + translationKey = `i_has_${benefit}_label`; + // @todo This would have to be handled in every translation situation. + // @todo Also, is there a way we can include this in the translation report? if (!(translationKey in translations)) { throw new Error(`No translation found as label for benefit radio buttons; expected key "${translationKey}"`); } @@ -70,26 +75,22 @@ class CurrentBenefitsContent extends React.Component { components.push( + key = { benefit } + translations = { translations } + labelText = { labelText } + onChange = { this.handleRadioChange } + checked = { current.benefits.includes(benefit) } + name = { benefit } /> ); - } + } // ends for every benefit return ( -
- {components} -
+
{ components }
); - } -} // End CurrentBenefitsContent() + }; // Ends render() +}; // Ends -/** - * @todo Combine with related components? - * +/** * @function * @param {object} props * @property {function} props.updateClientValue Updates state upstream. @@ -101,6 +102,7 @@ class CurrentBenefitsContent extends React.Component { * @returns {object} Component */ const CurrentBenefitsStep = ({ updateClientValue, navData, client, translations }) => { + // @todo Combine with related components since there are so few? return ( + current = { client.current } + translations = { translations } + benefits = { allBenefitOrders[ client.USState ] } /> ); -}; // End CurrentBenefitsStep() +}; // Ends + export { CurrentBenefitsStep }; diff --git a/src/forms/CurrentExpenses.js b/src/forms/CurrentExpenses.js index 688f3328..dfec3ee0 100644 --- a/src/forms/CurrentExpenses.js +++ b/src/forms/CurrentExpenses.js @@ -37,10 +37,6 @@ import { import { getUnder13Expenses } from '../utils/cashflow'; -// ======================================== -// COMPONENTS -// ======================================== - /* Move these to SNAP calc logic scripts: * @todo SNAP: Does a medical assistant's payments count as a medical expense? * (Answer: Yes. @see {@link https://www.mass.gov/service-details/snap-verifications}) @@ -72,9 +68,9 @@ const CurrentExpensesStep = function ({ updateClientValue, navData, client, tran formClass = { `expenses` }> + current = { client.current } + time = { `current` } + translations = { translations } /> ); @@ -93,7 +89,7 @@ const CurrentExpensesStep = function ({ updateClientValue, navData, client, tran */ const ExpensesFormContent = function ({ current, time, updateClientValue, translations }) { - let type = 'expense', + let type = `expense`, household = current.household, sharedProps = { timeState: current, @@ -114,16 +110,18 @@ const ExpensesFormContent = function ({ current, time, updateClientValue, transl over12 = getEveryMember(allDependents, isOver12); // 'Elderly' here is using the lowest common denominator - SNAP standards. + // @todo Make this dependant on type of benefit and use that benefit's + // values const isElderlyOrDisabled = function (member) { return isDisabled(member) || member.m_age >= 60; }; - const elderlyOrDisabled = getEveryMember(household, isElderlyOrDisabled), + const elderlyOrDisabled = getEveryMember(household, isElderlyOrDisabled), elderlyOrDisabledHeadOrSpouse = getEveryMember(elderlyOrDisabled, isHeadOrSpouse); return ( -
+
- { under13.length > 0 ? ( + { (under13.length > 0) ? ( 0 ? ( + { (over12.length > 0) ? ( 0 ? ( + { (elderlyOrDisabled.length > 0) ? ( 0 || (current.benefits.includes('snap') && elderlyOrDisabled.length > 0) ? ( + { (elderlyOrDisabledHeadOrSpouse.length > 0 || (current.benefits.includes('snap') && elderlyOrDisabled.length > 0)) ? ( + translations = { translations } + type = { type } + sharedProps = { sharedProps } /> ) : ( null ) } {/* Premature feature temporarily hidden to avoid messy revert + question = { `Do you want to enter your other expenses so you can see if you need to make a different plan?` } + heading = { `Other Expenses` }> */} @@ -202,35 +200,37 @@ const ExpensesFormContent = function ({ current, time, updateClientValue, transl const Under13 = function ({ translations, type, sharedProps, current, updateClientValue }) { return (
- + { translations.unreimbursedNonMedicalChildCare.i_sectionHeading } + + + generic = { `childDirectCare` }> { translations.unreimbursedNonMedicalChildCare.childDirectCare.i_label } + generic = { `childBeforeAndAfterSchoolCare` }> { translations.unreimbursedNonMedicalChildCare.childBeforeAndAfterSchoolCare.i_label} + generic = { `childTransportation` }> { translations.unreimbursedNonMedicalChildCare.childTransportation.i_label } + generic = { `childOtherCare` }> { translations.unreimbursedNonMedicalChildCare.childOtherCare.i_label } - { `How much less would you make?` } + How much less would you make? } /> @@ -252,10 +252,13 @@ const ChildSupport = function ({ type, sharedProps }) { return (
Child Support + + Legally obligated child support + generic = { `childSupportPaidOut` }> + Legally obligated child support
); @@ -265,21 +268,26 @@ const ChildSupport = function ({ type, sharedProps }) { const DependentsOver12 = function ({ type, sharedProps }) { return (
- + Dependent Care of Persons Over 12 Years of Age + + Direct care costs + generic = { `adultDirectCare` }> + Direct care costs Transportation costs + generic = { `adultTransportation` }> + Transportation costs Other care + generic = { `adultOtherCare` }> + Other care
); @@ -300,16 +308,19 @@ const ElderlyOrDisabledAssistance = function ({ current, type, sharedProps, upda
+ + Disabled/Handicapped assistance + generic = { `disabledAssistance` }> + Disabled/Handicapped assistance - { `How much less would you make?` } + How much less would you make? } />
@@ -329,6 +340,7 @@ const ElderlyOrDisabledAssistance = function ({ current, type, sharedProps, upda const UnreimbursedMedical = function ({ type, sharedProps }) { return (
+ Unreimbursed Medical Expenses
@@ -346,14 +358,18 @@ const UnreimbursedMedical = function ({ type, sharedProps }) {
+ + Disabled/Elderly medical expenses + generic = { `disabledMedical` }> + Disabled/Elderly medical expenses Medical expenses of other members + generic = { `otherMedical` }> + Medical expenses of other members
); @@ -387,28 +403,27 @@ const Housing = function ({ current, type, time, updateClientValue }) { return (
- Housing - { current.housing === 'voucher' ? ( + { (current.housing === `voucher`) ? ( null ) : (
-
What is your housing situation?
+
What is your housing situation?
) } @@ -428,10 +443,10 @@ const HousingRadio = function ({ currentValue, label, time, updateClientValue }) return ( ); @@ -450,7 +465,7 @@ const HousingDetails = function ({ current, type, time, updateClientValue }) { updateClientValue: updateClientValue, }; - if (current.housing === 'voucher') { + if (current.housing === `voucher`) { return (
@@ -459,10 +474,10 @@ const HousingDetails = function ({ current, type, time, updateClientValue }) {
); - } else if (housing === 'homeless') { + } else if (housing === `homeless`) { return null; - } else if (housing === 'renter') { + } else if (housing === `renter`) { return (

@@ -471,27 +486,27 @@ const HousingDetails = function ({ current, type, time, updateClientValue }) {
); - } else if (housing === 'homeowner') { + } else if (housing === `homeowner`) { return (
Mortgage + generic = { `mortgage` }> Mortgage Insurance Costs + generic = { `housingInsurance` }> Insurance Costs Property Tax + generic = { `propertyTax` }> Property Tax
); - } // ends which expenses + } // ends which kind of housing }; // Ends @@ -518,36 +533,35 @@ const Utilities = function ({ current, type, time, updateClientValue }) { // Will require more work in the change handler return (
-
Which of these utilities do you pay for?
+
Which of these utilities do you pay for?




-
); @@ -594,7 +608,10 @@ const EarnedFrom = function ({ hasExpenses, CashFlowRow, label, propData }) { if (hasExpenses) { - const { childPropName, client } = propData; + const { + childPropName, + client, + } = propData; const showProps = { childName: childPropName, showChildrenAtStart: client[ childPropName ] > 0, @@ -606,7 +623,7 @@ const EarnedFrom = function ({ hasExpenses, CashFlowRow, label, propData }) { }; return ( -
+
{ CashFlowRow } @@ -615,7 +632,7 @@ const EarnedFrom = function ({ hasExpenses, CashFlowRow, label, propData }) { } else { return null; - } + } // ends if client has expenses }; // Ends diff --git a/src/forms/cashflow.js b/src/forms/cashflow.js index adba0845..0f2d3170 100644 --- a/src/forms/cashflow.js +++ b/src/forms/cashflow.js @@ -1,3 +1,5 @@ +/** @module */ + // REACT COMPONENTS import React, { Component } from 'react'; import { Form } from 'semantic-ui-react'; @@ -12,6 +14,13 @@ import { isNonNegNumber, hasOnlyNonNegNumberChars } from '../utils/validators'; import { toMoneyStr } from '../utils/prettifiers'; +/** Maximum input value of yearly income allowed in the textbox, + * monthly/daily will be scaled + * @var + */ +const MAXIMUM_VALUE_YEARLY = 999999.99; +const PERIODS_REGEX = /\./g; + /** Contains cash flow inputs, their label, and any user feedback * * @function @@ -33,14 +42,14 @@ const CashFlowRow = function ({ children, label, name, validRow, message }) { return ( + className = { `cashflow` }>
{ children } -
+