From 57263dac20b5a9be613bba68e4df2f9135aba173 Mon Sep 17 00:00:00 2001 From: Nada Date: Fri, 18 Oct 2024 15:04:03 +0400 Subject: [PATCH 1/8] fix: email verification redirection --- packages/p2p/src/pages/app.jsx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/packages/p2p/src/pages/app.jsx b/packages/p2p/src/pages/app.jsx index a679f5cc6008..db7d890c20e4 100644 --- a/packages/p2p/src/pages/app.jsx +++ b/packages/p2p/src/pages/app.jsx @@ -20,6 +20,7 @@ import './app.scss'; const App = () => { const is_production = window.location.origin === URLConstants.derivAppProduction; + const [is_p2p_standalone_enabled, isGBLoaded] = useGrowthbookGetFeatureValue({ featureFlag: 'p2p_standalone_enabled', defaultValue: false, @@ -48,7 +49,13 @@ const App = () => { React.useEffect(() => { if (isGBLoaded) { if (is_p2p_standalone_enabled) { - window.location.href = is_production ? URLConstants.derivP2pProduction : URLConstants.derivP2pStaging; + const current_url = window.location.href; + const split_url = current_url.split('/redirect/p2p')[1] || ''; + const target_url = is_production ? URLConstants.derivP2pProduction : URLConstants.derivP2pStaging; + const redirection_url = target_url + split_url; + // window.location.href = targetUrl + splitUrl; + /* eslint-disable no-console */ + console.log('targetUrl', redirection_url); } } }, [isGBLoaded, is_p2p_standalone_enabled, is_production]); @@ -178,6 +185,8 @@ const App = () => { setActionParam(url_params.get('action')); + //https://localhost:8443/redirect/p2p?action=p2p_order_confirm&order_id=134&code=nUTUKsG4&lang=EN + //http://localhost:5173/redirect/p2p?action=p2p_order_confirm&order_id=134&code=rPTLI09i&lang=EN if (!isDesktop) { setCodeParam(localStorage.getItem('verification_code.p2p_order_confirm')); } else if (!code_param) { From 4d4d640142b1c9b6a3ef6d2d866ff0061ddcc466 Mon Sep 17 00:00:00 2001 From: Nada Date: Fri, 18 Oct 2024 15:42:54 +0400 Subject: [PATCH 2/8] fix: update url --- packages/p2p/src/pages/app.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/p2p/src/pages/app.jsx b/packages/p2p/src/pages/app.jsx index db7d890c20e4..470f817cb147 100644 --- a/packages/p2p/src/pages/app.jsx +++ b/packages/p2p/src/pages/app.jsx @@ -50,7 +50,7 @@ const App = () => { if (isGBLoaded) { if (is_p2p_standalone_enabled) { const current_url = window.location.href; - const split_url = current_url.split('/redirect/p2p')[1] || ''; + const split_url = current_url.split('/p2p')[1] || ''; const target_url = is_production ? URLConstants.derivP2pProduction : URLConstants.derivP2pStaging; const redirection_url = target_url + split_url; // window.location.href = targetUrl + splitUrl; From 43baa1d269c6500eac96c24707ef3b120acba7a2 Mon Sep 17 00:00:00 2001 From: Nada Date: Fri, 18 Oct 2024 16:15:02 +0400 Subject: [PATCH 3/8] fix: console url --- packages/p2p/src/pages/app.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/p2p/src/pages/app.jsx b/packages/p2p/src/pages/app.jsx index 470f817cb147..1f2e9a203b92 100644 --- a/packages/p2p/src/pages/app.jsx +++ b/packages/p2p/src/pages/app.jsx @@ -50,7 +50,9 @@ const App = () => { if (isGBLoaded) { if (is_p2p_standalone_enabled) { const current_url = window.location.href; + /* eslint-disable no-console */ const split_url = current_url.split('/p2p')[1] || ''; + console.log('split_url', split_url); const target_url = is_production ? URLConstants.derivP2pProduction : URLConstants.derivP2pStaging; const redirection_url = target_url + split_url; // window.location.href = targetUrl + splitUrl; From 9011bbade41808420c8bd7e5e3b77be67e8d3e48 Mon Sep 17 00:00:00 2001 From: Nada Date: Fri, 18 Oct 2024 16:40:28 +0400 Subject: [PATCH 4/8] fix: removed console --- packages/p2p/src/pages/app.jsx | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/packages/p2p/src/pages/app.jsx b/packages/p2p/src/pages/app.jsx index 1f2e9a203b92..d1cb9be81ba9 100644 --- a/packages/p2p/src/pages/app.jsx +++ b/packages/p2p/src/pages/app.jsx @@ -50,14 +50,10 @@ const App = () => { if (isGBLoaded) { if (is_p2p_standalone_enabled) { const current_url = window.location.href; - /* eslint-disable no-console */ const split_url = current_url.split('/p2p')[1] || ''; - console.log('split_url', split_url); const target_url = is_production ? URLConstants.derivP2pProduction : URLConstants.derivP2pStaging; const redirection_url = target_url + split_url; - // window.location.href = targetUrl + splitUrl; - /* eslint-disable no-console */ - console.log('targetUrl', redirection_url); + window.location.href = redirection_url; } } }, [isGBLoaded, is_p2p_standalone_enabled, is_production]); From 51964858acf6d0b4598ce668325a47676b947965 Mon Sep 17 00:00:00 2001 From: Nada Date: Fri, 18 Oct 2024 16:42:20 +0400 Subject: [PATCH 5/8] fix: remove comments --- packages/p2p/src/pages/app.jsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/packages/p2p/src/pages/app.jsx b/packages/p2p/src/pages/app.jsx index d1cb9be81ba9..385020b49bb4 100644 --- a/packages/p2p/src/pages/app.jsx +++ b/packages/p2p/src/pages/app.jsx @@ -183,8 +183,6 @@ const App = () => { setActionParam(url_params.get('action')); - //https://localhost:8443/redirect/p2p?action=p2p_order_confirm&order_id=134&code=nUTUKsG4&lang=EN - //http://localhost:5173/redirect/p2p?action=p2p_order_confirm&order_id=134&code=rPTLI09i&lang=EN if (!isDesktop) { setCodeParam(localStorage.getItem('verification_code.p2p_order_confirm')); } else if (!code_param) { From 670dd0157478cb269cb8d05fc59653fb13e26eeb Mon Sep 17 00:00:00 2001 From: Nada Date: Fri, 18 Oct 2024 16:45:54 +0400 Subject: [PATCH 6/8] fix: check for action param and code param --- packages/p2p/src/pages/app.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/p2p/src/pages/app.jsx b/packages/p2p/src/pages/app.jsx index 385020b49bb4..75cb7beaead5 100644 --- a/packages/p2p/src/pages/app.jsx +++ b/packages/p2p/src/pages/app.jsx @@ -294,6 +294,8 @@ const App = () => { React.useEffect(() => { if (action_param && code_param) { + /* eslint-disable no-console */ + console.log('action_param', action_param, 'code_param', code_param); // We need an extra state since we delete the code from the query params. // Do not remove. order_store.setVerificationCode(code_param); From f7544334dab96822b95e60c738921a57a60cf032 Mon Sep 17 00:00:00 2001 From: Nada Date: Mon, 21 Oct 2024 08:22:17 +0400 Subject: [PATCH 7/8] fix: add order id --- packages/p2p/src/pages/app.jsx | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/packages/p2p/src/pages/app.jsx b/packages/p2p/src/pages/app.jsx index 75cb7beaead5..af8c33cf8ab3 100644 --- a/packages/p2p/src/pages/app.jsx +++ b/packages/p2p/src/pages/app.jsx @@ -49,14 +49,17 @@ const App = () => { React.useEffect(() => { if (isGBLoaded) { if (is_p2p_standalone_enabled) { - const current_url = window.location.href; - const split_url = current_url.split('/p2p')[1] || ''; const target_url = is_production ? URLConstants.derivP2pProduction : URLConstants.derivP2pStaging; - const redirection_url = target_url + split_url; - window.location.href = redirection_url; + if (action_param === 'p2p_order_confirm' && code_param) { + const current_url = window.location.href; + const split_url = current_url.split('/p2p')[1] || ''; + const search_params = new URLSearchParams(split_url.split('?')[1]); + const order_id = search_params.get('order'); + window.location.href = `${target_url}/redirect/p2p?action=${action_param}&order_id=${order_id}&code=${code_param}&lang=${lang}`; + } } } - }, [isGBLoaded, is_p2p_standalone_enabled, is_production]); + }, [isGBLoaded, is_p2p_standalone_enabled, is_production, action_param, code_param, lang]); React.useEffect(() => { init(); From 9cd1e9b013d2d2b33b3977f8f0d19d88ae905ff2 Mon Sep 17 00:00:00 2001 From: Nada Date: Mon, 21 Oct 2024 10:42:46 +0400 Subject: [PATCH 8/8] fix: remove console --- packages/p2p/src/pages/app.jsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/p2p/src/pages/app.jsx b/packages/p2p/src/pages/app.jsx index af8c33cf8ab3..1355f6498759 100644 --- a/packages/p2p/src/pages/app.jsx +++ b/packages/p2p/src/pages/app.jsx @@ -56,6 +56,8 @@ const App = () => { const search_params = new URLSearchParams(split_url.split('?')[1]); const order_id = search_params.get('order'); window.location.href = `${target_url}/redirect/p2p?action=${action_param}&order_id=${order_id}&code=${code_param}&lang=${lang}`; + } else { + window.location.href = target_url; } } } @@ -297,8 +299,6 @@ const App = () => { React.useEffect(() => { if (action_param && code_param) { - /* eslint-disable no-console */ - console.log('action_param', action_param, 'code_param', code_param); // We need an extra state since we delete the code from the query params. // Do not remove. order_store.setVerificationCode(code_param);