-
Notifications
You must be signed in to change notification settings - Fork 21
/
index.tsx
28 lines (24 loc) · 1 KB
/
index.tsx
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
import { Form } from 'antd';
import PhoneInput from 'antd-phone-input';
import { QuestionItemProps } from 'sdc-qrf';
import { useFieldController } from '../../hooks';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const PhoneInputFixed: typeof PhoneInput = PhoneInput.default ? PhoneInput.default : PhoneInput;
export function QuestionPhone({ parentPath, questionItem }: QuestionItemProps) {
const { linkId } = questionItem;
const fieldName = [...parentPath, linkId, 0, 'value', 'string'];
const { value, onChange, disabled, formItem } = useFieldController(fieldName, questionItem);
return (
<Form.Item {...formItem}>
<PhoneInputFixed
country="us"
value={value}
disabled={disabled}
onChange={({ countryCode, areaCode, phoneNumber }) => {
onChange([countryCode, areaCode, phoneNumber].filter(Boolean).join(''));
}}
/>
</Form.Item>
);
}