-
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
refactor: ♻️ migrated code to TS #45
Changes from 1 commit
78c3b9f
067e4a7
8c6103b
60d5901
149d91f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import TermsOfUse from './terms-of-use'; | ||
|
||
export default TermsOfUse; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ import { Text } from '@deriv/components'; | |
|
||
export const Hr = () => <div className='terms-of-use__hr' />; | ||
|
||
export const BrokerSpecificMessage = ({ target }) => ( | ||
export const BrokerSpecificMessage = ({ target }: { target: string }) => ( | ||
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. as we know the possible values of target, can we try writing an enum for it with just these possible 5 values? 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. Will get confirmation on the active broker codes then change to enum |
||
<React.Fragment> | ||
{target === 'svg' && <SVGDescription />} | ||
{target === 'iom' && <IOMDescription />} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ | |
flex-grow: 1; | ||
margin: 0 8rem !important; | ||
width: 84% !important; | ||
padding-bottom: unset; | ||
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. since we set the |
||
|
||
@include mobile { | ||
margin: unset !important; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,10 +11,31 @@ import { | |
} from '@deriv/components'; | ||
import { isDesktop, isMobile, PlatformContext } from '@deriv/shared'; | ||
import { localize, Localize } from '@deriv/translations'; | ||
import CheckboxField from './checkbox-field.jsx'; | ||
import { SharedMessage, BrokerSpecificMessage, Hr } from './terms-of-use-messages.jsx'; | ||
import CheckboxField from './checkbox-field'; | ||
import { SharedMessage, BrokerSpecificMessage, Hr } from './terms-of-use-messages'; | ||
import './terms-of-use.scss'; | ||
|
||
type TTermsOfUseFormProps = { | ||
agreed_tos: boolean; | ||
agreed_tnc: boolean; | ||
}; | ||
|
||
type TTermsOfUseProps = { | ||
getCurrentStep: () => number; | ||
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. the list is not huge but anyway, wouldn’t it be better to sort all fields alphabetically? :) |
||
onCancel: (current_step: number, goToPreviousStep: () => void) => void; | ||
goToPreviousStep: () => void; | ||
goToNextStep: () => void; | ||
onSubmit: ( | ||
current_step: number | null, | ||
values: TTermsOfUseFormProps, | ||
action: (isSubmitting: boolean) => void, | ||
next_step: () => void | ||
) => void; | ||
value: TTermsOfUseFormProps; | ||
real_account_signup_target: string; | ||
form_error?: string; | ||
}; | ||
|
||
const TermsOfUse = ({ | ||
getCurrentStep, | ||
onCancel, | ||
|
@@ -24,7 +45,7 @@ const TermsOfUse = ({ | |
value, | ||
real_account_signup_target, | ||
...props | ||
}) => { | ||
}: TTermsOfUseProps) => { | ||
const { is_appstore } = React.useContext(PlatformContext); | ||
|
||
const handleCancel = () => { | ||
|
@@ -43,7 +64,7 @@ const TermsOfUse = ({ | |
<Formik | ||
initialValues={value} | ||
onSubmit={(values, actions) => { | ||
onSubmit(getCurrentStep() - 1, {}, actions.setSubmitting, goToNextStep); | ||
onSubmit(getCurrentStep() - 1, values, actions.setSubmitting, goToNextStep); | ||
}} | ||
> | ||
{({ handleSubmit, values, isSubmitting }) => ( | ||
|
@@ -56,10 +77,7 @@ const TermsOfUse = ({ | |
is_disabled={isDesktop()} | ||
> | ||
<ThemedScrollbars> | ||
<div | ||
className={cn('details-form__elements', 'terms-of-use')} | ||
style={{ paddingBottom: isDesktop() ? 'unset' : null }} | ||
> | ||
<div className={cn('details-form__elements', 'terms-of-use')}> | ||
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. since we set the padding-bottom at the top level, isn't it available on mobile as well as there's no override? 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. unset or null does the same as there is no override available 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. can we change this classnames import to commonly used in our app? :) |
||
<BrokerSpecificMessage target={real_account_signup_target} /> | ||
<Hr /> | ||
<SharedMessage /> | ||
|
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.
If this component is being used with formik
Field
component, can we try wrapping this withField
directly and we'll be able to remove this field prop?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 u please elaborate?
Checkbox field is passed as a component to Field
<Field component={CheckboxField}