SHARE
TWEET

Untitled

a guest Oct 23rd, 2019 89 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *
  3.  * AccountHolder Default Values
  4.  */
  5.  
  6. import find from 'lodash.find'
  7. import get from 'lodash.get'
  8. import {
  9.   AccountHolderMutationVariables, AccountTypeEnum, GetAccountHolderQuery, GetPersonQuery
  10. } from '@types-generated'
  11. import addressDefaultValues from 'components/AddressSubform/AddressSubform.i'
  12. import patriotActDefaultValues from 'components/PatriotActSubform/PatriotActSubform.i'
  13. import personDefaultValues, {
  14.   simplePersonDefaultValues
  15. } from 'components/PersonSubform/PersonSubform.i'
  16. import * as C from './AccountHolder.c'
  17.  
  18. export default (personData?: GetPersonQuery, submissionData?: GetAccountHolderQuery['submission']['data']) => {
  19.   const patriotAct = get(submissionData, 'patriotAct')
  20.   const subAddress = get(submissionData, 'address')
  21.   return {
  22.     [C.ACCOUNT_TYPE]: get(submissionData, C.ACCOUNT_TYPE) || AccountTypeEnum.Individual,
  23.     [C.EXISTING_ACCOUNTS]: get(submissionData, C.EXISTING_ACCOUNTS) || false,
  24.     ...personDefaultValues(
  25.       get(personData, 'currentUser') || undefined,
  26.       get(submissionData, 'accountHolder') || undefined,
  27.     ),
  28.     [C.ADDRESS]: [
  29.       addressDefaultValues(
  30.         'primary',
  31.         get(personData, 'currentUser.permanentAddress'),
  32.         find(subAddress, ['type', 'permanent']),
  33.       ),
  34.       addressDefaultValues(
  35.         'mailing',
  36.         get(personData, 'currentUser.mailingAddress'),
  37.         find(subAddress, ['type', 'mailing']),
  38.       ),
  39.     ],
  40.     [C.RESIDENT_CHECK]: get(submissionData, 'accountHolder.residentCheck') || false,
  41.     [C.GET_MAILING]:
  42.       get(find(subAddress, ['type', 'mailing']), 'line1') || get(personData, 'accountHolder.mailingAddress.line1')
  43.         ? true
  44.         : false,
  45.     [C.MARITAL_STATUS]: get(submissionData, 'maritalStatus') || '',
  46.     [C.DEPENDENTS]: get(submissionData, 'dependents') || 0,
  47.     [C.PATRIOT_ACT]: patriotActDefaultValues(patriotAct),
  48.     // TODO: Add co-applicant data when added to schema
  49.     [C.CO_APPLICANT]: simplePersonDefaultValues,
  50.   } as AccountHolderMutationVariables
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top