From fc69f5e11ef6ae2f88400d29a49f3009cb91eeeb Mon Sep 17 00:00:00 2001 From: thi-investax Date: Mon, 6 Jan 2025 12:01:02 +0700 Subject: [PATCH] Experimental: ddisable yandex --- public/index.html | 231 +++++++++++++++++++------------------ src/index.tsx | 4 +- src/pages/App.tsx | 56 +++++++++ src/pages/LiffProvider.tsx | 2 +- 4 files changed, 177 insertions(+), 116 deletions(-) diff --git a/public/index.html b/public/index.html index f816dec992..25150ec698 100644 --- a/public/index.html +++ b/public/index.html @@ -1,23 +1,22 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
X
-
-
- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
X
+
+
+ + - + + - \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index dcb2ae937b..4a36fb438b 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -102,9 +102,7 @@ ReactDOM.createRoot(document.getElementById('root')!).render( - - - + diff --git a/src/pages/App.tsx b/src/pages/App.tsx index 6ead207e8e..00e20ad4d8 100644 --- a/src/pages/App.tsx +++ b/src/pages/App.tsx @@ -46,6 +46,7 @@ import SignMessageModal from 'components/SignMessageModal' import useQuery from 'hooks/useQuery' import { setJumpTaskState } from 'state/jumpTask' import { CHAINS } from 'components/Web3Provider/constants' +import liff from '@line/liff' const chains = CHAINS ? CHAINS.map((chain) => chain.id) : [] const lbpAdminRoutes = [routes.lbpCreate, routes.lbpEdit, routes.lbpDashboard, routes.adminDetails] @@ -61,6 +62,13 @@ const initSafary = () => { document.head.appendChild(script) } +// Clean URL parameters +const cleanUrlParameters = () => { + const url = new URL(window.location.href) + url.searchParams.delete('mst_challenge') + window.history.replaceState({}, document.title, url.pathname + url.search) +} + export default function App() { const getMe = useGetMe() const { isAdmin } = useRole() @@ -82,6 +90,8 @@ export default function App() { const [countryCode, setCountryCode] = useState() + const [isLiffReady, setIsLiffReady] = useState(false) + const transactionId = query.get('transaction_id') const affUnique1 = query.get('aff_unique1') const isIxSwap = whiteLabelConfig?.isIxSwap ?? false @@ -144,6 +154,47 @@ export default function App() { return (config?.pages ?? []).length > 0 ? config?.pages[0] : defaultPath }, [kyc, account, chainId, isWhitelisted, chains]) + useEffect(() => { + const initLiff = async () => { + liff + .init({ liffId: '2006746651-DmRwZed0' }) + .then(() => { + console.log('LIFF initialization is done') + console.log(liff.getAppLanguage()) + console.log(liff.getVersion()) + console.log(liff.isInClient()) + console.log(liff.isLoggedIn()) + console.log(liff.getOS()) + console.log(liff.getLineVersion()) + + setIsLiffReady(true) // Ensure LIFF initialization is complete + }) + .catch((error: any) => { + console.error(`LIFF initialization failed: ${error}`) + }) + } + + initLiff() + }, []) + + // useEffect(() => { + // const checkLoginStatus = async () => { + // if (!liff.isLoggedIn()) { + // liff.login() // Redirect to LINE login + // } else { + // const profile = await liff.getProfile() + // console.log('Logged in user profile:', profile) + // } + // } + + // checkLoginStatus() + // }, []) + + if (!isLiffReady) { + // Optional: Render a loading screen while LIFF initializes + return + } + const isAdminKyc = pathname.includes('admin') const isWhiteBackground = pathname === routes.launchpad || @@ -229,6 +280,11 @@ export default function App() { initSafary() }, []) + useEffect(() => { + // Clean up URL parameters + cleanUrlParameters() + }, []) + useEffect(() => { if (transactionId) { dispatch(setJumpTaskState({ transactionId })) diff --git a/src/pages/LiffProvider.tsx b/src/pages/LiffProvider.tsx index 3aecc94d5d..affa0c7444 100644 --- a/src/pages/LiffProvider.tsx +++ b/src/pages/LiffProvider.tsx @@ -20,7 +20,7 @@ export const LiffProvider: React.FC = ({ children }) => { useEffect(() => { liff - .init({ liffId: '2006732958-EAK9vggN' }) + .init({ liffId: '2006746651-DmRwZed0' }) .then(() => { console.log('LIFF initialization is done') setLiffObject(liff)