Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: 🎨 resolves code review comments #98

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
Loading