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 | 3x 3x 3x 8x 178x 178x 178x 178x 8x 178x 107x 36x 107x 107x | import React, { useEffect } from 'react';
import { Form, useI18nContext, useFormContext } from '@procore/core-react';
import { useAddCompanyContext } from '../../Context/AddCompanyContext';
export function ZipInput() {
const i18n = useI18nContext();
const { values, validateForm } = useFormContext();
const { vendorConfigurableFieldSets } = useAddCompanyContext();
useEffect(() => {
validateForm();
}, [values.country]);
const validate = (zipValue: string) => {
let errorMessage;
if (
vendorConfigurableFieldSets.zip.required &&
values.country.id === 'US' &&
zipValue.length !== 5
) {
errorMessage = i18n.t(
'views.generic.directory.add_company_package.manual_form_errors.zip_length'
);
}
return errorMessage;
};
return (
<Form.Text
name="zip"
label={i18n.t('views.generic.directory.add_company_package.postal_code')}
colStart={7}
placeholder={i18n.t(
'views.generic.directory.add_company_package.postal_code_placeholder'
)}
validate={(zipValue: string) => validate(zipValue)}
/>
);
}
|