Skip to content

Commit 217efea

Browse files
authored
Merge pull request codeforboston#619 from knod/care-income
Fixes codeforboston#450 Makes sub-section for income earned because of care
2 parents c9cf247 + a2e3a26 commit 217efea

File tree

5 files changed

+110
-16
lines changed

5 files changed

+110
-16
lines changed

src/forms/CashFlowRowAfterConfirm.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class CashFlowRowAfterConfirm extends React.Component {
7878

7979
return (
8080

81-
<div>
81+
<div style={{ display: 'inline-block' }}>
8282

8383
<ControlledRadioYesNo
8484
labelText = { confirmLabel }

src/forms/CurrentExpenses.js

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
IntervalColumnHeadings,
1515
CashFlowRow,
1616
ControlledRadioYesNo,
17+
AttentionArrow,
1718
} from './formHelpers';
1819
import {
1920
ContractRentField,
@@ -33,11 +34,35 @@ import {
3334
isDisabled,
3435
isUnder13,
3536
} from '../utils/getMembers';
37+
import { getUnder13Expenses } from '../utils/cashflow';
3638

3739

3840
// ========================================
3941
// COMPONENTS
4042
// ========================================
43+
const EarnedFrom = function ({ hasExpenses, cashflowProps, children }) {
44+
45+
if (hasExpenses) {
46+
47+
// Because we're familiar with the benefit code, we
48+
// happen to know these values don't need to be reset
49+
// to 0, even if the client erases childcare expenses.
50+
// Not sure if that's a great general practice, though.
51+
return (
52+
<div className= { 'earned-from' }>
53+
<AttentionArrow />
54+
<CashFlowRowAfterConfirm { ...cashflowProps }>
55+
{ children }
56+
</CashFlowRowAfterConfirm>
57+
</div>
58+
);
59+
60+
} else {
61+
return null;
62+
}
63+
64+
}; // End EarnedFrom
65+
4166

4267
const Utilities = function ({ current, type, time, setClientProperty }) {
4368

@@ -267,7 +292,7 @@ const ExpensesFormContent = function ({ current, time, setClientProperty }) {
267292
?
268293
<div>
269294
<FormHeading subheading = { 'A "child" is a person 12 or younger. Don\'t include amounts that are paid for by other benefit programs.\n' }>
270-
Reasonable Unreimbursed Non-Medical Child(ren) Care
295+
Reasonable Unreimbursed Non-Medical Child Care
271296
</FormHeading>
272297
<IntervalColumnHeadings type={ type } />
273298
<CashFlowRow
@@ -286,12 +311,16 @@ const ExpensesFormContent = function ({ current, time, setClientProperty }) {
286311
{ ...sharedProps }
287312
generic={ 'childOtherCare' }> Other care
288313
</CashFlowRow>
289-
<CashFlowRowAfterConfirm
290-
{ ...sharedProps }
291-
generic={ 'earnedBecauseOfChildCare' }
292-
confirmLabel={ 'Does childcare allow you to make additional income?' }>
293-
<span style={{ textDecoration: 'underline' }}>Income</span> made possible by child care expenses
294-
</CashFlowRowAfterConfirm>
314+
315+
<EarnedFrom
316+
hasExpenses ={ getUnder13Expenses(current) !== 0 }
317+
cashflowProps ={{
318+
...sharedProps,
319+
generic: 'earnedBecauseOfChildCare',
320+
confirmLabel: `If you didn't have that child care, would it change how much pay you can bring home?`,
321+
}}>
322+
How much less would you make?
323+
</EarnedFrom>
295324
</div>
296325
: null
297326
}
@@ -348,12 +377,16 @@ const ExpensesFormContent = function ({ current, time, setClientProperty }) {
348377
{ ...sharedProps }
349378
generic={ 'disabledAssistance' }> Disabled/Handicapped assistance
350379
</CashFlowRow>
351-
<CashFlowRowAfterConfirm
352-
{ ...sharedProps }
353-
generic={ 'earnedBecauseOfAdultCare' }
354-
confirmLabel={ 'Do assistance expenses allow you to make additional income?' }>
355-
<span style={{ textDecoration: 'underline' }}>Income</span> made possible by assistance expenses
356-
</CashFlowRowAfterConfirm>
380+
381+
<EarnedFrom
382+
hasExpenses ={ current.disabledAssistance !== 0 }
383+
cashflowProps ={{
384+
...sharedProps,
385+
generic: 'earnedBecauseOfAdultCare',
386+
confirmLabel: `If you didn't have that assistance, would it change how much pay you can bring home?`,
387+
}}>
388+
How much less would you make?
389+
</EarnedFrom>
357390
</div>
358391
: null
359392
}

src/forms/formHelpers.js

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
Grid,
1313
// Input,
1414
Checkbox,
15+
Icon,
1516
} from 'semantic-ui-react';
1617

1718
// UTILITIES
@@ -690,7 +691,28 @@ class ControlledRadioYesNo extends Component {
690691
</div>
691692
);
692693
}
693-
}
694+
};
695+
696+
697+
var AttentionArrow = function () {
698+
699+
return (
700+
<span className={ 'attention-arrow' }>
701+
<Icon
702+
className = { 'attention-font' }
703+
fitted
704+
name = { 'angle right' }
705+
size = { 'big' } />
706+
<Icon
707+
className = { 'attention-font' }
708+
fitted
709+
name = { 'angle right' }
710+
size = { 'big' } />
711+
</span>
712+
);
713+
714+
}; // End AttentionArrow
715+
694716

695717
/** @todo Separate into different files? */
696718
export {
@@ -701,5 +723,5 @@ export {
701723
RowMessage,
702724
IntervalColumnHeadings, ColumnHeading, ManagedNumberField,
703725
CashFlowRow, MonthlyCashFlowRow, CashFlowContainer,
704-
ControlledRadioYesNo,
726+
ControlledRadioYesNo, AttentionArrow,
705727
};

src/index.css

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,31 @@ input[type=number]::-webkit-outer-spin-button {
193193
buttons are put on the left side. */
194194
.radio-yes-no {
195195
display: flex;
196+
margin-bottom: 1rem;
197+
}
198+
199+
.ui.form .radio-yes-no .field {
200+
margin-bottom: 0;
201+
}
202+
203+
.earned-from {
204+
display: flex;
205+
align-items: flex-start;
206+
margin-bottom: 1rem;
207+
}
208+
209+
.ui.form i.icon.attention-font {
210+
color: #f2711c;
211+
font-weight: 600;
212+
}
213+
214+
.attention-arrow {
215+
display: inline-block;
216+
margin-right: 1rem;
217+
}
218+
219+
.attention-arrow i.fitted.attention-font {
220+
line-height: .6em;
196221
}
197222

198223
/* Give padding between elements, but not at the start

src/utils/cashflow.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,19 @@ const getDependentCostsMonthly = function (client) {
3333
}; // End getDependentCostsMonthly()
3434

3535

36+
/**
37+
* Client's total MONTHLY costs for dependents under 13
38+
* (does not include child support paid out).
39+
*
40+
* @function
41+
* @param {object} client - `current` or `future` property of client data
42+
* @returns {number}
43+
*/
44+
const getUnder13Expenses = function (client) {
45+
return sumProps(client, UNDER13_CARE_EXPENSES);
46+
}; // End getUnder13Expenses()
47+
48+
3649
// ==================================
3750
// STRAIGHT UP INCOME
3851
// ==================================
@@ -87,6 +100,7 @@ const sumProps = function (obj, props) {
87100

88101
export {
89102
getDependentCostsMonthly,
103+
getUnder13Expenses,
90104
getSimpleGrossIncomeMonthly,
91105
getGrossUnearnedIncomeMonthly,
92106
sumProps,

0 commit comments

Comments
 (0)