Skip to content

Commit

Permalink
Merge pull request #94 from amina-deriv/amina/fix_types
Browse files Browse the repository at this point in the history
fix: type
  • Loading branch information
amina-deriv authored Oct 31, 2023
2 parents c686ea3 + 52eecc6 commit c726d58
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import React from 'react';
import { Button, Modal, Text } from '@deriv/components';
import { Jurisdiction, MT5_ACCOUNT_STATUS, getMT5AccountTitle } from '@deriv/shared';
import { DetailsOfEachMT5Loginid } from '@deriv/api-types';
import { useStore } from '@deriv/stores';
import { Localize } from '@deriv/translations';
import { TTradingPlatformAvailableAccount } from '../account-type-modal/types';
import { TMarketType } from '../../../types/common.types';

type TOpenPositionsSVGModal = {
loginId: string;
market_type: string;
loginId: DetailsOfEachMT5Loginid['login'];
market_type: NonNullable<TTradingPlatformAvailableAccount['market_type']> | TMarketType;
status: string;
is_modal_open: boolean;
setModalOpen: React.Dispatch<React.SetStateAction<boolean>>;
Expand Down
8 changes: 4 additions & 4 deletions packages/cfd/src/Containers/cfd-password-modal-title.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import React from 'react';
import { Text } from '@deriv/components';
import { getCFDPlatformNames, getCFDPlatformLabel, CFD_PLATFORMS, getFormattedJurisdictionCode } from '@deriv/shared';
import { getCFDPlatformNames, getCFDPlatformLabel, getFormattedJurisdictionCode } from '@deriv/shared';
import { observer, useStore } from '@deriv/stores';
import { Localize } from '@deriv/translations';
import { CATEGORY } from '../Helpers/cfd-config';
import { CATEGORY, CFD_PLATFORMS } from '../Helpers/cfd-config';
import { useCfdStore } from '../Stores/Modules/CFD/Helpers/useCfdStores';

type TCFDPasswordModalTitleProps = { platform: string };
type TCFDPasswordModalTitleProps = { platform: typeof CFD_PLATFORMS[keyof typeof CFD_PLATFORMS] };

const CFDPasswordModalTitle = observer(({ platform }: TCFDPasswordModalTitleProps) => {
const { traders_hub, ui } = useStore();
const { show_eu_related_content } = traders_hub;
const { is_mt5_migration_modal_enabled } = ui;
const { account_title, account_type, jurisdiction_selected_shortcode } = useCfdStore();

const accountTitle = (category: string) => {
const accountTitle = (category: typeof CATEGORY[keyof typeof CATEGORY]) => {
switch (platform) {
case 'ctrader':
case 'derivez':
Expand Down
4 changes: 2 additions & 2 deletions packages/cfd/src/Containers/cfd-password-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ type TIconTypeProps = {
};

type TCFDPasswordFormReusedProps = {
platform: string;
platform: typeof CFD_PLATFORMS[keyof typeof CFD_PLATFORMS];
error_message: string;
validatePassword: (values: TCFDPasswordFormValues) => FormikErrors<TCFDPasswordFormValues>;
};
Expand Down Expand Up @@ -107,7 +107,7 @@ type TCFDPasswordFormProps = TCFDPasswordFormReusedProps & {
type TCFDPasswordModalProps = {
error_type?: string;
form_error?: string;
platform: string;
platform: typeof CFD_PLATFORMS[keyof typeof CFD_PLATFORMS];
};

const getAccountTitle = (
Expand Down
9 changes: 4 additions & 5 deletions packages/shared/src/utils/cfd/cfd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ export const getAuthenticationStatusInfo = (account_status: GetAccountStatus): T
export const mt5_community_url =
'https://community.deriv.com/t/log-in-using-mt5-pc-or-mobile-app-application-guideline/49622';

export const getFormattedJurisdictionCode = (jurisdiction_code: string) => {
export const getFormattedJurisdictionCode = (jurisdiction_code: typeof Jurisdiction[keyof typeof Jurisdiction]) => {
let formatted_label = '';

switch (jurisdiction_code) {
Expand All @@ -487,14 +487,14 @@ export const getFormattedJurisdictionCode = (jurisdiction_code: string) => {
formatted_label = localize('Malta');
break;
default:
formatted_label = jurisdiction_code?.toUpperCase();
break;
}

return formatted_label;
};

export const getFormattedJurisdictionMarketTypes = (jurisdiction_market_type: string) => {
export const getFormattedJurisdictionMarketTypes = (
jurisdiction_market_type: typeof JURISDICTION_MARKET_TYPES[keyof typeof JURISDICTION_MARKET_TYPES] | TMarketType
) => {
let formatted_market_type = '';

switch (jurisdiction_market_type) {
Expand All @@ -506,7 +506,6 @@ export const getFormattedJurisdictionMarketTypes = (jurisdiction_market_type: st
formatted_market_type = localize('Financial');
break;
default:
formatted_market_type = jurisdiction_market_type?.toUpperCase();
break;
}
return formatted_market_type;
Expand Down

0 comments on commit c726d58

Please sign in to comment.