diff --git a/package.json b/package.json index b2303b5..d8a5797 100644 --- a/package.json +++ b/package.json @@ -11,10 +11,13 @@ }, "dependencies": { "framer-motion": "^11.3.31", + "intl-tel-input": "^24.3.6", "ky": "^1.7.1", + "libphonenumber-js": "^1.11.7", "react": "^18.3.1", "react-dom": "^18.3.1", "react-input-mask": "^2.0.4", + "react-phone-number-input": "^3.4.5", "react-router-dom": "^6.26.1", "react-swipeable": "^7.0.1", "usehooks-ts": "^3.1.0", @@ -25,6 +28,7 @@ "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", "@types/react-input-mask": "^3.0.5", + "@types/react-phone-number-input": "^3.1.37", "@vitejs/plugin-react": "^4.3.1", "autoprefixer": "^10.4.20", "eslint": "^9.9.0", diff --git a/src/assets/promotion/Ellipse.png b/src/assets/promotion/Ellipse.png new file mode 100644 index 0000000..44753bb Binary files /dev/null and b/src/assets/promotion/Ellipse.png differ diff --git a/src/components/Form.tsx b/src/components/Form.tsx index 1f66308..ed971a0 100644 --- a/src/components/Form.tsx +++ b/src/components/Form.tsx @@ -1,19 +1,26 @@ +import examples from 'libphonenumber-js/mobile/examples'; +import { + formatPhoneNumber, + getCountries, + getCountryCallingCode, +} from 'react-phone-number-input'; import ReactInputMask from 'react-input-mask'; import { FormEvent, useEffect, useRef, useState } from 'react'; import { Title } from './ui/Title'; import { api } from '../api'; -import { PhoneCode } from '../types/PhoneCode'; import { Button } from './ui/Button'; import { ClassNameWrapper } from '../hocs/ClassNameWrapper'; import { LoaderIcon } from './icons/LoaderIcon'; import { ChevronUpIcon } from './icons/ChevronUpIcon'; import { ChevronDownIcon } from './icons/ChevronDownIcon'; -import { phoneCodes } from '../consts/phoneCodes'; import { ArrowRightIcon } from './icons/ArrowRightIcon'; +import { CountryCode, getExampleNumber } from 'libphonenumber-js'; export function Form() { const [name, setName] = useState(''); - const [phoneCode, setPhoneCode] = useState('+7'); + const [[phoneCode, country], setPhoneCodeAndCountry] = useState< + [string, string] + >(['', '']); const [phone, setPhone] = useState(''); const [email, setEmail] = useState(''); const [description, setDescription] = useState(''); @@ -116,17 +123,20 @@ export function Form() {
setPhone(e.target.value)} className="bg-transparent rounded-none outline-none transition-all w-full placeholder:h4 placeholder:font-medium placeholder:select-none peer" /> @@ -154,7 +164,7 @@ export function Form() {
-
+
-
+
@@ -239,11 +249,15 @@ function SelectPhoneCode({ currentPhoneCode, onClick, }: { - currentPhoneCode: PhoneCode; - onClick: (phoneCode: PhoneCode) => void; + currentPhoneCode: string; + onClick: ([phoneCode, country]: [string, string]) => void; }) { const [open, setOpen] = useState(false); + useEffect(() => { + console.log(getCountries().map(country => getCountryCallingCode(country))); + }, []); + return (