Skip to content

Commit

Permalink
Suisin/utkarsha/upm819/phone verification flow (#16266)
Browse files Browse the repository at this point in the history
* test: added testcases for the hook

* chore: add phone otp screen

* chore: update based on comments

* chore: remove unused store in test case

* chore: add sms and whatsapp to 1 constant file

* chore: update code based on comments

* test: add tescases for counter change and title change

* chore: update code based on comments

* test: use useRealTimers

* test: mock useGetPhoneNumberOTP

* chore: update TODO comments

* chore: update code

* chore: update function for WhatsApp display

* chore: fix test case fail for confirm-phone-number

* chore: resolve failling test case

* chore: resolve conflicts otp-verification-component

* fix: prettier issue scss format

* chore: add phone verification successful modal

* chore: edit classname for verified modal

* chore: update test case describe name and ui store value

* chore: move successful modal inside phone-number-verification-page

* chore: update phone-number-verified-modal and remove ui store values

* chore: revert unused changes

* chore: add routes to personal details

* chore: fix matchMedia failling in test case

* chore: update test case title

* chore: replace modal with quill-ui modal

* chore: update test case to pass first for phone number verified modal

* fix: test case

* chore: update code base on comments

* chore: resolve integration test failling

* chore: update code based on comments

* chore: add didnt get the code modal for phone verification

* chore: update test case and files for didnt get the code modal

* chore: update code based on comments

* chore: update test case based on comments

* chore: update helpers.ts based on comments

* chore: update based on comments

* chore: move convertPhoneTypeDisplay to correct folders

* chore: update resend-code-timer test case to use jest.advanceTimer

* chore: update show to show_otp_verification

* chore: update to use localise function

* chore: create verification-link-expired-modal

* chore: update all quill-ui packages

* chore: update test case title

* chore: update package version for quill-ui

* chore: create useGetEmailVerificationOTP hooks

* chore: implement callback for hooks

* chore: try to add InputGroupButton for phone-verification

* chore: update code based on comments

* chore: remove useGetEmailVerificationOTP and use useVerifyEmail instead

* chore: remove Input field from component and use quill-ui TextField and InputGroupButton

* chore: update scss

* chore: fix test failing for resend-code-timer.spec.tsx

* chore: implement phone number otp api hooks

* chore: update test case for useSendOTPVerificationCode

* chore: update otp-verification.spec.tsx

* chore: update title for otp verification and add test for Phone number verified modal

* chore: update naming to is_phone_number_verified based on comment

* chore: update localize in hooks

* fix: type error

* chore: resolve build fail issue

* chore: add localize at useSendOTPVerificationCode

* chore: implement error status when phone number is invalid

* chore: fix test case for confirm phone number

* chore: rename test case title and hooks based on comment

* chore: moved validePhoneNumber to a constant file

* chore: add error screens for email otp invalid

* chore: remove unused package in hooks

* chore: added useSetSettings hooks and change logic using new implemented hooks

* chore: update test case and localStorage setItem

* chore: rename handleError to formatError

* chore: change useSetSettings to useSettings and modify the hooks

* chore: update based on comments

* chore: remove conditional check for handleError and make it into 2 different formatError

* chore: include comments in hooks for requestSMS and requestWhatsapp

* chore: update useSEndOTPVerificationCode test case

* chore: add routing from email verification link

* chore: remove comments

* chore: implement timer from BE

* chore: update code based on comment

* chore: use 1 useState for otp request

* chore: move to 1 useState based on comment

* chore: rename phone_number_verification and move setIsLoading in if else statement based on comment

* chore: move setTimer useState into otp-verification

* chore: need to use React.useCallback to solve blinking issue for reInitalizeGetSettings

* chore: remove setIsButtonDisabled in validate next_email_otp_request function

* chore: update code based on comments

* chore: update to use is_email_verified

* chore: add WS call when redirect from notification tray

* chore: remove unused comment

* chore: update quill-ui in package.json

* chore: added Math.round for minutes timer

* chore: update code to have better user flow

* chore: realign code for BE integration

* chore: add timer to personal-details, expired modal and notification

* chore: remove unused dayjs in account package

* chore: update quill-ui version and updated codes for expired-link-modal

* chore: update verification link expired modal

* chore: add timer countdown snackbar in confirm your phone number page

* chore: update commented paragraph and remove TODOs

* chore: update test case and remove ts-expect-error

* chore: remove unused ...rest

* chore: include !! to phone_number_verification.verified

* chore: update verify button to clear all possible stored value

* chore: update code to fix demo session bugs

* chore: remove is_mobile from ui-store and update to latest useDevice

* chore: fix test case failling and update code based on comments

* chore: remove phone_number_verify?.verified logic check in personal details

* chore: fix test case and remove unused imports

* chore: update to fix test case

* chore: update code based on comments

* chore: update test case

* chore: update code based on comments

* chore: revert icons file

* chore: update code based on comments

* chore: update packages version and fix useSetting based on comments

* chore: update code based on comments

* chore: update verify-button.spec.tsx based on comment

* chore: update quill-ui version and code based on comments

* chore: update positions test case with scrollTo fix

* chore: remove @ts-expected-error

* fix: console log verified not found issue and clear otp after click resend code

* chore: fix authorize issue

* chore: update quill-ui version for console log fix

* chore: fix verification link expired rerendering issue

* fix: clicks on resend link or send via whatsapp redirect user back to confirm phone number page

* chore: have to include color black in button so the underline will be black

* chore: update quill-ui version

* chore: update to include type number in InputGroupButton

* chore: update useVerifyEmail hooks to fix button disabled issue

* chore: should run timer also if error is returned from BE

* fix: console error on clicking verify button in personal details section

* chore: fix unmounted console log issue

* chore: use useEffect directly from react package

* chore: fix test case fail issue

* chore: fix link-expired-modal cause added a boolean value in the hooks

* chore: replace TextField with TextFieldAddOn for confirm your phone number page

* chore: create new functional call in useVerifyEmail and remove deprecated tag

* chore: fix console log issue after clicking on verify button

* fix: legacywonicon not displaying properly by updating the version

* chore: update quill-ui version to fix input validation issue

* chore: update quill-ui verison to fix dark mode + issue

* chore: use lazyLoading for phone number verification

* chore: fix verify-button test case based on comment

* chore: update codes based on comment

* fix: resolve conflicts

* chore: revert phone number verification changes with master

* chore: make verify button disabled once user edit personal details and added growthbook

* chore: scss changes to fix tablet view issue

* chore: hide notification and show demo message when user is in demo account

* chore: implement growthbook in AppContent and added client store for it

* chore: change to redirect user back to personal details once they switch to demo

* chore: move popover tablet view from right to top

* chore: hide verify button when phone number changes

* chore: update growthbook usage based on comment

* chore: update useEffect in AppContent

* Suisin/utkarsha/upm819/phone verification flow (#16157)

* feat: move timer to diff component

* refactor: replace timer code with component

* test: testcase for resend-code-timer

* chore: add test case on cancel phone verification modal and move to a seperate component

* chore: update test case for phone-verification-page

* chore: update codes based on comments

* chore: update data testid

* fix: change text for email and phone, add TODOs

* chore: edit testcases

* chore: change prop to text

* test: update testcase

* chore: use ReturnType instead of NodeJS.timer

* chore: update quill-ui package and remove previous build config edits

* feat: integrate phone number challenge api

* chore: add comments

* chore: add ThemeProvider in phone verification

* chore: use states instead of useRef and update testcase

* test: added testcases for the hook

* chore: add phone otp screen

* chore: update based on comments

* chore: remove unused store in test case

* chore: add sms and whatsapp to 1 constant file

* chore: update code based on comments

* test: add tescases for counter change and title change

* chore: update code based on comments

* test: use useRealTimers

* test: mock useGetPhoneNumberOTP

* chore: update TODO comments

* chore: update code

* chore: update function for WhatsApp display

* chore: fix test case fail for confirm-phone-number

* chore: resolve failling test case

* chore: resolve conflicts otp-verification-component

* fix: prettier issue scss format

* chore: add phone verification successful modal

* chore: edit classname for verified modal

* chore: update test case describe name and ui store value

* chore: move successful modal inside phone-number-verification-page

* chore: update phone-number-verified-modal and remove ui store values

* chore: revert unused changes

* chore: add routes to personal details

* chore: fix matchMedia failling in test case

* chore: update test case title

* chore: replace modal with quill-ui modal

* chore: update test case to pass first for phone number verified modal

* fix: test case

* chore: update code base on comments

* chore: resolve integration test failling

* chore: update code based on comments

* chore: add didnt get the code modal for phone verification

* chore: update test case and files for didnt get the code modal

* chore: update code based on comments

* chore: update test case based on comments

* chore: update helpers.ts based on comments

* chore: update based on comments

* chore: move convertPhoneTypeDisplay to correct folders

* chore: update resend-code-timer test case to use jest.advanceTimer

* chore: update show to show_otp_verification

* chore: update to use localise function

* chore: create verification-link-expired-modal

* chore: update all quill-ui packages

* chore: update test case title

* chore: update package version for quill-ui

* chore: create useGetEmailVerificationOTP hooks

* chore: implement callback for hooks

* chore: try to add InputGroupButton for phone-verification

* chore: update code based on comments

* chore: remove useGetEmailVerificationOTP and use useVerifyEmail instead

* chore: remove Input field from component and use quill-ui TextField and InputGroupButton

* chore: update scss

* chore: fix test failing for resend-code-timer.spec.tsx

* chore: implement phone number otp api hooks

* chore: update test case for useSendOTPVerificationCode

* chore: update otp-verification.spec.tsx

* chore: update title for otp verification and add test for Phone number verified modal

* chore: update naming to is_phone_number_verified based on comment

* chore: update localize in hooks

* fix: type error

* chore: resolve build fail issue

* chore: add localize at useSendOTPVerificationCode

* chore: implement error status when phone number is invalid

* chore: fix test case for confirm phone number

* chore: rename test case title and hooks based on comment

* chore: moved validePhoneNumber to a constant file

* chore: add error screens for email otp invalid

* chore: remove unused package in hooks

* chore: added useSetSettings hooks and change logic using new implemented hooks

* chore: update test case and localStorage setItem

* chore: rename handleError to formatError

* chore: change useSetSettings to useSettings and modify the hooks

* chore: update based on comments

* chore: remove conditional check for handleError and make it into 2 different formatError

* chore: include comments in hooks for requestSMS and requestWhatsapp

* chore: update useSEndOTPVerificationCode test case

* chore: add routing from email verification link

* chore: remove comments

* chore: implement timer from BE

* chore: update code based on comment

* chore: use 1 useState for otp request

* chore: move to 1 useState based on comment

* chore: rename phone_number_verification and move setIsLoading in if else statement based on comment

* chore: move setTimer useState into otp-verification

* chore: need to use React.useCallback to solve blinking issue for reInitalizeGetSettings

* chore: remove setIsButtonDisabled in validate next_email_otp_request function

* chore: update code based on comments

* chore: update to use is_email_verified

* chore: add WS call when redirect from notification tray

* chore: remove unused comment

* chore: update quill-ui in package.json

* chore: added Math.round for minutes timer

* chore: update code to have better user flow

* chore: realign code for BE integration

* chore: add timer to personal-details, expired modal and notification

* chore: remove unused dayjs in account package

* chore: update quill-ui version and updated codes for expired-link-modal

* chore: update verification link expired modal

* chore: add timer countdown snackbar in confirm your phone number page

* chore: update commented paragraph and remove TODOs

* chore: update test case and remove ts-expect-error

* chore: remove unused ...rest

* chore: include !! to phone_number_verification.verified

* chore: update verify button to clear all possible stored value

* chore: update code to fix demo session bugs

* chore: remove is_mobile from ui-store and update to latest useDevice

* chore: fix test case failling and update code based on comments

* chore: remove phone_number_verify?.verified logic check in personal details

* chore: fix test case and remove unused imports

* chore: update to fix test case

* chore: update code based on comments

* chore: update test case

* chore: update code based on comments

* chore: revert icons file

* chore: update code based on comments

* chore: update packages version and fix useSetting based on comments

* chore: update code based on comments

* chore: update verify-button.spec.tsx based on comment

* chore: update quill-ui version and code based on comments

* chore: update positions test case with scrollTo fix

* chore: remove @ts-expected-error

* fix: console log verified not found issue and clear otp after click resend code

* chore: fix authorize issue

* chore: update quill-ui version for console log fix

* chore: fix verification link expired rerendering issue

* fix: clicks on resend link or send via whatsapp redirect user back to confirm phone number page

* chore: have to include color black in button so the underline will be black

* chore: update quill-ui version

* chore: update to include type number in InputGroupButton

* chore: update useVerifyEmail hooks to fix button disabled issue

* chore: should run timer also if error is returned from BE

* fix: console error on clicking verify button in personal details section

* chore: fix unmounted console log issue

* chore: use useEffect directly from react package

* chore: fix test case fail issue

* chore: fix link-expired-modal cause added a boolean value in the hooks

* chore: replace TextField with TextFieldAddOn for confirm your phone number page

* chore: create new functional call in useVerifyEmail and remove deprecated tag

* chore: fix console log issue after clicking on verify button

* fix: legacywonicon not displaying properly by updating the version

* chore: update quill-ui version to fix input validation issue

* chore: update quill-ui verison to fix dark mode + issue

* chore: use lazyLoading for phone number verification

* chore: fix verify-button test case based on comment

* chore: update codes based on comment

* fix: resolve conflicts

* chore: revert phone number verification changes with master

* chore: make verify button disabled once user edit personal details and added growthbook

* chore: scss changes to fix tablet view issue

* chore: hide notification and show demo message when user is in demo account

* chore: implement growthbook in AppContent and added client store for it

* chore: change to redirect user back to personal details once they switch to demo

* chore: move popover tablet view from right to top

* chore: hide verify button when phone number changes

* chore: update growthbook usage based on comment

* chore: update useEffect in AppContent

---------

Co-authored-by: utkarsha-deriv <utkarsha@regentmarkets.com>
Co-authored-by: amina-deriv <amina@regentmarkets.com>
Co-authored-by: amina-deriv <84661147+amina-deriv@users.noreply.github.com>

* chore: update growthbook value in AppContent

* chore: remove is_phone_number_verification_enabled

* chore: solve redirect not working issue

* chore: update packages for deriv-com/quill-ui

* fix: removed clean urls from vercel dr json (#16249)

* Revert "[WALL] george / WALL-4522 / Add ce_cashier_deposit_onboarding_form an…" (#16246)

This reverts commit a10f85c.

* [DTRA] Maryia/DTRA-1546/fix: [V2] style & animation for Digits Current spot price + active_symbols request (#16225)

* fix: styles & animation for current spot for digit trade types

* fix: active_symbols call for rise/fall and higher/lower

* fix: useActiveSymbols usage

* fix: active_symbols call with relevant barrier_category + error handling same like in prod

* chore: replace localize import with new library (#16140)

* chore: replace localize import with new library

* chore: removed unused component

* chore: update usePhoneNumberVerificationSetTimer to use useServerTime

* [WALL] Lubega / WALL-4549 / Wallets initial translations setup (#16158)

* feat: draft wallet translations

* feat: initial wallets translations setup

* chore: clean up code

* fix: resolve error

* fix: resolve error

* chore: update text component

* fix: env variables and language switcher

* [WALL] Lubega/ WALL-4549 / Wallets multi language support (#16069)

* feat: draft wallet translations

* feat: initial wallets translations setup

* chore: clean up code

* fix: resolve error

* fix: resolve error

* chore: update text component

* fix: env variables and language switcher

* fix: update locked scenarios

* [WALL] Lubega / Wallets translations update (#16112)

* feat: draft wallet translations

* feat: initial wallets translations setup

* chore: clean up code

* fix: resolve error

* fix: resolve error

* chore: update text component

* fix: env variables and language switcher

* Suisin/fix: text not bold in email and password page (#16094)

* fix: text not bold in email and password page

* chore: update package version to use specific version

* Fasih/COJ-1275/ Implemented lazy load (#16020)

* chore: implemented lazy load on financial assessment and trading assesment

* chore: working on personal details

* chore: removed lazy load from personal details

---------

Co-authored-by: amina-deriv <84661147+amina-deriv@users.noreply.github.com>

* [WALL] george / WALL-4402 / feat(wallets): ✨ add analytics to track wallets events  (#16004)

* feat(wallets): ✨ add wallet migration analytic

* chore: 🔇 suppress ts error

* chore: align with master

* fix: prettified code

* chore: fix isOpen condition appear twice

* fix: update locked scenarios

---------

Co-authored-by: Sui Sin <103026762+suisin-deriv@users.noreply.github.com>
Co-authored-by: fasihali-deriv <121229483+fasihali-deriv@users.noreply.github.com>
Co-authored-by: amina-deriv <84661147+amina-deriv@users.noreply.github.com>
Co-authored-by: George Usynin <103181646+heorhi-deriv@users.noreply.github.com>

* fix: update github workflow

* fix: getWalletHeaderButtons format

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* Update index.js

* chore: remove eslint auto format

* chore: test remove line

* chore: test remove line

* chore: test remove line

* chore: test remove line

* chore: test remove line

* chore: update deriv-com/translations version

---------

Co-authored-by: Sui Sin <103026762+suisin-deriv@users.noreply.github.com>
Co-authored-by: fasihali-deriv <121229483+fasihali-deriv@users.noreply.github.com>
Co-authored-by: amina-deriv <84661147+amina-deriv@users.noreply.github.com>
Co-authored-by: George Usynin <103181646+heorhi-deriv@users.noreply.github.com>
Co-authored-by: nijil-deriv <nijil@deriv.com>

* translations: 📚 sync translations with crowdin (#16262)

Co-authored-by: DerivFE <fe-access@regentmarkets.com>

* ci: change env usage (#16264)

* Ako/ override installCommand of vercel (#16257)

* build: override installcommand of vercel

* build: override installcommand of vercel (#16256)

* ci: fix the staging vercel env

* chore: update to use useGrowthbookGetFeatureFlag

---------

Co-authored-by: utkarsha-deriv <utkarsha@regentmarkets.com>
Co-authored-by: amina-deriv <amina@regentmarkets.com>
Co-authored-by: amina-deriv <84661147+amina-deriv@users.noreply.github.com>
Co-authored-by: nada-deriv <122768621+nada-deriv@users.noreply.github.com>
Co-authored-by: Maryia <103177211+maryia-deriv@users.noreply.github.com>
Co-authored-by: Likhith Kolayari <98398322+likhith-deriv@users.noreply.github.com>
Co-authored-by: lubega-deriv <142860499+lubega-deriv@users.noreply.github.com>
Co-authored-by: fasihali-deriv <121229483+fasihali-deriv@users.noreply.github.com>
Co-authored-by: George Usynin <103181646+heorhi-deriv@users.noreply.github.com>
Co-authored-by: nijil-deriv <nijil@deriv.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: DerivFE <fe-access@regentmarkets.com>
Co-authored-by: Ali(Ako) Hosseini <ali.hosseini@deriv.com>
  • Loading branch information
14 people committed Jul 30, 2024
1 parent 5bae279 commit 3c7980e
Show file tree
Hide file tree
Showing 93 changed files with 913 additions and 1,026 deletions.
4 changes: 0 additions & 4 deletions .github/actions/build/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ inputs:
description: 'Node environment'
required: false
default: 'test'
CROWDIN_WALLETS_API_KEY:
description: 'Crowdin wallets api key'
required: false
DATADOG_CLIENT_TOKEN:
description: 'Datadog client token'
required: false
Expand Down Expand Up @@ -64,7 +61,6 @@ runs:
- name: Build all packages
env:
NODE_ENV: ${{ inputs.NODE_ENV }}
CROWDIN_WALLETS_API_KEY: ${{ inputs.CROWDIN_WALLETS_API_KEY }}
DATADOG_APPLICATION_ID: ${{ inputs.DATADOG_APPLICATION_ID }}
DATADOG_CLIENT_TOKEN: ${{ inputs.DATADOG_CLIENT_TOKEN }}
DATADOG_CLIENT_TOKEN_LOGS: ${{ inputs.DATADOG_CLIENT_TOKEN_LOGS }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build_docker_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ jobs:
run: npm run build:prod

- name: Run Build Docker
run: docker build -t ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/${{ env.tag_name }} . --platform=linux/amd64
run: docker build -t ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/$tag_name . --platform=linux/amd64

- name: Run Tag Docker
run: docker tag ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/${{ env.tag_name }} ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/${{ env.tag_name }}
run: docker tag ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/$tag_name ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/$tag_name

- name: Run Push Docker
run: docker push ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/${{ env.tag_name }}
run: docker push ${{ secrets.WEB_ACCESS_DOCKERHUB_USERNAME }}/$tag_name
3 changes: 1 addition & 2 deletions .github/workflows/release_staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
uses: "./.github/actions/build"
with:
NODE_ENV: production
CROWDIN_WALLETS_API_KEY: ${{ secrets.CROWDIN_WALLETS_API_KEY }}
IS_GROWTHBOOK_ENABLED: ${{ vars.IS_GROWTHBOOK_ENABLED }}
DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }}
DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }}
Expand Down Expand Up @@ -60,6 +59,6 @@ jobs:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_API_TOKEN }}
ENVIRONMENT: Production
ENVIRONMENT: Preview
VERCEL_SCOPE: deriv
ALIAS_DOMAIN_URL: 'staging-app-dr.binary.sx'
1 change: 0 additions & 1 deletion .github/workflows/release_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
uses: "./.github/actions/build"
with:
NODE_ENV: production
CROWDIN_WALLETS_API_KEY: ${{ secrets.CROWDIN_WALLETS_API_KEY }}
DATADOG_APPLICATION_ID: ${{ vars.DATADOG_APPLICATION_ID }}
IS_GROWTHBOOK_ENABLED: ${{ vars.IS_GROWTHBOOK_ENABLED }}
DATADOG_CLIENT_TOKEN: ${{ vars.DATADOG_CLIENT_TOKEN }}
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/sync-translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ on:
- master
schedule:
- cron: '0 */12 * * *'

jobs:
sync_translations:
permissions:
contents: write
runs-on: ubuntu-latest
environment: Staging
steps:
- name: Sync translations
- name: Sync accounts translations
uses: deriv-com/translations/.github/actions/extract_and_sync_translations@main
with:
PROJECT_NAME: ${{ vars.ACC_R2_PROJECT_NAME }}
Expand All @@ -26,3 +26,15 @@ jobs:
R2_SECRET_ACCESS_KEY: ${{ secrets.ACC_R2_SECRET_ACCESS_KEY }}
R2_BUCKET_NAME: ${{ secrets.ACC_R2_BUCKET_NAME }}
PROJECT_SOURCE_DIRECTORY: "packages/account/src"
- name: Sync wallets translations
uses: deriv-com/translations/.github/actions/extract_and_sync_translations@main
with:
PROJECT_NAME: ${{ vars.WALLETS_PROJECT_NAME }}
CROWDIN_BRANCH_NAME: staging
CROWDIN_PROJECT_ID: ${{ secrets.WALLETS_CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.ACC_CROWDIN_PERSONAL_TOKEN }}
R2_ACCOUNT_ID: ${{ secrets.ACC_R2_ACCOUNT_ID }}
R2_ACCESS_KEY_ID: ${{ secrets.ACC_R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.ACC_R2_SECRET_ACCESS_KEY }}
R2_BUCKET_NAME: ${{ secrets.ACC_R2_BUCKET_NAME }}
PROJECT_SOURCE_DIRECTORY: "packages/wallets/src"
48 changes: 40 additions & 8 deletions __mocks__/translation.mock.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,51 @@
const Localize = ({ i18n_default_text, values }) => {
// Replace placeholders in the default text with actual values
const localizedText = i18n_default_text.replace(/\{\{(\w+)\}\}/g, (match, key) => values[key] || match);
import React from 'react';

return localizedText || null;
const Localize = ({ i18n_default_text, components = [], values = {} }) => {
// Split text into parts, extracting placeholders for components and values
const parts = i18n_default_text.split(/(<\d+>.*?<\/\d+>|{{\w+}})/g);

const replaceValues = text => {
return text.replace(/{{(\w+)}}/g, (match, key) => values[key] || match);
};

return (
<>
{parts.map((part, index) => {
// Replace component placeholders with actual components
const componentMatch = part.match(/<(\d+)>(.*?)<\/\1>/);

if (componentMatch) {
const componentIndex = parseInt(componentMatch[1]);

// Replace values wrapped in components with actual values
const content = replaceValues(componentMatch[2]);
const Component = components[componentIndex];
return Component ? React.cloneElement(Component, { key: index, children: content }) : content;
}

// Replace value placeholders with actual values
const valueMatch = part.match(/{{(\w+)}}/);
if (valueMatch) {
const valueKey = valueMatch[1];
return values[valueKey] || part;
}
return part;
})}
</>
);
};

const mockFn = jest.fn((text, args) => {
return text.replace(/{{(.*?)}}/g, (_, match) => args[match.trim()]);
});

// Mock for useTranslations hook
const useTranslations = () => ({
localize: jest.fn((text, args) => {
return text.replace(/{{(.*?)}}/g, (_, match) => args[match.trim()]);
}),
localize: mockFn,
currentLang: 'EN',
});

const localize = jest.fn(text => text);
const localize = mockFn;

const getAllowedLanguages = jest.fn(() => ({ EN: 'English', VI: 'Tiếng Việt' }));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { Field, FormikValues, useFormikContext } from 'formik';
import { Dropdown, SelectNative } from '@deriv/components';
import { EMPLOYMENT_VALUES, TEmploymentStatus, shouldHideOccupationField } from '@deriv/shared';
import { localize } from '@deriv/translations';
import { useTranslations } from '@deriv-com/translations';
import { useDevice } from '@deriv-com/ui';
import {
getAccountTurnoverList,
Expand Down Expand Up @@ -40,13 +40,14 @@ type TFinancialInformationProps = {
const FinancialDetailsDropdownField = ({
dropdown_list,
field_key,
placeholder = localize('Please select'),
placeholder,
label,
}: TFinancialDetailsDropdownFieldProps) => {
const { values, handleChange, handleBlur, touched, errors, setFieldValue } = useFormikContext<{
[key: string]: string;
}>();
const { isDesktop } = useDevice();
const { localize } = useTranslations();
return (
<Field name={field_key}>
{({ field }: FormikValues) => (
Expand All @@ -67,7 +68,7 @@ const FinancialDetailsDropdownField = ({
/>
) : (
<SelectNative
placeholder={placeholder}
placeholder={placeholder ?? localize('Please select')}
name={field.name}
label={label}
list_items={dropdown_list}
Expand All @@ -90,14 +91,15 @@ const FinancialDetailsDropdownField = ({
const FinancialDetailsOccupationDropdownField = ({
dropdown_list,
field_key,
placeholder = localize('Please select'),
placeholder,
label,
employment_status,
}: TFinancialDetailsDropdownFieldProps) => {
const { values, handleChange, handleBlur, touched, errors, setFieldValue } = useFormikContext<{
[key: string]: string;
}>();
const { isDesktop } = useDevice();
const { localize } = useTranslations();

const getFormattedOccupationValues = () =>
employment_status === EMPLOYMENT_VALUES.EMPLOYED && values?.occupation === EMPLOYMENT_VALUES.UNEMPLOYED
Expand Down Expand Up @@ -128,7 +130,7 @@ const FinancialDetailsOccupationDropdownField = ({
) : (
<SelectNative
{...field}
placeholder={placeholder}
placeholder={placeholder ?? localize('Please select')}
name={field.name}
label={label}
list_items={dropdown_list}
Expand All @@ -152,6 +154,8 @@ const FinancialDetailsOccupationDropdownField = ({
* @returns {JSX.Element}
*/
const FinancialInformation = ({ employment_status }: TFinancialInformationProps) => {
const { localize } = useTranslations();

return (
<React.Fragment>
<FinancialDetailsDropdownField
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Button, Icon, Modal, Text, MobileDialog } from '@deriv/components';
import { localize } from '@deriv/translations';
import { useTranslations } from '@deriv-com/translations';
import { useDevice } from '@deriv-com/ui';

type RiskToleranceWarningModalProps = {
Expand All @@ -21,6 +21,8 @@ const RiskToleranceWarningModal = ({
has_sub_header = false,
}: RiskToleranceWarningModalProps) => {
const { isDesktop } = useDevice();
const { localize } = useTranslations();

return (
<React.Fragment>
{isDesktop ? (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { MobileDialog, Modal } from '@deriv/components';
import { localize } from '@deriv/translations';
import { useTranslations } from '@deriv-com/translations';
import { useDevice } from '@deriv-com/ui';

type TestWarningModalProps = {
Expand All @@ -11,6 +11,8 @@ type TestWarningModalProps = {

const TestWarningModal = ({ show_risk_modal, body_content, footer_content }: TestWarningModalProps) => {
const { isDesktop } = useDevice();
const { localize } = useTranslations();

return (
<React.Fragment>
{isDesktop ? (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import clsx from 'clsx';
import { Field } from 'formik';
import { Dropdown, Text, SelectNative } from '@deriv/components';
import { localize } from '@deriv/translations';
import { useTranslations } from '@deriv-com/translations';
import { TTradingAssessmentForm, TQuestion } from 'Types';
import { MAX_QUESTION_TEXT_LENGTH } from '../../Constants/trading-assessment';
import { useDevice } from '@deriv-com/ui';
Expand Down Expand Up @@ -45,6 +45,7 @@ const TradingAssessmentDropdown = ({
}, [values]);

const { isDesktop } = useDevice();
const { localize } = useTranslations();

const checkIfAllFieldsFilled = () => {
if (values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import clsx from 'clsx';
import { observer, useStore } from '@deriv/stores';
import { Formik, Form, FormikErrors, FormikHelpers } from 'formik';
import { Button, Modal, Text } from '@deriv/components';
import { localize, Localize } from '@deriv/translations';
import { useTranslations, Localize } from '@deriv-com/translations';
import TradingAssessmentRadioButton from './trading-assessment-radio-buttons';
import TradingAssessmentDropdown from './trading-assessment-dropdown';
import { getTradingAssessmentQuestions } from '../../Constants/trading-assessment-questions';
Expand Down Expand Up @@ -41,6 +41,7 @@ const TradingAssessmentForm = observer(
is_responsive,
}: TradingAssessmentFormProps) => {
const { traders_hub } = useStore();
const { localize } = useTranslations();
const { is_eu_user } = traders_hub;
const assessment_questions = getTradingAssessmentQuestions();
const stored_items = parseInt(localStorage.getItem('current_question_index') ?? '0');
Expand Down
2 changes: 1 addition & 1 deletion packages/account/src/Configs/financial-details-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
EMPLOYMENT_VALUES,
TEmploymentStatus,
} from '@deriv/shared';
import { localize } from '@deriv/translations';
import { localize } from '@deriv-com/translations';

type TFinancialDetailsConfig = {
real_account_signup_target: string;
Expand Down
21 changes: 0 additions & 21 deletions packages/account/src/Containers/toast-popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,12 @@ import { Toast } from '@deriv/components';
import { observer, useStore } from '@deriv/stores';
import { useDevice } from '@deriv-com/ui';

type TToastPopUp = {
portal_id?: string;
className: string;
} & React.ComponentProps<typeof Toast>;

type TNetworkStatusToastError = {
status: string;
portal_id: string;
message: string;
};

export const ToastPopup = ({
portal_id = 'popup_root',
children,
className,
...props
}: React.PropsWithChildren<TToastPopUp>) => {
const new_portal_id = document.getElementById(portal_id);
if (!new_portal_id) return null;
return ReactDOM.createPortal(
<Toast className={clsx('dc-toast-popup', className)} {...props}>
{children}
</Toast>,
new_portal_id
);
};

/**
* Network status Toast components
*/
Expand Down
Loading

0 comments on commit 3c7980e

Please sign in to comment.