Skip to content

Commit

Permalink
Merge pull request #98 from amina-deriv/shaheer/sprint_6_ts_migration
Browse files Browse the repository at this point in the history
refactor: 🎨 resolves code review comments
  • Loading branch information
shaheer-deriv committed Nov 13, 2023
2 parents fe0c5ec + 8d1ee46 commit 3e2971d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const SelfExclusionArticle = observer(() => {
const { is_deriv_crypto } = React.useContext(PlatformContext);
const { ui } = useStore();
const { is_desktop, is_mobile } = ui;

return (
<AccountArticle
title={localize('Trading limits and self-exclusion')}
Expand Down
2 changes: 1 addition & 1 deletion packages/account/src/Constants/api-token-card-details.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { Localize } from '@deriv/translations';

export const getApiTokenCardDetails = () => [
export const API_TOKEN_CARD_DETAILS = [
{
name: 'read',
display_name: <Localize i18n_default_text='Read' />,
Expand Down
6 changes: 2 additions & 4 deletions packages/account/src/Sections/Security/ApiToken/api-token.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { TToken } from 'Types';
import { ApiTokenContext, ApiTokenArticle, ApiTokenCard, ApiTokenTable } from 'Components/api-token';
import InlineNoteWithIcon from 'Components/inline-note-with-icon';
import LoadErrorMessage from 'Components/load-error-message';
import { getApiTokenCardDetails, TOKEN_LIMITS } from 'Constants/api-token-card-details';
import { API_TOKEN_CARD_DETAILS, TOKEN_LIMITS } from 'Constants/api-token-card-details';
import './api-token.scss';

type AptTokenState = {
Expand Down Expand Up @@ -181,8 +181,6 @@ const ApiToken = observer(() => {
deleteToken,
};

const api_token_card_array = getApiTokenCardDetails();

return (
<ApiTokenContext.Provider value={context_value}>
<section className='da-api-token'>
Expand All @@ -209,7 +207,7 @@ const ApiToken = observer(() => {
}
>
<div className='da-api-token__checkbox-wrapper'>
{api_token_card_array.map(card => (
{API_TOKEN_CARD_DETAILS.map(card => (
<ApiTokenCard
key={card.name}
name={card.name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ import React from 'react';
import { render, screen } from '@testing-library/react';
import ClosingAccountPendingContent from '../closing-account-pending-content';

jest.mock('@deriv/components', () => {
const original_module = jest.requireActual('@deriv/components');
return {
...original_module,
Icon: jest.fn(() => <div>mockedIcon</div>),
};
});
jest.mock('@deriv/components', () => ({
...jest.requireActual('@deriv/components'),
Icon: jest.fn(() => <div>mockedIcon</div>),
}));

describe('ClosingAccountPendingContent', () => {
const mock_props: React.ComponentProps<typeof ClosingAccountPendingContent> = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ type TListCell = {
align?: 'left' | 'right';
};

const ListCell = ({ title, text, className, align }: TListCell) => (
const ListCell = ({ title, text, className, align = 'left' }: TListCell) => (
<React.Fragment>
<Text as='h3' align={align} weight='bold' className='login-history__list__row__cell--title'>
{title}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const LoginHistory = observer(() => {

return (
<ThemedScrollbars is_bypassed={is_mobile} className='login-history'>
{login_history.length && <LoginHistoryContent data={login_history} />}
<LoginHistoryContent data={login_history} />
</ThemedScrollbars>
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const mock = {
};
let store = mockStore(mock);
describe('<SelfExclusion />', () => {
let mock_props = {
let mock_props: React.ComponentProps<typeof SelfExclusion> = {
overlay_ref: document.createElement('div'),
setIsOverlayShown: jest.fn(),
};
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/hooks/useLoginHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const useLoginHistory = (payload?: TUseLoginHistoryPayload) => {
const modified_login_history = useMemo(
() => ({
...data?.login_history,
formatted_data: getLoginHistoryFormattedData(data?.login_history || []),
formatted_data: getLoginHistoryFormattedData(data?.login_history ?? []),
}),
[data?.login_history]
);
Expand Down

0 comments on commit 3e2971d

Please sign in to comment.