Skip to content
This repository has been archived by the owner on Sep 26, 2024. It is now read-only.

Commit

Permalink
Aswathy/DPROD-3448/Deriv Academy new Sign Up flow (#7090)
Browse files Browse the repository at this point in the history
* feat: new signup page

* fix: redirection of login page

* feat: academy app id redirection for login

* fix: window error issue

* fix: window error

* fix: app id connection and login page

* fix: changed the url flow for academy signup flow

* fix: passowrd changes

* fix: validation for password

* fix: password feature button

* fix: added the token auth

* fix: added authorized token

* fix: background color issue

* fix: redirection of url to thinkific

* fix: authorize the api call

* fix: redirection of language to english only

* fix: for handling the response for the country

* fix: flickering logo issue

* fix: flickering logo issue with use state

* fix: flickering logo

* fix: created the academy nav logo

* fix: logo fix flicker

* fix: password page

* fix: country selection and disabling button

* fix: redirection issue

* fix: logo issue

* fix: translations issue

* fix: logo issue

* fix: changed the logo

* fix: minimized the logo size

* fix: dropdown issues

* fix: sonar cloud issues

* fix: issues in the design

* fix: dropdown is reverted to old one

* fix: dropdown issues

* fix: removed the button width for residence page

* fix: focus blur

* fix: added the dropdown search changes

* fix: changed the css file

* fix: renamed the css file

* fix: percy issues

* fix: percy run issue

* fix: renamed the password files

* fix: sonarcloud issues
  • Loading branch information
aswathy-deriv authored Mar 6, 2024
1 parent d6f8359 commit 0bcbbbd
Show file tree
Hide file tree
Showing 38 changed files with 1,539 additions and 82 deletions.
68 changes: 19 additions & 49 deletions crowdin/messages.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@
"use-query-params": "^1.2.3",
"usehooks-ts": "^2.9.1",
"webpack": "^5.89.0",
"yup": "^1.3.2"
"yup": "^1.3.2",
"@zxcvbn-ts/core": "^3.0.4",
"@zxcvbn-ts/language-common": "^3.0.4"
},
"devDependencies": {
"@commitlint/cli": "^16.3.0",
Expand Down
19 changes: 15 additions & 4 deletions src/common/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import Cookies from 'js-cookie'
import { isStorageSupported } from './storage'
import { getCookiesFields, getCookiesObject, getDataLink, getDataObjFromCookies } from './cookies'
import { getAppId } from './websocket/config'
import { redirectToTradingPlatform } from './utility'
import { isBrowser, redirectToTradingPlatform } from './utility'
import { brand_name, deriv_app_id, oauth_url } from 'common/constants'

export type TSocialProvider = 'google' | 'facebook' | 'apple'

const Login = (() => {
const url = isBrowser() && window.location.href
const is_academy = isBrowser() && url.includes('academy')

const redirectToLogin = () => {
if (isStorageSupported(sessionStorage)) {
window.location.href = loginUrl()
Expand All @@ -31,9 +34,17 @@ const Login = (() => {

const sub_url = redirectToTradingPlatform()

return server_url && /qa/.test(server_url)
? `https://${server_url}/oauth2/authorize?app_id=${getAppId()}&l=${language}&brand=${brand_name.toLowerCase()}${affiliate_token_link}${cookies_link}&platform=${sub_url}`
: `${oauth_url}/oauth2/authorize?app_id=${deriv_app_id}&l=${language}&brand=${brand_name.toLowerCase()}${affiliate_token_link}${cookies_link}&platform=${sub_url}`
if (is_academy) {
if (server_url && /qa/.test(server_url)) {
return `https://${server_url}/oauth2/authorize?app_id=37228&l=${language}&brand=${brand_name.toLowerCase()}${affiliate_token_link}${cookies_link}&platform=${sub_url}`
}
return `${oauth_url}/oauth2/authorize?app_id=37228&l=${language}&brand=${brand_name.toLowerCase()}${affiliate_token_link}${cookies_link}&platform=${sub_url}`
} else {
if (server_url && /qa/.test(server_url)) {
return `https://${server_url}/oauth2/authorize?app_id=${getAppId()}&l=${language}&brand=${brand_name.toLowerCase()}${affiliate_token_link}${cookies_link}&platform=${sub_url}`
}
return `${oauth_url}/oauth2/authorize?app_id=${deriv_app_id}&l=${language}&brand=${brand_name.toLowerCase()}${affiliate_token_link}${cookies_link}&platform=${sub_url}`
}
}

const initOneAll = (provider: TSocialProvider, utm_content?: string): void => {
Expand Down
41 changes: 23 additions & 18 deletions src/common/websocket/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ const isStaging = () => isBrowser() && domain_config.staging.hostname === window
const isBeta = () => isBrowser() && domain_config.beta.hostname === window.location.hostname
const isLive = () => isProduction() || isStaging() || isBeta()
const isLocalHost = () => isBrowser() && domain_config.local.hostname === window.location.hostname

const url = isBrowser() && window.location.href
const is_academy = isBrowser() && url.includes('academy')
const getAppId = (): null | number | string => {
let app_id = null
const user_app_id = '' // you can insert Application ID of your registered application here
Expand All @@ -83,24 +84,28 @@ const getAppId = (): null | number | string => {

const config_app_id = window.localStorage.getItem('config.app_id')

if (url_app_id) {
app_id = url_app_id
} else if (config_app_id) {
app_id = config_app_id
} else if (isStaging()) {
window.localStorage.removeItem('config.default_app_id')
app_id = domain_config.staging.app_id
} else if (isBeta()) {
window.localStorage.removeItem('config.default_app_id')
app_id = domain_config.beta.app_id
} else if (user_app_id.length) {
window.localStorage.setItem('config.default_app_id', user_app_id) // it's being used in endpoint chrome extension - please do not remove
app_id = user_app_id
} else if (isLocalHost()) {
app_id = domain_config.local.app_id
if (is_academy) {
app_id = 37228
} else {
window.localStorage.removeItem('config.default_app_id')
app_id = isProduction() ? prod_app_id : domain_config.test.app_id
if (url_app_id) {
app_id = url_app_id
} else if (config_app_id) {
app_id = config_app_id
} else if (isStaging()) {
window.localStorage.removeItem('config.default_app_id')
app_id = domain_config.staging.app_id
} else if (isBeta()) {
window.localStorage.removeItem('config.default_app_id')
app_id = domain_config.beta.app_id
} else if (user_app_id.length) {
window.localStorage.setItem('config.default_app_id', user_app_id) // it's being used in endpoint chrome extension - please do not remove
app_id = user_app_id
} else if (isLocalHost()) {
app_id = domain_config.local.app_id
} else {
window.localStorage.removeItem('config.default_app_id')
app_id = isProduction() ? prod_app_id : domain_config.test.app_id
}
}
}
return app_id
Expand Down
14 changes: 12 additions & 2 deletions src/components/elements/dropdown-search.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from 'react'
import React, { useEffect, useRef, useState } from 'react'
import styled, { css } from 'styled-components'
import {
Arrow,
Expand Down Expand Up @@ -41,6 +41,7 @@ const DropdownInput = styled.input<DropdownInputProps>`
display: flex;
align-items: center;
justify-content: flex-start;
${(props) =>
props.has_short_name &&
css`
Expand Down Expand Up @@ -78,12 +79,19 @@ const DropdownSearch = ({
onChange,
selected_item,
is_alternate_style,
onClearInput,
placeholder,
...props
}: DropdownProps) => {
const [input_value, setInputValue] = useState('')
const [dropdown_items, setDropdownItems] = useState([...items])
const [is_open, dropdown_ref, nodes, handleChange, toggleListVisibility, setOpen] =
useDropdown(onChange)
const inputRef = useRef(null)

useEffect(() => {
!is_open && inputRef.current.blur()
}, [is_open])

// Auto select default value
useEffect(() => {
Expand All @@ -99,6 +107,7 @@ const DropdownSearch = ({
const handleInputChange = (e) => {
setInputValue(e.target.value)
toggleListVisibility(e)
onClearInput?.()
}

const handleSelectItem = (option: SelectedType, handled_error: FormikErrorsType) => {
Expand Down Expand Up @@ -139,6 +148,7 @@ const DropdownSearch = ({
</StyledLabel>
<DropdownInput
id="selected_dropdown"
ref={inputRef}
tabIndex={0}
onClick={toggleListVisibility}
onChange={handleInputChange}
Expand All @@ -149,7 +159,7 @@ const DropdownSearch = ({
value={input_value}
is_active={is_open}
is_alternate_style={is_alternate_style}
placeholder={label}
placeholder={placeholder}
/>
<Arrow onClick={toggleListVisibility} expanded={is_open} />
</Flex>
Expand Down
5 changes: 5 additions & 0 deletions src/components/elements/dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -286,17 +286,20 @@ export const StyledLabel = styled.label<DropdownStyledProps>`
transition: 0.25s ease transform;
transform: translateZ(0);
padding: 0 0.8rem;
margin-top: 3px;
${(props) =>
!props.is_alternate_style &&
css`
@media ${device.tabletL} {
font-size: 1.65rem;
top: 1.4rem;
margin-top: 0px;
}
@media ${device.mobileL} {
font-size: 1.5rem;
top: 1.6rem;
margin-top: 0px;
}
`}
Expand Down Expand Up @@ -439,8 +442,10 @@ export type DropdownProps = {
value?: string
disabled?: boolean
autocomplete?: string
placeholder?: string
mb?: string
is_alternate_style?: boolean
onClearInput?: () => void
} & Pick<ItemsType, 'contractSize'>

const Dropdown = ({
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@use 'features/styles/theme/theme-mixins' as *;

.static_nav_logo {
inline-size: 19.9rem;
block-size: 3.19rem;

@include breakpoints(tablet) {
inline-size: 19.9rem;
block-size: 3.19rem;
}
}
22 changes: 22 additions & 0 deletions src/features/components/templates/navigation/academy-nav/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React from 'react'
import NavTemplate from '../template'
import { static_nav_logo } from './academy-nav.module.scss'
import LogoImage from 'images/common/academy.svg'
import Link from 'features/components/atoms/link'
import Image from 'features/components/atoms/image'

const AcademyNav = () => {
return (
<NavTemplate
has_centered_items
has_centered_logo
renderLogo={() => (
<Link url={{ type: 'internal', to: '/' }}>
<Image src={LogoImage} className={static_nav_logo} />
</Link>
)}
/>
)
}

export default AcademyNav
26 changes: 18 additions & 8 deletions src/features/hooks/use-residence-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@ const formatResidenceList = ({
}
return residences
.filter(({ text: name }) => !restricted.includes(name))
.map(({ text: display_name, text: name, value: symbol, phone_idd: prefix }) => {
return {
name,
display_name,
symbol,
prefix,
}
})
.map(
({
text: display_name,
text: name,
value: symbol,
phone_idd: prefix,
disabled: disabled,
}) => {
return {
name,
display_name,
symbol,
prefix,
disabled,
}
},
)
}

export const useResidenceList = ({
Expand All @@ -34,6 +43,7 @@ export const useResidenceList = ({
restricted_countries?: ['Iran', 'North Korea', 'Myanmar (Burma)', 'Syria', 'Cuba']
} = {}) => {
const { send, data } = useWS('residence_list')

useEffect(() => {
send()
}, [send])
Expand Down
26 changes: 26 additions & 0 deletions src/features/pages/academy-complete/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react'
import Layout from 'features/components/templates/layout'
import { nav_logo } from './signup-academy-complete.module.scss'
import PopUpMenu from './pop-up-menu'
import NavTemplate from 'features/components/templates/navigation/template'
import LogoImage from 'images/common/deriv_academy.svg'
import Link from 'features/components/atoms/link'
import Image from 'features/components/atoms/image'

const SignupCompleteAcademy = () => {
return (
<Layout>
<NavTemplate
has_centered_items
has_centered_logo
renderLogo={() => (
<Link url={{ type: 'internal', to: '/' }}>
<Image src={LogoImage} className={nav_logo} />
</Link>
)}
/>
<PopUpMenu />
</Layout>
)
}
export default SignupCompleteAcademy
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
$inactive_color: #999999;
$success_color: #4bb4b3;
$warning_color: #ffad3a;
$error_field: #ec3f3f;

.deriv-helper-message {
font-size: 12px;
line-height: 1;
font-style: normal;
font-weight: 400;
color: $inactive_color;
&--general {
color: $inactive_color;
}
&--success {
color: $success_color;
}
&--warning {
color: $warning_color;
}
&--error {
color: $error_field;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React, { ReactNode } from 'react'
import clsx from 'clsx'
import { InputVariants } from '.'
import './HelperMessage.scss'

export interface HelperMessageProps {
error?: boolean
message?: ReactNode
variant?: InputVariants
disabled?: boolean
}
type TMessageVariant = Exclude<InputVariants, 'disabled'>
const MessageVariant: Record<TMessageVariant, string> = {
general: 'deriv-helper-message--general',
success: 'deriv-helper-message--success',
warning: 'deriv-helper-message--warning',
error: 'deriv-helper-message--error',
}

const HelperMessage = ({ error, message, variant = 'general', disabled }: HelperMessageProps) => (
<p
className={clsx('deriv-helper-message', {
[MessageVariant['general']]: disabled,
[MessageVariant[error ? 'error' : (variant as TMessageVariant)]]: !disabled,
})}
>
{message}
</p>
)

export default HelperMessage
Loading

0 comments on commit 0bcbbbd

Please sign in to comment.