Skip to content

Commit

Permalink
[COJ]/Likhith/coj 782/refactor profile section code phase1 (binary-co…
Browse files Browse the repository at this point in the history
…m#15443)

* chore: configured translations

* chore: migrated personal details to tsx

* fix: file extension

* chore: removed react import

* fix: failing testcase

* fix: failed testcases

* fix: failed testcases

* fix: failed testcases

* chore: replaced hintbox with InlineMessage

* chore: reverted translation changes

* chore: reverted translation changes

* fix: incorporated review comments

* chore: reverted translation version

* fix: import issue in CFD
  • Loading branch information
likhith-deriv committed Jun 6, 2024
1 parent 64b0875 commit c84b1f7
Show file tree
Hide file tree
Showing 25 changed files with 295 additions and 239 deletions.
1 change: 0 additions & 1 deletion packages/account/build/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ module.exports = function (env) {
'@deriv/utils': '@deriv/utils',
'@deriv/quill-icons': `@deriv/quill-icons`,
'@deriv-com/utils': '@deriv-com/utils',
'@deriv-com/translations': '@deriv-com/translations',
},
/^@deriv\/shared\/.+$/,
/^@deriv\/components\/.+$/,
Expand Down
1 change: 0 additions & 1 deletion packages/account/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import React from 'react';
import Routes from './Containers/routes';
import ResetTradingPassword from './Containers/reset-trading-password';
import { NetworkStatusToastErrorPopup } from './Containers/toast-popup';
Expand Down
9 changes: 5 additions & 4 deletions packages/account/src/Components/form-body/form-body.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react';
// [TODO] - To be removed once CFD is configured to use the new form-body component
import React, { PropsWithChildren, Fragment } from 'react';
import { ScrollbarsContainer } from '../scrollbars-container/scrollbars-container';
import { Div100vhContainer, DesktopWrapper, MobileWrapper } from '@deriv/components';
import clsx from 'clsx';
Expand All @@ -8,8 +9,8 @@ type TFormBody = {
className?: string;
};

export const FormBody = ({ children, scroll_offset, className }: React.PropsWithChildren<TFormBody>) => (
<React.Fragment>
export const FormBody = ({ children, scroll_offset, className }: PropsWithChildren<TFormBody>) => (
<Fragment>
<DesktopWrapper>
<ScrollbarsContainer
className={clsx('account__scrollbars_container--grid-layout', className)}
Expand All @@ -26,5 +27,5 @@ export const FormBody = ({ children, scroll_offset, className }: React.PropsWith
{children}
</Div100vhContainer>
</MobileWrapper>
</React.Fragment>
</Fragment>
);
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// [TODO] - To be removed once CFD is configured to use the new form-body component
import React, { Fragment } from 'react';
import clsx from 'clsx';
import React from 'react';
import { Text } from '@deriv/components';

export type TFormSubHeader = {
Expand All @@ -13,7 +14,7 @@ export const FormSubHeader = ({ description, subtitle, title, title_text_size =
const title_as_class = title.replace(/\s+/g, '-').toLowerCase();

return (
<React.Fragment>
<Fragment>
<div
className={clsx('account-form__header', title_as_class, {
'account-form__header--has-description': !!description,
Expand Down Expand Up @@ -42,6 +43,6 @@ export const FormSubHeader = ({ description, subtitle, title, title_text_size =
{description}
</Text>
)}
</React.Fragment>
</Fragment>
);
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/ban-ts-comment */
//@ts-nocheck [TODO] - Need to fix typescript errors

// [TODO] - Remove React after CFD is configured with new JSX transformer
import React from 'react';
import { Field, FieldProps } from 'formik';
import { DateOfBirthPicker } from '@deriv/components';
Expand All @@ -17,7 +17,7 @@ type TDateOfBirthFieldProps = {
* @param name - Name of the field
* @param portal_id - Portal ID
* @param [props] - Other props to pass to DateOfBirthPicker
* @returns {React.ReactNode}
* @returns {ReactNode}
*/
const DateOfBirthField = ({ name, portal_id, ...rest }: TDateOfBirthFieldProps) => (
<Field name={name}>
Expand Down
8 changes: 4 additions & 4 deletions packages/account/src/Components/forms/form-select-field.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { FC, Fragment } from 'react';
import { Autocomplete, SelectNative } from '@deriv/components';
import { useStore } from '@deriv/stores';
import { Field, FieldProps, FormikErrors } from 'formik';
import React from 'react';
import { TGetField } from '../additional-kyc-info-modal/form-config';
import { TListItem } from 'Types';

Expand All @@ -16,7 +16,7 @@ type TSetFieldValue = (
shouldValidate?: boolean
) => Promise<void | FormikErrors<Record<string, string>>>;

const FormSelectField: React.FC<TFormSelectField> = ({
const FormSelectField: FC<TFormSelectField> = ({
label,
name,
required = false,
Expand All @@ -38,7 +38,7 @@ const FormSelectField: React.FC<TFormSelectField> = ({
return (
<Field name={name}>
{({ field, meta: { touched, error }, form: { setFieldValue } }: FieldProps<string>) => (
<React.Fragment>
<Fragment>
{is_mobile ? (
<SelectNative
{...field}
Expand Down Expand Up @@ -71,7 +71,7 @@ const FormSelectField: React.FC<TFormSelectField> = ({
list_height={list_height}
/>
)}
</React.Fragment>
</Fragment>
)}
</Field>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('LanguageRadioButton', () => {
const mock_props: TLanguageRadioButton = {
is_current_language: true,
id: 'test id',
language_code: 'lang_1',
language_text: 'Lang 1',
name: 'Test Language',
onChange: jest.fn(),
};
Expand All @@ -32,7 +32,7 @@ describe('LanguageRadioButton', () => {
render(<LanguageRadioButton {...mock_props} />);

expect(screen.getByText('Flag Icon')).toBeInTheDocument();
expect(screen.getByText('Test Lang 1')).toBeInTheDocument();
expect(screen.getByText('Lang 1')).toBeInTheDocument();
expect(screen.getByTestId('dt_language_settings_button')).toHaveClass(
'settings-language__language-link--active'
);
Expand All @@ -44,7 +44,7 @@ describe('LanguageRadioButton', () => {
render(<LanguageRadioButton {...mock_props} />);

expect(screen.getByText('Flag Icon')).toBeInTheDocument();
expect(screen.getByText('Test Lang 1')).toBeInTheDocument();
expect(screen.getByText('Lang 1')).toBeInTheDocument();
expect(screen.getByTestId('dt_language_settings_button')).not.toHaveClass(
'settings-language__language-link--active'
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,30 @@
import React from 'react';
import { ChangeEventHandler } from 'react';
import { Text, Icon } from '@deriv/components';
import clsx from 'clsx';
import { getAllowedLanguages } from '@deriv/translations';

export type TLanguageRadioButton = {
is_current_language: boolean;
id: string;
language_code: string;
language_text: string;
name: string;
onChange: React.ChangeEventHandler<HTMLInputElement>;
onChange: ChangeEventHandler<HTMLInputElement>;
};

const LanguageRadioButton = ({ is_current_language, id, language_code, name, onChange }: TLanguageRadioButton) => {
const allowed_languages: Record<string, string> = getAllowedLanguages();
const LanguageRadioButton = ({ is_current_language, id, language_text, name, onChange }: TLanguageRadioButton) => {
return (
<div
className={clsx('settings-language__language-link', {
'settings-language__language-link--active': is_current_language,
})}
id={`dt_settings_${language_code}_button`}
id={`dt_settings_${id}_button`}
data-testid={'dt_language_settings_button'}
>
<input
type='radio'
id={id}
name={name}
onChange={onChange}
value={language_code}
value={id}
className='settings-language__language--radio-button'
/>
<label htmlFor={id} className='settings-language__language--center-label'>
Expand All @@ -43,7 +41,7 @@ const LanguageRadioButton = ({ is_current_language, id, language_code, name, onC
'settings-language__language-name--active': is_current_language,
})}
>
{allowed_languages[language_code]}
{language_text}
</Text>
</div>
</label>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { ReactNode } from 'react';
import { Icon } from '@deriv/components';
import IconMessageContent from '../icon-message-content';

type TLoadErrorMessage = {
error_message: React.ReactNode;
error_message: ReactNode;
};

const LoadErrorMessage = ({ error_message }: TLoadErrorMessage) => (
Expand Down
Loading

0 comments on commit c84b1f7

Please sign in to comment.