Skip to content

Commit

Permalink
Niloofar/Fix signup redirection (#17282)
Browse files Browse the repository at this point in the history
* fix: signup redirection

* fix: review comment
  • Loading branch information
niloofar-deriv authored Oct 22, 2024
1 parent d7c7463 commit 62b3957
Showing 1 changed file with 12 additions and 48 deletions.
60 changes: 12 additions & 48 deletions packages/core/src/App/Components/Layout/Header/signup-button.jsx
Original file line number Diff line number Diff line change
@@ -1,55 +1,19 @@
import React, { useEffect, useState } from 'react';
import React from 'react';
import PropTypes from 'prop-types';
import { Button } from '@deriv/components';
import { redirectToSignUp, mobileOSDetectAsync, isSafari } from '@deriv/shared';
import { redirectToSignUp } from '@deriv/shared';
import { localize } from '@deriv/translations';
import { useGrowthbookGetFeatureValue } from '@deriv/hooks';

const SignupButton = ({ className }) => {
const [redirect_to_os_signup, setRedirectToOSSignup] = useState(false);
const [trigger_os_signup, isGBLoaded] = useGrowthbookGetFeatureValue({
featureFlag: 'trigger_os_signup',
defaultValue: false,
});

useEffect(() => {
if (isGBLoaded) {
setRedirectToOSSignup(trigger_os_signup);
}
}, [isGBLoaded, trigger_os_signup]);

const handleOutSystemsRedirection = () => {
switch (process.env.NODE_ENV) {
case 'production':
return 'https://hub.deriv.com/tradershub/signup';
case 'staging':
return 'https://staging-hub.deriv.com/tradershub/signup';
default:
return 'https://dev-hub.deriv.com/tradershub/signup';
}
};

const handleSignup = async () => {
const os = await mobileOSDetectAsync();

if (redirect_to_os_signup) {
if (os === 'iOS' || isSafari()) {
redirectToSignUp();
} else window.open(handleOutSystemsRedirection());
} else redirectToSignUp();
};

return (
<Button
id='dt_signup_button'
className={className}
has_effect
text={localize('Sign up')}
onClick={handleSignup}
primary
/>
);
};
const SignupButton = ({ className }) => (
<Button
id='dt_signup_button'
className={className}
has_effect
text={localize('Sign up')}
onClick={redirectToSignUp}
primary
/>
);

SignupButton.propTypes = {
className: PropTypes.string,
Expand Down

0 comments on commit 62b3957

Please sign in to comment.