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

Commit

Permalink
behnaz/MARK-1063/cpa by combo (#7280)
Browse files Browse the repository at this point in the history
* fix: all changes

* fix: add switzerland to cpa plan coutries
  • Loading branch information
behnaz-deriv authored Apr 15, 2024
1 parent bdbdb51 commit 8005584
Show file tree
Hide file tree
Showing 24 changed files with 46 additions and 33 deletions.
1 change: 0 additions & 1 deletion crowdin/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4266,7 +4266,6 @@
"-1474274516": "State/province*",
"-1253349870": "Town/city*",
"-490553914": "Postal/Zip code",
"-597462351": "${item.label}",
"-1120954663": "First name*",
"-1929304521": "Website/social media URL*",
"-1113902570": "Details",
Expand Down
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/common/country-base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const african_countries = [
]

// special partnership payments for this countries
export const cpa_plan_countries = ['za', 'ec', 'br', 'lk', 'uy']
export const cpa_plan_countries = ['za', 'ec', 'br', 'lk', 'uy', 'ch']

export const isEuCountry = (clients_country: (typeof eu_countries)[number]): boolean =>
eu_countries.includes(clients_country)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ import { useStatesList } from 'features/hooks/use-states-list'
import { DropdownSearch } from 'components/elements'
import { localize } from 'components/localization'
import { TString } from 'types/generics'
import { cpa_plan_countries, eu_countries } from 'common/country-base'

type AccountAddressProps = WizardStepProps<'account_address'> & {
setIsCpaPlanAff: React.Dispatch<React.SetStateAction<boolean>>
}

const AccountAddress = ({
is_individual,
affiliate_account,
residence_list,
updateData,
onValidate,
}: WizardStepProps<'account_address'>) => {
setIsCpaPlanAff,
}: AccountAddressProps) => {
const [form_data, setFormData] = useState(affiliate_account.account_address)
const [form_errors, setFormErrors] = useState({
country_error_msg: affiliate_validation['country'](form_data['country']) ?? '',
Expand All @@ -40,6 +46,13 @@ const AccountAddress = ({
state_error_msg: 'State is not valid for this country',
})
}
setIsCpaPlanAff(
changed_country
? cpa_plan_countries.includes(changed_country.symbol) ||
eu_countries.includes(changed_country.symbol)
: false,
)

setFormData({ ...form_data, country: changed_country })
}
const handleState = (changed_state) => {
Expand Down Expand Up @@ -111,7 +124,6 @@ const AccountAddress = ({
const { name, value } = e.target

setFormData((prev) => ({ ...prev, [name]: value }))

if (affiliate_validation[name]) {
const error_msg = affiliate_validation[name](value)
setFormErrors((errors) => ({
Expand Down Expand Up @@ -145,7 +157,6 @@ const AccountAddress = ({
error={form_errors[`${item.name}_error_msg`]}
onChange={item.handler}
style={{ marginTop: '16px' }}
placeholder={localize(`_t_${item.label}_t_`)}
/>
)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ import { StyledHeader } from '../utils/_affiliate-header'
import AccountCard, { AccountCardProps, MainWrapper } from '../utils/_account-card'
import { Localize } from 'components/localization'
import { useIsRtl } from 'components/hooks/use-isrtl'
import useRegion from 'components/hooks/use-region'
import Revenue from 'images/svg/signup-affiliates/revenue.svg'
import Turnover from 'images/svg/signup-affiliates/turnover.svg'
import CPA from 'images/svg/signup-affiliates/cpa.svg'
import useBuildVariant from 'features/hooks/use-build-variant'

const getPlans = (is_eu: boolean, is_cpa_plan: boolean): AccountCardProps[] => {
const getPlans = (is_cpa_plan_aff: boolean): AccountCardProps[] => {
const plans: AccountCardProps[] = [
{
value: 2,
Expand All @@ -27,7 +26,7 @@ const getPlans = (is_eu: boolean, is_cpa_plan: boolean): AccountCardProps[] => {
"_t_Earn based on each contract's payout probability or client's trade. <0>Learn more</>_t_",
},
]
if (is_eu || is_cpa_plan) {
if (is_cpa_plan_aff) {
plans.push({
value: 6,
icon: CPA,
Expand All @@ -39,22 +38,23 @@ const getPlans = (is_eu: boolean, is_cpa_plan: boolean): AccountCardProps[] => {
return plans
}

type AccountPlanProps = WizardStepProps<'account_plan'> & {
is_cpa_plan_aff: boolean
}

const AccountPlan = ({
affiliate_account,
updateData,
onValidate,
}: WizardStepProps<'account_plan'>) => {
const { region } = useBuildVariant()
is_cpa_plan_aff,
}: AccountPlanProps) => {
const [account_plan, setAccountPlan] = useState(affiliate_account.account_plan)
const { is_cpa_plan } = useRegion()
const is_rtl = useIsRtl()
const plans = getPlans(region === "eu", is_cpa_plan)

const plans = getPlans(is_cpa_plan_aff)
useEffect(() => {
updateData(account_plan)
onValidate(!!account_plan)
}, [account_plan])

return (
<MainWrapper>
<StyledHeader
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ const Wizard = ({
},
[step],
)
const [is_cpa_plan_aff, setIsCpaPlanAff] = useState(false)

return (
<WizardComponent
Expand All @@ -72,6 +73,7 @@ const Wizard = ({
}}
onValidate={setNextBtnEnabled}
residence_list={residence_list}
setIsCpaPlanAff={setIsCpaPlanAff}
/>
<AccountDetails
affiliate_account={affiliate_account}
Expand All @@ -83,6 +85,7 @@ const Wizard = ({
/>
<AccountPlan
affiliate_account={affiliate_account}
is_cpa_plan_aff={is_cpa_plan_aff}
updateData={(value: AffiliateAccountTypes['account_plan']): void => {
updateAffiliateValues<'account_plan'>(value, 'account_plan')
}}
Expand Down
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/ach.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "crwdns5019034:0crwdne5019034:0",
"-651384976": "crwdns5019036:0crwdne5019036:0",
"-1033881248": "crwdns5019038:0crwdne5019038:0"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "موظف",
"-651384976": "الجنسيات",
"-1033881248": "شاهد صفقاتنا المفتوحة"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "কর্মচারী",
"-651384976": "জাতীয়তা",
"-1033881248": "আমাদের ওপেন পজিশন দেখুন"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "Mitarbeiter",
"-651384976": "Nationalitäten",
"-1033881248": "Sehen Sie unsere offenen Stellen"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "empleados",
"-651384976": "nacionalidades",
"-1033881248": "Vea nuestros puestos disponibles"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "employés",
"-651384976": "nationalités",
"-1033881248": "Voir nos postes vacants"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "dipendenti",
"-651384976": "nazionalità",
"-1033881248": "Vedi le posizioni aperte"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "직원",
"-651384976": "출신 국적",
"-1033881248": "채용 정보 보기"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/mn.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "ажилчид",
"-651384976": "үндэстэн",
"-1033881248": "Манай нээлттэй байр суурийг үзнэ үү"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "pracowników",
"-651384976": "narodowości",
"-1033881248": "Zobacz nasze otwarte pozycje"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "funcionários",
"-651384976": "nacionalidades",
"-1033881248": "Consulte as nossas vagas"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "сотрудников",
"-651384976": "национальностей",
"-1033881248": "Смотреть вакансии"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/si.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "සේවකයින්",
"-651384976": "ජාතීන්",
"-1033881248": "අපගේ විවෘත ස්ථාන බලන්න"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/sw.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "wafanyakazi",
"-651384976": "mataifa",
"-1033881248": "Tazama nafasi zetu za kazi zilizo wazi"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "พนักงาน",
"-651384976": "สัญชาติ",
"-1033881248": "ดูตำแหน่งงานที่เปิดรับ"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "çalışanlar",
"-651384976": "milliyetler",
"-1033881248": "Açık pozisyonlarımızı görün"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "nhân viên",
"-651384976": "dân tộc",
"-1033881248": "Xem các vị trí đang tuyển"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "雇员",
"-651384976": "国籍",
"-1033881248": "查看空缺职位"
}
}
2 changes: 1 addition & 1 deletion themes/gatsby-theme-deriv/src/translations/zh_tw.json
Original file line number Diff line number Diff line change
Expand Up @@ -4626,4 +4626,4 @@
"-1165835520": "僱員",
"-651384976": "國籍",
"-1033881248": "查看空缺職位"
}
}

0 comments on commit 8005584

Please sign in to comment.