Skip to content

Commit

Permalink
Merge pull request #1032 from knod/code-style-10
Browse files Browse the repository at this point in the history
Cleans '/src/forms' through 'Household.js'. #1018
  • Loading branch information
knod committed Dec 2, 2018
2 parents 8b2ce5d + b8cd5de commit 68e9402
Show file tree
Hide file tree
Showing 7 changed files with 273 additions and 210 deletions.
5 changes: 3 additions & 2 deletions src/components/headings.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ const ContentH1 = function ({ subheading, children }) {
}

return (
<div className={ 'text-h1' } >
<div className={ `text-h1` } >
<div /> {/** div here to make sure header margin doesn\'t collapse */}
<Header
as = { `h3` }
style = {{ display: 'inline-block' }}>
style = {{ display: `inline-block` }}>
{ children }
</Header>
<ContentSubH1>{ subheading }</ContentSubH1>
Expand Down Expand Up @@ -137,6 +137,7 @@ const IntervalColumnHeadings = function ({ type }) {
* @returns Component
*/
const ColumnHeading = function ({ type, colName, style, children }) {
// @todo Move 'cashflow' stuff elsewhere
let classes = type + `-column cashflow-column header ` + colName;
return (
<Header
Expand Down
46 changes: 23 additions & 23 deletions src/forms/CurrentIncome.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { CashFlowInputsRow } from './cashflow';
// ========================================
// COMPONENTS
// ========================================
/* Move to program calculations
/* Move to program calculations:
* @todo Figure out which programs need to know which types of incomes
* and categorize/tag them accordingly.
* @todo Calc and store `client.currentUnearnedIncomeMonthly`? I think
Expand All @@ -34,7 +34,7 @@ import { CashFlowInputsRow } from './cashflow';
* (@see {@link http://www.masslegalhelp.org/housing/financial-eligibility})
*/

/** Contents of income step. Abstract to allow entry of `future` values too.
/** Contents of income step. Abstracted to allow entry of `future` values too.
*
* @function
* @param {object} props
Expand All @@ -48,15 +48,15 @@ import { CashFlowInputsRow } from './cashflow';
*/
const IncomeForm = function ({ current, time, updateClientValue, translations }) {

let type = 'income';
let type = `income`;

/** Makes sure values are propagated to 'future' properties if needed
* @member
* @depricated
*/
let ensureFuture = function (evnt, inputProps) {
updateClientValue(evnt, { ...inputProps, fillFuture: true });
}; // End ensureFuture()
};

let sharedProps = {
timeState: current,
Expand All @@ -66,73 +66,73 @@ const IncomeForm = function ({ current, time, updateClientValue, translations })
};

return (
<div className='field-aligner two-column'>
<div className={ `field-aligner two-column` }>

<IntervalColumnHeadings type={ type } />

{/* All kinds of things need to be explained. */}
{/* Need to give user more info on these. */}

<CashFlowInputsRow
{ ...sharedProps }
generic='earned'>
generic = { `earned` }>
{ translations.earnedIncome.i_label }
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic='TAFDC'>
generic = { `TAFDC` }>
{ translations.TAFDC.i_label }
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic='SSI'>
generic = { `SSI` }>
{ translations.SSI.i_label }
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic='SSDI'>
generic = { `SSDI` }>
{ translations.SSDI.i_label }
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic='childSupportIn'>
generic = { `childSupportIn` }>
{ translations.childSupport.i_label }
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic='unemployment'>
generic = { `unemployment` }>
{ translations.unemployment.i_label }
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic='workersComp'>
generic = { `workersComp` }>
{ translations.workersComp.i_label }
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic='pension'>
generic = { `pension` }>
{ translations.pension.i_label }
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic='socialSecurity'>
generic = { `socialSecurity` }>
{ translations.socialSecurity.i_label }
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic='alimony'>
generic = { `alimony` }>
{ translations.alimony.i_label }
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic='otherIncome'>
generic = { `otherIncome` }>
{ translations.otherIncome.i_label }
</CashFlowInputsRow>
<Form.Field>{ translations.i_explainSnapCalculation }</Form.Field>

</div>
); // end return
); // ends return

}; // End IncomeForm()
}; // Ends <IncomeForm>


/**
Expand All @@ -156,13 +156,13 @@ const CurrentIncomeStep = function ({ updateClientValue, navData, client, transl
formClass = { `income` }>
<IncomeForm
updateClientValue = { updateClientValue }
current={ client.current }
time={ 'current' }
translations={ translations } />
current = { client.current }
time = { 'current' }
translations = { translations } />
</FormPartsContainer>
);

}; // End CurrentIncomeStep()
};


export {
Expand Down
62 changes: 36 additions & 26 deletions src/forms/ExpensesOther.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from './cashflow';
import { IntervalColumnHeadings } from '../components/headings';

// // LOGIC
// LOGIC
import {
getMedicalExpenses,
getNonTransportCareCosts,
Expand Down Expand Up @@ -46,31 +46,34 @@ const ExpensesOther = function ({ timeState, type, time, updateClientValue }) {

{/* Is this complexity really required? Can we just
* have children and include a warning in the docs? */}
{ housingCosts > 0 ? (
{ (housingCosts > 0) ? (
<CashFlowDisplayRow
timeState = { timeState }
value = { housingCosts }
generic = { `housingCosts` }> Payments for housing
generic = { `housingCosts` }>
Payments for housing
</CashFlowDisplayRow>
) : (
null
) }

{ dependentCare > 0 ? (
{ (dependentCare > 0) ? (
<CashFlowDisplayRow
timeState = { timeState }
value = { dependentCare }
generic = { `dependentCare` }> Dependent care (other than transportation)
generic = { `dependentCare` }>
Dependent care (other than transportation)
</CashFlowDisplayRow>
) : (
null
) }

{ dependentTransport > 0 ? (
{ (dependentTransport > 0) ? (
<CashFlowDisplayRow
timeState = { timeState }
value = { dependentTransport }
generic = { `dependentTransport` }> Transportation for dependents
generic = { `dependentTransport` }>
Transportation for dependents
</CashFlowDisplayRow>
) : (
null
Expand All @@ -79,18 +82,19 @@ const ExpensesOther = function ({ timeState, type, time, updateClientValue }) {
<CashFlowInputsRow
{ ...sharedProps }
generic = { `otherExpensesTransport` }>
{ dependentTransport > 0 ? (
{ (dependentTransport > 0) ? (
`Money you spend on other transportation`
) : (
`Money you spend on transportation`
) }
</CashFlowInputsRow>

{ medExpenses > 0 ? (
{ (medExpenses > 0) ? (
<CashFlowDisplayRow
timeState = { timeState }
value = { medExpenses }
generic = { `medicalTotal` }> Medical expenses you wrote in earlier
generic = { `medicalTotal` }>
Medical expenses you wrote in earlier
</CashFlowDisplayRow>
) : (
null
Expand All @@ -99,15 +103,16 @@ const ExpensesOther = function ({ timeState, type, time, updateClientValue }) {
<CashFlowInputsRow
{ ...sharedProps }
generic = { `otherExpensesMedical` }>
{ medExpenses > 0 ? (
{ (medExpenses > 0) ? (
`Money you spend because of other medical problems`
) : (
`Money you spend because of medical problems`
) }
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic={ `otherExpensesFood` }> Money you spend on food
generic = { `otherExpensesFood` }>
Money you spend on food
</CashFlowInputsRow>
{/* Utilities are complicated because the housing
* voucher could be taking them into account and
Expand All @@ -117,48 +122,53 @@ const ExpensesOther = function ({ timeState, type, time, updateClientValue }) {
* at out of pocket expenses, it's still relevant. */}
<CashFlowInputsRow
{ ...sharedProps }
generic={ `otherExpensesPhone` }> Any phone costs
generic = { `otherExpensesPhone` }>
Any phone costs
</CashFlowInputsRow>

{ housing !== `homeless` ? (
{ (housing !== `homeless`) ? (
<CashFlowInputsRow
{ ...sharedProps }
generic={ `otherExpensesCable` }> Cable/internet costs
generic = { `otherExpensesCable` }>
Cable/internet costs
</CashFlowInputsRow>
) : (
null
)
}
) }

{ housing !== `homeless` ? (
{ (housing !== `homeless`) ? (
<CashFlowInputsRow
{ ...sharedProps }
generic={ `otherExpensesUtilities` }> Other utility costs
generic = { `otherExpensesUtilities` }>
Other utility costs
</CashFlowInputsRow>
) : (
null
)
}
) }

<CashFlowInputsRow
{ ...sharedProps }
generic={ `otherExpensesEntertainment` }> Other entertainment costs
generic = { `otherExpensesEntertainment` }>
Other entertainment costs
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic={ `otherExpensesCareProducts` }> Personal care and household goods costs
generic = { `otherExpensesCareProducts` }>
Personal care and household goods costs
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic={ `otherExpensesClothes` }> Money you spend on clothing
generic = { `otherExpensesClothes` }>
Money you spend on clothing
</CashFlowInputsRow>
<CashFlowInputsRow
{ ...sharedProps }
generic={ `otherExpensesOther` }> Any other money you spend
generic = { `otherExpensesOther` }>
Any other money you spend
</CashFlowInputsRow>
</div>
);
};
}; // Ends <ExpensesOther>


export { ExpensesOther };
Loading

0 comments on commit 68e9402

Please sign in to comment.