-
Notifications
You must be signed in to change notification settings - Fork 0
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
Yauheni/74112/formbodysection ts migration #19
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,20 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import { PropTypes } from 'prop-types'; | ||
import { Text } from '@deriv/components'; | ||
import { PlatformContext } from '@deriv/shared'; | ||
import { TPlatformContext } from 'Types'; | ||
|
||
const FormBodySection = ({ children, has_side_note, side_note }) => { | ||
const { is_appstore } = React.useContext(PlatformContext); | ||
export type TFormBodySection = { | ||
has_side_note?: boolean; | ||
side_note?: string | React.ReactElement; | ||
}; | ||
|
||
const FormBodySection = ({ children, has_side_note, side_note }: React.PropsWithChildren<TFormBodySection>) => { | ||
const { is_appstore }: Partial<TPlatformContext> = React.useContext(PlatformContext); | ||
if (has_side_note) { | ||
return ( | ||
<div | ||
data-testid='side-note-container' | ||
data-testid='dt_side_note_container' | ||
className={classNames('account-form__section', { 'account-form__section--dashboard': is_appstore })} | ||
> | ||
<div className='account-form__section-side-note'> | ||
|
@@ -25,11 +30,7 @@ const FormBodySection = ({ children, has_side_note, side_note }) => { | |
</div> | ||
); | ||
} | ||
return children; | ||
}; | ||
FormBodySection.prototype = { | ||
children: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), | ||
has_side_note: PropTypes.bool, | ||
side_note: PropTypes.oneOfType([PropTypes.string, PropTypes.object]), | ||
return children as JSX.Element; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Rather than typecasting, may be it is better to return There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @likhith-deriv, it makes tests broken. I also changed the same part of code for other components in other PRs |
||
}; | ||
|
||
export default FormBodySection; |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import FormBodySection from './form-body-section'; | ||
|
||
export default FormBodySection; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the test-id be replaced as per the coding guide?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes. sure. Thanks for this 👍