Created
May 8, 2024 07:10
-
-
Save aeknarinamn/f5f00c9031fdecbb2931d654cf0e688b to your computer and use it in GitHub Desktop.
Landing.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useEffect } from 'react' | |
import Logo from './../assets/logo.png' | |
import { useNavigate } from 'react-router-dom' | |
import API from './../services/HttpClient' | |
// import { liff } from 'react-liff'; | |
import liff from '@line/liff' | |
// const liff = window.liff; | |
// const liffId = process.env.REACT_APP_LINE_LIFF_ID; | |
function Landing() { | |
const liffId = "2004804717-BRL89z0X"; | |
console.log("Version 1.0.1") | |
console.log(liffId) | |
const navigate = useNavigate(); | |
useEffect(() => { | |
// setTimeout(() => { | |
// navigate('/email-confirm') | |
// navigate('/main') | |
// }, 4000) | |
// let interval = setInterval(() => { | |
// console.log('interval running') | |
// AnimationPlay() | |
// }, 3000) | |
// return () => { | |
// clearInterval(interval) | |
// } | |
checkRegister(); | |
}, []); | |
async function checkRegister() { | |
await liff.init({ liffId: liffId }).catch(err=>{throw err}); | |
if (liff.isLoggedIn()) { | |
let profile = await liff.getProfile(); | |
const user_id = profile.userId; | |
localStorage.setItem('user_id', user_id) | |
let res = await API.post('/check-register', { | |
user_id: user_id | |
}) | |
if (res.is_found) { | |
localStorage.setItem('user_data', JSON.stringify(res.datas)) | |
navigate('/main') | |
} else { | |
navigate('/email-confirm') | |
} | |
// console.log(getProfile); | |
// this.setState({ | |
// name: getProfile.displayName, | |
// userLineID: getProfile.userId, | |
// pictureUrl: getProfile.pictureUrl, | |
// }); | |
}else{ | |
liff.login(); | |
} | |
// liff.init(async () => { | |
// const profile = await liff.getProfile(); | |
// // const user_id = localStorage.getItem('user_id'); | |
// const user_id = profile.userId; | |
// localStorage.setItem('user_id', user_id) | |
// let res = await API.post('/check-register', { | |
// user_id: user_id | |
// }) | |
// if (res.is_found) { | |
// localStorage.setItem('user_data', JSON.stringify(res.datas)) | |
// navigate('/main') | |
// } else { | |
// navigate('/email-confirm') | |
// } | |
// }); | |
} | |
// function AnimationPlay() { | |
// const imgLogo = document.getElementById('landing-logo').querySelector(`img`); | |
// imgLogo.classList.remove('play-animation') | |
// setTimeout(() => { | |
// imgLogo.classList.add('play-animation') | |
// }, 3000) | |
// } | |
return ( | |
<div id="landing-logo" className="landing h-100 d-flex justify-content-center align-items-center"> | |
<img src={Logo} alt='logo' className='play-animation' /> | |
</div> | |
) | |
} | |
export default Landing |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment