import map from 'lodash/map'
import uniqBy from 'lodash/uniqBy'
import orderBy from 'lodash/orderBy'
import countriesData from '../../../../../constants/country-flag.json'
import { TollFreeRegistrationForm } from '@komi-app/creator-ui'

export const SMSVolumeOptions = [
  { label: '1,000', value: '1,000' },
  { label: '10,000', value: '10,000' },
  { label: '100,000', value: '100,000' },
  { label: '250,000', value: '250,000' },
  { label: '500,000', value: '500,000' },
  { label: '750,000', value: '750,000' },
  { label: '1M', value: '1,000,000' }
]

export const countriesOptions = map(
  countriesData,
  ({ name, abbreviation }) => ({
    label: name,
    value: abbreviation
  })
)

export const countryCodeOptions = orderBy(
  uniqBy(
    map(countriesData, ({ callingCode }) => ({
      label: `+${callingCode}`,
      value: `+${callingCode}`
    })),
    'value'
  ),
  'value'
)

export const formDefaultValues: TollFreeRegistrationForm = {
  businessName: '',
  website: '',
  firstName: '',
  lastName: '',
  email: '',
  phoneNumber: {
    countryCode: '',
    number: ''
  },
  expectedMonthlyVolume: '1,000',
  addressLine1: '',
  addressLine2: '',
  city: '',
  stateProvince: '',
  zipPostalCode: '',
  country: ''
}

export const emailRegExp = /^[^\s@]+@[^\s@]+\.[^\s@]+$/
export const phoneRegExp = /^[0-9\s()-]+$/
export const websiteRegExp =
  /(\b(?:https?:\/\/)(?:www\.)?[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}(?::\d+)?(?:\/[^\s]*)?(?:\?[^\s]*)?)/
