diff --git a/src/App.tsx b/src/App.tsx index f4731c8..c94088b 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -3,36 +3,59 @@ import "./App.css"; import Client from "mtproton/envs/browser"; function App() { - let [countriesList, setcountriesList] = useState([]); + let [countriesList, setcountriesList] = useState([] as any[]); + let phone = React.createRef(); useEffect(() => { let client = new Client({ api_id: 18987971, api_hash: "fcfd9e6ed3f9e48a360bb57cc0d59d98", }); + client.call("help.getCountriesList").then((result: any) => { console.log("country:", result); + let resp: any[] = []; result.countries.map((country: any) => { // @ts-ignore - setcountriesList((oldArray) => [ - ...oldArray, - country.default_name + ": " + country.country_codes[0].country_code, - ]); + resp.push( + country.default_name + ": " + country.country_codes[0].country_code + ); return true; }); + setcountriesList(resp); }); }, []); - // client - // .invoke({ - // _: "getCountryCode", - // }) - // .then((res) => { - // console.log(res); - // }); + let sendCode = () => { + console.log("phone:", phone.current?.value); + let client = new Client({ + api_id: 18987971, + api_hash: "fcfd9e6ed3f9e48a360bb57cc0d59d98", + }); + client.setDefaultDc(5); + client + .call("auth.sendCode", { + phone_number: phone.current?.value, + settings: { + _: "codeSettings", + }, + }) + .then((result: any) => { + console.log("auth.sendCode:", result); + }) + .catch((error: any) => { + console.log("auth.sendCode:", error); + }); + }; + + let login = () => {}; return (
+ + + + {countriesList.map((country: any, index) => { return (