import React, { useEffect, useState } from "react" import { Input, Layout, Button, Divider, Typography, Row, Col } from 'antd'; import { PhoneOutlined } from '@ant-design/icons'; import {login, loginWithCredify, initialize, Environment} from "credify-web-sdk" import { useLocation } from "react-router-dom" import {setMarketEnvironment} from "../../config"; const DEFAULT_API_KEY = "1F36ve7ONARLUKJ8mOMsoA2FFjmfvMeuUU3G9vcp6dcDyIqxmFQdnebzm2LnXoRs" const CLIENT_ID = "cc61532e-4668-4bee-b8c1-95fd0bec7f09" const { Title, Paragraph } = Typography; const { Header, Footer, Content } = Layout; function LoginPage() { const [phone, setPhone] = useState(""); const [url, setUrl] = useState(""); const location = useLocation() useEffect(() => { const urlSearch = new URLSearchParams(location.search) const env = urlSearch.get("env") const apiKey = urlSearch.get("apiKey") || DEFAULT_API_KEY const marketId = urlSearch.get("marketId") || CLIENT_ID initialize(env as Environment, apiKey, marketId) // Demo Market environment setMarketEnvironment(env as Environment) }, []) const doLogin = async () => { await login(url) } const doLogin2 = async () => { const demoUserPhone = { countryCode: "84", phoneNumber: phone } await loginWithCredify(CLIENT_ID, demoUserPhone) } return ( <>
Login Test

Login with OIDC setup URL

Please provide a set up URL for OIDC. This supports only Vietnamese phone numbers. setUrl(e.target.value)} value={url}/>

Login (this is just for debugging)

Please provide a phone number you want to log in. This supports only Vietnamese phone numbers. } onChange={(e) => setPhone(e.target.value)} value={phone}/>
) } export default LoginPage