<commit_before>import _ from 'lodash';
import fullSchema from 'vets-json-schema/dist/22-0994-schema.json';
import ReviewCardField from 'platform/forms-system/src/js/components/ReviewCardField';
import phoneUI from 'platform/forms-system/src/js/definitions/phone';
import emailUI from 'platform/forms-system/src/js/definitions/email';
import AddressViewField from 'platform/forms-system/src/js/components/AddressViewField';
import {
  uiSchema as addressUISchema,
  schema as addressSchema,
} from 'platform/forms/definitions/address';
import { PhoneEmailViewField } from '../components/PhoneEmailViewField';

import {
  contactInfoNote,
  contactInfoDescription,
} from '../content/contactInformation';

const { emailAddress, homePhone, mobilePhone } = fullSchema.properties;

const mailingAddressStartInEdit = formData => {
  if (formData) {
    const { street, city, state, postalCode } = formData;
    return !(street || city || state || postalCode);
  }
  return true;
};

const isRequiredForAddressUi = formData => {
  const { country } = _.get(formData, 'mailingAddress', {});
  return country && country === 'USA';
};

const addressUiSchema = addressUISchema(
  'Address',
  true,
  isRequiredForAddressUi,
);
const address = addressSchema(fullSchema, true);

export const uiSchema = {
  'ui:title': 'Contact information',
  'ui:description': contactInfoDescription,
  'view:phoneAndEmail': {
    'ui:title': 'Phone & email',
    'ui:field': ReviewCardField,
    'ui:options': {
      viewComponent: PhoneEmailViewField,
    },
    saveClickTrackEvent: { event: 'edu-0994-personal-information-saved' },
    homePhone: phoneUI('Home phone number'),
    mobilePhone: phoneUI('Mobile phone number'),
    emailAddress: emailUI(),
  },
  mailingAddress: {
    ...addressUiSchema,
    'ui:field': ReviewCardField,
    'ui:options': {
      ...addressUiSchema['ui:options'],
      viewComponent: AddressViewField,
      startInEdit: mailingAddressStartInEdit,
    },
    saveClickTrackEvent: { event: 'edu-0994-personal-information-saved' },
    street: {
      ...addressUiSchema.street,
      'ui:title': 'Street address',
    },
    city: addressUiSchema.city,
  },
  'view:contactInfoNote': {
    'ui:description': contactInfoNote,
  },
};

export const schema = {
  type: 'object',
  properties: {
    'view:phoneAndEmail': {
      type: 'object',
      required: ['homePhone', 'emailAddress'],
      properties: {
        homePhone,
        mobilePhone,<commit_msg>VFEP-239, switch mobile phone and home phone; and make mobilephone required. (#22691)<commit_after>import _ from 'lodash';
import fullSchema from 'vets-json-schema/dist/22-0994-schema.json';
import ReviewCardField from 'platform/forms-system/src/js/components/ReviewCardField';
import phoneUI from 'platform/forms-system/src/js/definitions/phone';
import emailUI from 'platform/forms-system/src/js/definitions/email';
import AddressViewField from 'platform/forms-system/src/js/components/AddressViewField';
import {
  uiSchema as addressUISchema,
  schema as addressSchema,
} from 'platform/forms/definitions/address';
import { PhoneEmailViewField } from '../components/PhoneEmailViewField';

import {
  contactInfoNote,
  contactInfoDescription,
} from '../content/contactInformation';

const { emailAddress, homePhone, mobilePhone } = fullSchema.properties;

const mailingAddressStartInEdit = formData => {
  if (formData) {
    const { street, city, state, postalCode } = formData;
    return !(street || city || state || postalCode);
  }
  return true;
};

const isRequiredForAddressUi = formData => {
  const { country } = _.get(formData, 'mailingAddress', {});
  return country && country === 'USA';
};

const addressUiSchema = addressUISchema(
  'Address',
  true,
  isRequiredForAddressUi,
);
const address = addressSchema(fullSchema, true);

export const uiSchema = {
  'ui:title': 'Contact information',
  'ui:description': contactInfoDescription,
  'view:phoneAndEmail': {
    'ui:title': 'Phone & email',
    'ui:field': ReviewCardField,
    'ui:options': {
      viewComponent: PhoneEmailViewField,
    },
    saveClickTrackEvent: { event: 'edu-0994-personal-information-saved' },
    mobilePhone: phoneUI('Mobile phone number'),
    homePhone: phoneUI('Home phone number'),
    emailAddress: emailUI(),
  },
  mailingAddress: {
    ...addressUiSchema,
    'ui:field': ReviewCardField,
    'ui:options': {
      ...addressUiSchema['ui:options'],
      viewComponent: AddressViewField,
      startInEdit: mailingAddressStartInEdit,
    },
    saveClickTrackEvent: { event: 'edu-0994-personal-information-saved' },
    street: {
      ...addressUiSchema.street,
      'ui:title': 'Street address',
    },
    city: addressUiSchema.city,
  },
  'view:contactInfoNote': {
    'ui:description': contactInfoNote,
  },
};

export const schema = {
  type: 'object',
  properties: {
    'view:phoneAndEmail': {
      type: 'object',
      required: ['mobilePhone', 'emailAddress'],
      properties: {
        mobilePhone,
        homePhone,
{'fraction_non_alphanumeric': 0.13496810207336524, 'fraction_numerical': 0.007177033492822967, 'mean_word_length': 4.193581780538302, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3521486', 'n_tokens_mistral': 1527, 'n_tokens_neox': 1493, 'n_words': 316}