Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | 3x 3x 3x 16x 356x 356x 356x 356x 356x 178x 178x 178x 178x 178x 24x | import React, { useState } from 'react';
import { Form, useI18nContext, useFormContext } from '@procore/core-react';
import { formatPhoneNumberInput } from '../../shared/utilities';
import { ManualAddCompanyFormData } from './schema';
export interface PhoneInputProps {
inputType: string;
}
export function PhoneInput(props: PhoneInputProps) {
const i18n = useI18nContext();
const { values, setFieldValue } = useFormContext<ManualAddCompanyFormData>();
let name = '';
let label = '';
if (props.inputType === 'business') {
name = 'business_phone';
label = 'phone_number';
} else if (props.inputType === 'fax') {
name = 'fax_number';
label = 'fax_number';
}
return (
<Form.Text
name={name}
label={i18n.t(`views.generic.directory.add_company_package.${label}`)}
colStart={1}
colWidth={12}
placeholder={i18n.t(
`views.generic.directory.add_company_package.${label}_placeholder`
)}
onChange={(event) => {
setFieldValue(
event.target.name,
formatPhoneNumberInput(event.target.value, values.country?.id)
);
}}
/>
);
}
|