Skip to content

Commit

Permalink
fix: changed the url flow for academy signup flow
Browse files Browse the repository at this point in the history
  • Loading branch information
aswathy-deriv committed Feb 20, 2024
1 parent 48bc72d commit 99d00ec
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 27 deletions.
1 change: 1 addition & 0 deletions crowdin/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,7 @@
"1673505406": "An impersonator’s main goal is to steal your sensitive information and funds.",
"1673824550": "Minimum stake",
"1674164323": "<0>With a x500 multiplier</0>, if the market goes down 2%, you'll <1>lose only $100</1>. An automatic stop out kicks in if your loss reaches your stake amount.",
"1674319947": "Unfortunately, Deriv is not available in this country.",
"1674798397": "Trade multipliers on our mobile app.",
"1676292946": "Forex trading gives you the chance to profit from changes in the relative values of currencies on the forex market.",
"1677027187": "Forex",
Expand Down
31 changes: 17 additions & 14 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,13 +43,7 @@ export const useResidenceList = ({
restricted_countries?: ['Iran', 'North Korea', 'Myanmar (Burma)', 'Syria', 'Cuba']
} = {}) => {
const { send, data } = useWS('residence_list')
// console.log(
// data.map((item) => {
// if (item.disabled === 'DISABLED') {

// }
// }),
// )
useEffect(() => {
send()
}, [send])
Expand Down
49 changes: 36 additions & 13 deletions src/features/pages/signup-academy-complete/residence-form.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useState } from 'react'
import styled from 'styled-components'
import { next_btn } from './signup-academy.module.scss'
import { DropdownSearch } from 'components/elements'
Expand Down Expand Up @@ -30,6 +30,7 @@ type CountryType = {
name: string
display_name: string
value: string
disabled: string
}
type HandleNextType = () => void

Expand All @@ -50,6 +51,21 @@ const ResidenceForm = ({
setSelectedValue,
}: ResidenceFormProps) => {
const { country, citizenship } = selected_value
const [errors, setErrors] = useState(false)

const handleSelection = (country) => {
const is_country_disabled = residence_list.filter((item) => country.name === item.name)?.[0]
?.disabled
setSelectedValue((prevState) => ({
...prevState,
country: country,
}))
if (is_country_disabled) {
setErrors(true)
} else {
setErrors(false)
}
}

const form_inputs = [
{
Expand All @@ -61,6 +77,7 @@ const ResidenceForm = ({
placeholder_message: localize(
'_t_Country of residence is where you currently live._t_',
),
error_message: '_t_Unfortunately, Deriv is not available in this country._t_',
},
{
id: 'dm-citizenship-select',
Expand All @@ -73,7 +90,7 @@ const ResidenceForm = ({
),
},
]

console.log(residence_list)
return (
<Flex.Box direction="col" align="start" padding="12x">
<Typography.Paragraph weight="bold">
Expand All @@ -93,17 +110,23 @@ const ResidenceForm = ({
items={item.list}
selected_item={country}
mb="5px"
onChange={(country) => {
setSelectedValue((prevState) => ({
...prevState,
country: country,
}))
}}
onChange={(country) => handleSelection(country)}
style={{ marginTop: '16px' }}
/>
<Typography.Paragraph size="xs" padding_inline="8x">
<Localize translate_text={item.placeholder_message} />
</Typography.Paragraph>
{errors && (
<Typography.Paragraph
size="small"
padding_inline="8x"
textcolor="brand"
>
<Localize translate_text={item.error_message} />
</Typography.Paragraph>
)}
{!errors && (
<Typography.Paragraph size="small" padding_inline="8x">
<Localize translate_text={item.placeholder_message} />
</Typography.Paragraph>
)}
</>
)
} else {
Expand All @@ -124,7 +147,7 @@ const ResidenceForm = ({
}}
style={{ marginTop: '16px' }}
/>
<Typography.Paragraph size="xs" padding_inline="8x">
<Typography.Paragraph size="small" padding_inline="8x">
<Localize translate_text={item.placeholder_message} />
</Typography.Paragraph>
</>
Expand All @@ -134,7 +157,7 @@ const ResidenceForm = ({
<div className={next_btn}>
<NextButton
secondary
disabled={!citizenship || !country}
disabled={!citizenship || !country || errors || !selected_value}
onClick={handleNext}
>
<Localize translate_text="_t_Next_t_" />
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 99d00ec

Please sign in to comment.