From ec0f96e95a50a52fe14d037234c7309475542bcb Mon Sep 17 00:00:00 2001 From: kate-deriv <121025168+kate-deriv@users.noreply.github.com> Date: Wed, 11 Oct 2023 16:19:54 +0300 Subject: [PATCH] Kate / DTRA-375 / [Package 5] Tech debt (#9809) * fix: ts-migrate trade-params * fix: sonarcloud * fix: pull in changes from tech debt 2 package * fix: resolve comments * fix: move type to common prop types * fix: move type to common prop types * fix: move type to common prop types file * fix: resolve comments * Kate / DTRA-321 / TS migration of trade-params and trade-params-mobile (#6) * refactor: migrate trade params and started mobile version * refactor: ts migration of trade params mobile * chore: add nessasary prop * refactor: apply suggestions * chore: change todo text * refactor: add import * fix: circleCI error * fix: ts migrate trade-footer-extensions.jsx * fix: fix import * fix: remove progress-slider-stream since its not used * fix: resolve comments * fix: reset with master * fix: reset with master * fix: reset with master * fix: reset with master * fix: circleCI * fix: togglePositions folder * fix: dtra-346 marketisclosed and marketcountdowntimer migration * fix: bug * Maryia/dtra-270/TS migration: trade-store (#5) * chore: prepare for migration * chore: add more types to trade-store * chore: add more types to trade-store * chore: add more types to trade-store * chore: add more types to trade-store * chore: migrated trade-store to ts * chore: improve types in trade-store * fix: type * revert: hooks package installation * refactor: address review * fix: resolve comments * feat: add ts migartion of store * refactor: add prev changes * chore: empty commit * fix: add lost mocked * fix: resolve comments * Kate / DTRA-354 / Components/Form/Purchase files in Trader package (#21) * refactor: ts migartion of purchase files * refactor: remove duplicated types * refactor: apply suggestions * maryia/fix: sonarcloud warnings (#7) * fix: sonarcloud warnings * fix: Unexpected end of JSON input * fix: bug * fix: sonarcloud * fix: reorder props * fix: test cases * fix: coveralls * fix: coveralls * fix: this component doesnt exist anymore, hence test was also removed * henry/dtra-356/fix: ts-migration-digitsJSX (#24) * fix: initial commit * fix: ts migrate digits JSX * fix: small type change * fix: comment * chore: removed unused state * Maryia/dtra-355/Migrate ContractDrawer files to TS (#22) * feat: migrated swipeable-components to TS * feat: migrated market-closed-contract-overlay & index to TS * chore: migrated contract-drawer-card.tsx to ts * build: fix type * chore: migrated contract-drawer to ts * chore: fixed existing types in digits and logic * chore: sort types properties in alphabetical order * Kate/dtra 357/ts contract audit files (#23) * refactor: apply suggestion from prev pr * refactor: start ts migration of contract audit * chore: change comment * refactor: ts of contract audit item * refactor: ts migration of contract details * refactor: ts migration of contract history * refactor: add preprepared types * refactor: tests * chore: apply nit * refactor: apply suggestions * refactor: apply suggestions * chore: fix of sonar cloud * Maryia/dtra-373/remove localize from ContractCardHeader component (#25) * refactor: remove localize from contract-card-header * refactor: use Localize component instead of localize helper * build: install RTL deps in shared package * feat: merge previous tech debt branch * fix: sonar cloud codesmells * Merge branch kate/ts_migration_trader_package_4 into kate/ts_migration_trader_package_5 * Kate / DTRA-378 / TS migration: Multiplier components and containers in Trader package (#26) * refactor: ts of cancel deal and risk managment info * fix: types in dialog tsx * refactor: start ts of multiplier options * refactor: ts of mult amount modal * refactor: remove default val from basis component * fix: type of amount mobile * refactor: applied suggestions * refactor: ts of multiplier info (#28) * Henry/dtra 376/fix: ts migration positionsdrawer folder (#27) * fix: positions drawer folder * fix: coveralls * fix: where is my commit * fix: found commits * fix: file rename * fix: comments * fix: comments * fix: correct logic * fix: remove unused props * fix: types * refactor: remove code mells * fix: ts-migrate-populate header (#30) * Maryia/DTRA-377/TS migration: TradingDatePicker + TradingTimePicker + TimePicker + Dialog (#29) * chore: timepicker to ts * chore: trading timepicker to ts * chore: add types for TradingDatePicker & DatePicker * refactor: added default values * refactor: remove code small * chore: empty commit * fix: not using index as key (#31) * fix: ternary bug * fix: build TS errors (#32) * refactor: apply suggestions * refactor: change type of time * chore: empty commit * refactor: tests * fix: conflicts * fix: conflicts * fix: tests * fix: types in tests * fix: test extention * fix: add turbos to types back * fix: add backup for target name * fix: revert empty strings --------- Co-authored-by: Henry Hein Co-authored-by: Maryia <103177211+maryia-deriv@users.noreply.github.com> Co-authored-by: henry-deriv <118344354+henry-deriv@users.noreply.github.com> --- .../src/components/calendar/calendar-body.tsx | 6 +- .../components/calendar/calendar-footer.tsx | 2 +- .../src/components/calendar/calendar.tsx | 30 +++--- .../calendar/views/calendar-days.tsx | 2 +- .../result-overlay/result-overlay.tsx | 4 +- .../date-picker/date-picker-calendar.tsx | 24 ++--- .../date-picker/date-picker-native.tsx | 22 ++--- .../components/date-picker/date-picker.tsx | 22 +++-- .../src/components/dialog/dialog.tsx | 2 +- .../components/input-field/input-field.tsx | 16 ++-- .../positions-drawer-card.tsx | 44 ++++----- .../progress-slider-mobile.tsx | 4 +- .../progress-ticks-mobile.tsx | 2 +- .../composite-calendar-mobile.tsx | 24 ++--- .../shared/src/utils/constants/contract.ts | 2 +- packages/shared/src/utils/date/date-time.ts | 2 +- packages/stores/src/mockStore.ts | 1 + packages/stores/types.ts | 4 +- .../ContractAudit/contract-details.tsx | 4 +- .../positions-result-mobile.spec.tsx | 20 ++++ .../__tests__/result-mobile.spec.js | 20 ---- ...ositions-helper.js => positions-helper.ts} | 0 .../helpers/{index.js => index.ts} | 0 ...ositions-helper.js => positions-helper.ts} | 29 +++--- .../Elements/PositionsDrawer/index.js | 3 - .../Elements/PositionsDrawer/index.ts | 3 + ...itions-drawer.jsx => positions-drawer.tsx} | 55 +++++++---- ...odal-card.jsx => positions-modal-card.tsx} | 84 ++++++++--------- ...mobile.jsx => positions-result-mobile.tsx} | 15 ++- .../toggle-positions-mobile.spec.tsx | 2 +- .../toggle-positions-mobile.tsx | 4 +- .../TimePicker/{dialog.jsx => dialog.tsx} | 56 +++++++----- .../App/Components/Form/TimePicker/index.js | 3 - .../App/Components/Form/TimePicker/index.ts | 3 + .../{time-picker.jsx => time-picker.tsx} | 47 +++++----- .../src/App/Components/Routes/binary-link.jsx | 2 +- ...opulate-header.jsx => populate-header.tsx} | 0 .../Contract/Components/Digits/digits.tsx | 1 - .../accumulators-chart-elements.spec.tsx | 2 +- .../Markers/accumulators-chart-elements.tsx | 2 +- ...deal-mobile.jsx => cancel-deal-mobile.tsx} | 91 ++++++++++++------- ...ment-info.jsx => risk-management-info.tsx} | 2 +- .../Components/Form/DatePicker/index.js | 3 - .../Components/Form/DatePicker/index.ts | 3 + ...ate-picker.jsx => trading-date-picker.tsx} | 60 ++++++------ .../Components/Form/TimePicker/index.js | 3 - .../Components/Form/TimePicker/index.ts | 3 + ...ime-picker.jsx => trading-time-picker.tsx} | 0 .../Duration/advanced-duration.jsx | 1 - .../Multiplier/{info.jsx => info.tsx} | 58 ++++++++---- .../Form/TradeParams/Multiplier/widgets.jsx | 4 +- .../Form/TradeParams/amount-mobile.tsx | 31 ++++--- .../Components/Form/TradeParams/amount.tsx | 5 +- .../Trading/Components/Form/screen-small.tsx | 2 +- ...-modal.jsx => multiplier-amount-modal.tsx} | 45 +++++---- ...ier-options.jsx => multiplier-options.tsx} | 17 ++-- ...-dialog.jsx => risk-management-dialog.tsx} | 38 +++++--- .../radio-group-options-modal.spec.jsx | 81 ----------------- .../radio-group-options-modal.spec.tsx | 2 +- .../Containers/radio-group-options-modal.tsx | 3 +- .../Containers/trade-params-mobile.tsx | 2 - .../Trading/Containers/trade-params.tsx | 2 +- .../Modules/Trading/Helpers/end-time.ts | 8 +- .../Modules/Trading/Helpers/multiplier.ts | 2 +- .../Trading/Helpers/preview-proposal.ts | 14 ++- 65 files changed, 543 insertions(+), 505 deletions(-) create mode 100644 packages/trader/src/App/Components/Elements/PositionsDrawer/__tests__/positions-result-mobile.spec.tsx delete mode 100644 packages/trader/src/App/Components/Elements/PositionsDrawer/__tests__/result-mobile.spec.js rename packages/trader/src/App/Components/Elements/PositionsDrawer/helpers/__tests__/{positions-helper.js => positions-helper.ts} (100%) rename packages/trader/src/App/Components/Elements/PositionsDrawer/helpers/{index.js => index.ts} (100%) rename packages/trader/src/App/Components/Elements/PositionsDrawer/helpers/{positions-helper.js => positions-helper.ts} (61%) delete mode 100644 packages/trader/src/App/Components/Elements/PositionsDrawer/index.js create mode 100644 packages/trader/src/App/Components/Elements/PositionsDrawer/index.ts rename packages/trader/src/App/Components/Elements/PositionsDrawer/{positions-drawer.jsx => positions-drawer.tsx} (80%) rename packages/trader/src/App/Components/Elements/PositionsDrawer/{positions-modal-card.jsx => positions-modal-card.tsx} (90%) rename packages/trader/src/App/Components/Elements/PositionsDrawer/{result-mobile.jsx => positions-result-mobile.tsx} (89%) rename packages/trader/src/App/Components/Form/TimePicker/{dialog.jsx => dialog.tsx} (78%) delete mode 100644 packages/trader/src/App/Components/Form/TimePicker/index.js create mode 100644 packages/trader/src/App/Components/Form/TimePicker/index.ts rename packages/trader/src/App/Components/Form/TimePicker/{time-picker.jsx => time-picker.tsx} (77%) rename packages/trader/src/App/Containers/{populate-header.jsx => populate-header.tsx} (100%) rename packages/trader/src/Modules/Trading/Components/Elements/Multiplier/{cancel-deal-mobile.jsx => cancel-deal-mobile.tsx} (63%) rename packages/trader/src/Modules/Trading/Components/Elements/Multiplier/{risk-management-info.jsx => risk-management-info.tsx} (98%) delete mode 100644 packages/trader/src/Modules/Trading/Components/Form/DatePicker/index.js create mode 100644 packages/trader/src/Modules/Trading/Components/Form/DatePicker/index.ts rename packages/trader/src/Modules/Trading/Components/Form/DatePicker/{trading-date-picker.jsx => trading-date-picker.tsx} (77%) delete mode 100644 packages/trader/src/Modules/Trading/Components/Form/TimePicker/index.js create mode 100644 packages/trader/src/Modules/Trading/Components/Form/TimePicker/index.ts rename packages/trader/src/Modules/Trading/Components/Form/TimePicker/{trading-time-picker.jsx => trading-time-picker.tsx} (100%) rename packages/trader/src/Modules/Trading/Components/Form/TradeParams/Multiplier/{info.jsx => info.tsx} (71%) rename packages/trader/src/Modules/Trading/Containers/Multiplier/{multiplier-amount-modal.jsx => multiplier-amount-modal.tsx} (75%) rename packages/trader/src/Modules/Trading/Containers/Multiplier/{multiplier-options.jsx => multiplier-options.tsx} (79%) rename packages/trader/src/Modules/Trading/Containers/Multiplier/{risk-management-dialog.jsx => risk-management-dialog.tsx} (80%) delete mode 100644 packages/trader/src/Modules/Trading/Containers/__tests__/radio-group-options-modal.spec.jsx diff --git a/packages/components/src/components/calendar/calendar-body.tsx b/packages/components/src/components/calendar/calendar-body.tsx index eb16d0a4ef1e..4b097cbdcbd9 100644 --- a/packages/components/src/components/calendar/calendar-body.tsx +++ b/packages/components/src/components/calendar/calendar-body.tsx @@ -5,13 +5,13 @@ import { CommonPropTypes } from './views/types'; type TBodyProps = CommonPropTypes & { calendar_view: string; date_format: string; - disabled_days: number[]; + disabled_days?: number[]; start_date: string; - events: Array<{ + events?: Array<{ dates: string[]; descrip: string; }>; - has_range_selection: boolean; + has_range_selection?: boolean; hovered_date: string | null; onMouseLeave?: React.MouseEventHandler; onMouseOver?: React.MouseEventHandler; diff --git a/packages/components/src/components/calendar/calendar-footer.tsx b/packages/components/src/components/calendar/calendar-footer.tsx index 9f1853dafa5b..e00a785bbbc9 100644 --- a/packages/components/src/components/calendar/calendar-footer.tsx +++ b/packages/components/src/components/calendar/calendar-footer.tsx @@ -6,7 +6,7 @@ type TFooterProps = { clear_text?: string; footer: string; has_clear_btn?: boolean; - has_today_btn: boolean; + has_today_btn?: boolean; onClick?: React.MouseEventHandler; onClear?: React.MouseEventHandler; use_icon?: string; diff --git a/packages/components/src/components/calendar/calendar.tsx b/packages/components/src/components/calendar/calendar.tsx index 288f9a16f031..bd898d3e5d59 100644 --- a/packages/components/src/components/calendar/calendar.tsx +++ b/packages/components/src/components/calendar/calendar.tsx @@ -7,30 +7,30 @@ import { getDate } from './helpers/constants'; type TCalendarProps = { date_format?: string; - footer: string; - has_today_btn: boolean; - holidays: Array<{ + footer?: string; + has_today_btn?: boolean; + holidays?: Array<{ dates: string[]; descrip: string; }>; max_date?: string; min_date?: string; - onChangeCalendarMonth: (start_of_month: string) => void; + onChangeCalendarMonth?: (start_of_month: string) => void; onSelect: (formatted_date: string, keep_open: boolean) => void; - start_date: string; + start_date?: string; value: string; - disable_days: number[]; + disable_days?: number[]; calendar_view?: string; calendar_el_ref: React.RefObject; - disabled_days: number[]; - events: Array<{ + disabled_days?: number[]; + events?: Array<{ dates: string[]; descrip: string; }>; - has_range_selection: boolean; - keep_open: boolean; + has_range_selection?: boolean; + keep_open?: boolean; onHover?: (selected_date: moment.MomentInput | null) => void; - should_show_today: boolean; + should_show_today?: boolean; }; type TCalendarRef = { @@ -52,7 +52,7 @@ const Calendar: React.MemoExoticComponent< date_format = 'YYYY-MM-DD', disabled_days, events, - footer, + footer = '', has_today_btn, has_range_selection, keep_open, @@ -61,7 +61,7 @@ const Calendar: React.MemoExoticComponent< onChangeCalendarMonth, onHover, onSelect, - start_date, + start_date = '', value, should_show_today, }, @@ -137,7 +137,7 @@ const Calendar: React.MemoExoticComponent< setSelectedDate(formatted_date); if (onSelect) { - onSelect(formatted_date, keep_open); + onSelect(formatted_date, !!keep_open); } }; @@ -211,7 +211,7 @@ const Calendar: React.MemoExoticComponent< hovered_date={hovered_date} onMouseOver={onMouseOver} onMouseLeave={onMouseLeave} - should_show_today={should_show_today} + should_show_today={!!should_show_today} />