From 8869ce19d898f3fa5aae5f38e10bd83057393f29 Mon Sep 17 00:00:00 2001 From: mahdiyeh-deriv <82078941+mahdiyeh-deriv@users.noreply.github.com> Date: Wed, 17 May 2023 09:16:11 +0330 Subject: [PATCH] refactor: TS migration of Reports pakage (#7300) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: initial commit * revert: revert changes * chore: ts-migration for positions-card.tsx (#5) * chore: reports-table-row to tsx (#10) * chore: migrating error-components to tsx (#8) * chore: migrating error-components to tsx * fix: added partial to type * chore: migrate calendar-icon to tsx (#11) * chore: migrate calendar-icon to tsx * fix: updated extensions * chore: migrate list-item to tsx (#12) * chore: migrate currency-wrapper to ts (#17) * chore: migrate empty-portfolio-message to ts (#18) * chore: migrating reports meta to tsx (#23) * chore: migrate amount-cell to ts (#16) * chore: migrate amount-cell to ts * fix: delete component because it is unused * chore: migrating EmptyTradeHistoryMessage to tsx (#19) * chore: migrating EmptyTradeHistoryMessage to tsx * fix: remove extension * fix: migrated sidelist to tsx (#13) * fix: migrated sidelist to tsx * fix: circle-ci error * fix: sidelist types * chore: migrate composite calendar mobile to typescript (#26) * chore: migrate composite calendar mobile to typescript * fix: remove component extension from the name * refactor: :recycle: removed unused component (#30) * chore: migrate index file to typescript (#27) * refactor: :recycle: migrate component to tsx (#29) * chore: two-month-picker to tsx with one calendar component (#15) * chore: migrate account statistics to ts (#14) * chore: migrate account statistics to ts * fix: typo in comment * Akmal / chore: migrate routes config to typescript (#31) * chore: migrate routes config to typescript * fix: change type for component * Akmal / chore: migrate data-table-constants to typescript (#33) * chore: migrate data-table-constants to typescript * fix: refactor types * chore: migrate loading component to typescript (#36) * Aizad/73988/msir ts (#21) * chore: migrate market-symbol-icon-row to ts * fix: remove commented lines * fix: remove classname from IconTradeTypes * fix: removed action prop * Sergei / chore: migrate open-positions to tsx (#40) * chore: convert open-positions to tsx * fix: add React.PropsWithChildren to tabs.tsx * fix: change Tabs type * fix: add/change some types and fix some undefined values * refactor: use Return Early pattern for contract-card-sell component * chore: delete commented lines * chore: add moment as dev dependency * chore: commit to check circleCI * fix: change back tabs.tsx * fix: change React.Fragment to null * Akmal / chore: convert helpers to typescript (#28) * chore: convert elpers to typescript * fix: types * chore: migrate placeholder to tsx (#42) * chore: migate placeholder to tsx * fix: destructure props and remove React.propswithchildre * Sergei / 73980 / chore: ts migration of route-with-sub-routes (#45) * chore: ts migration of route-with-sub-routes * refactor: add common types to separate files * fix: get back composite-calendar * refactor: change path from absolute to relative for Types * Sergei / 73979 / chore: ts migration of binary-routes (#46) * chore: ts migration of binary-routes.jsx * chore: add TPassthrough type and add key as index when route.path is undefined * chore: add export for TBinaryRoutes type * refactor: use types from common types * Aizad/73977/binary link ts (#41) * chore: migrate routes folder to tsx * fix: change type for component * fix: migrated test cases to tsx * chore: migrate binary-links to tsx * fix: change back function names * fix: resolved conflict issues * fix: testcases * chore: migrated filter component and fix some issues with composite-c… (#20) * chore: migrated filter component and fix some issues with composite-calendar * fix: change export to CalendarIcon on index.js and added RootStore type to filter-components * fix: change TRootStore to RootStore * fix: replace RootStore to TRootStore * fix: expand object for filtered_date_range * Sergei / chore: ts migration of routes (#38) * chore: ts migration of routes * chore: change RootStore type * Aizad/73994/pss ts (#48) * chore: migrate progress-slider-stream to tsx * fix: imported TContractInfo inside deriv/shared/ * Sergei / chore: migrate statements to tsx (#39) * chore: ts migration of statements * chore: change RootStore type * chore: change local TRootStore with module property * fix: return class RootStore to Stores/index.ts * chore: change core_store type * chore: migrated indicative cell to tsx (#44) * chore: migrated indicative cell to tsx * fix: added types to usestate * fix: change type * fix: change function type to boolean * fix: imported TContractInfo from shared file into indicative-cell * fix: test * fix: mockstore * fix: format-response.ts * fix: mockstore * Aizad/73978/routes ts (#50) * Merge branch 'Improvement/72232/Reports_TS_migration' of github.com:mahdiyeh-deriv/deriv-app into ts-migration * chore: finalising routes folder migration for Reports package 📦 * Akmal / chore: migrate app.jsx to typescript (#37) * chore: migrate app.jsx to typescript * chore: utilize TRootStore type * chore: replace type * Akmal / chore: migrate composite calendar to typescript (#25) * chore: migrate composite calendar to typescript * chore: refactor composite calendar and related components to properly use moment * chore: move out index changes * feat: resolve conflicts * feat: add deriv stores package * Kate/73995/TS migration of Reports (#51) * refactor: migrate reports component into ts * refactor: add useStore hook * refactor: delete extra react fragment Co-authored-by: Farzin Mirzaie <72082844+farzin-deriv@users.noreply.github.com> --------- Co-authored-by: Farzin Mirzaie <72082844+farzin-deriv@users.noreply.github.com> * redeploy: rerun tests * refactor: remove named import from react * chore: migrate statement to tsx (#47) * chore: migrate statement to tsx * fix: use Statement props from api-types than declaring it in ts file * fix: imported TAccountStatistics inside statement * fix: made changes based on comments * fix: refactor based on suggestions * fix: types in packages/shared/src/utils/shortcode/shortcode.ts * fix: regex to prevent sonarcloud bug * chore: change index.js to index.ts * Rostislav / 73993 / Task - TS migration of ProfitTable (#34) * refactor: init pr * refactor: profit_loss_cell tsx'd * refactor: profit_loss_cell import problem resolved * refactor: profit_loss_cell import another problem fix * refactor: the migration is more or less finished * refactor: a few extra changes * refactor: prev commit accidental changes removed * refactor: TProfitTable type changed a bit * refactor: moved types to common-prop.type.ts * refactor: getSupportedContracts and getUnsupportedContracts moved to shared * refactor: contract.tsx completely replaced by imports from @deriv/shared * refactor: added alias for Types * refactor: applied suggested changes * fix: regex for sonarcloud * fix: remove props from the name of type declaration * fix: resolve comments * fix: fix comments v2 * fix: remove usestate * fix: date-time test * fix: comments v3 * thisyahlen/fix: trade table for mobile (#52) * fix: trade table for mobile * fix: trade table error * fix: statement input validation error on date_from * fix: setdate unix * fix: responsive input validation error * fix: remove unix from store --------- Co-authored-by: aizad-deriv <103104395+aizad-deriv@users.noreply.github.com> Co-authored-by: Akmal Djumakhodjaev Co-authored-by: Likhith Kolayari <98398322+likhith-deriv@users.noreply.github.com> Co-authored-by: Sergei Baranovski <120570511+sergei-deriv@users.noreply.github.com> Co-authored-by: kate-deriv <121025168+kate-deriv@users.noreply.github.com> Co-authored-by: Farzin Mirzaie <72082844+farzin-deriv@users.noreply.github.com> Co-authored-by: Rostik Kayko <119863957+rostislav-deriv@users.noreply.github.com> Co-authored-by: Thisyahlen Nair Co-authored-by: thisyahlen <104053934+thisyahlen-deriv@users.noreply.github.com> Co-authored-by: hirad-deriv --- .../components/src/components/label/label.tsx | 2 +- packages/reports/build/constants.js | 1 + packages/reports/build/loaders-config.js | 3 - packages/reports/build/webpack.config.js | 2 +- packages/reports/jest.config.js | 2 + packages/reports/package.json | 1 + .../Elements/ContentLoader/index.js | 1 - .../Elements/ContentLoader/index.ts | 1 + ...{positions-card.jsx => positions-card.tsx} | 11 +- ...ts-table-row.jsx => reports-table-row.tsx} | 11 +- ...rror-component.jsx => error-component.tsx} | 17 +- .../reports/src/Components/Errors/index.js | 1 - .../reports/src/Components/Errors/index.ts | 3 + .../Form/CompositeCalendar/calendar-icon.jsx | 11 - .../Form/CompositeCalendar/calendar-icon.tsx | 12 + ...bile.jsx => composite-calendar-mobile.tsx} | 78 +++-- ...te-calendar.jsx => composite-calendar.tsx} | 99 +++--- .../Form/CompositeCalendar/index.js | 1 - .../Form/CompositeCalendar/index.ts | 3 + .../{list-item.jsx => list-item.tsx} | 15 +- .../{side-list.jsx => side-list.tsx} | 30 +- ...-month-picker.jsx => two-month-picker.tsx} | 79 ++--- .../{helpers.spec.js => helpers.spec.tsx} | 23 +- .../{binary-link.jsx => binary-link.tsx} | 19 +- .../src/Components/Routes/binary-routes.jsx | 30 -- .../src/Components/Routes/binary-routes.tsx | 26 ++ .../reports/src/Components/Routes/helpers.js | 34 --- .../reports/src/Components/Routes/helpers.ts | 36 +++ .../reports/src/Components/Routes/index.js | 4 - .../reports/src/Components/Routes/index.ts | 7 + ...b-routes.jsx => route-with-sub-routes.tsx} | 17 +- ...-statistics.jsx => account-statistics.tsx} | 19 +- .../reports/src/Components/amount-cell.jsx | 15 - ...rency-wrapper.jsx => currency-wrapper.tsx} | 11 +- ...essage.jsx => empty-portfolio-message.tsx} | 6 +- ...ge.jsx => empty-trade-history-message.tsx} | 17 +- ...ter-component.jsx => filter-component.tsx} | 31 +- packages/reports/src/Components/index.js | 3 - packages/reports/src/Components/index.ts | 3 + ...ndicative-cell.jsx => indicative-cell.tsx} | 37 ++- ...con-row.jsx => market-symbol-icon-row.tsx} | 43 +-- .../src/Components/placeholder-component.tsx | 39 +++ ...fit_loss_cell.jsx => profit_loss_cell.tsx} | 13 +- .../reports/src/Components/reports-meta.jsx | 19 -- .../reports/src/Components/reports-meta.tsx | 28 ++ ...-constants.js => data-table-constants.tsx} | 149 ++++----- .../{routes-config.js => routes-config.tsx} | 11 +- ....spec.js => open-positions-table.spec.tsx} | 0 packages/reports/src/Containers/index.js | 11 - packages/reports/src/Containers/index.ts | 11 + ...{open-positions.jsx => open-positions.tsx} | 273 +++++++++++------ .../{profit-table.jsx => profit-table.tsx} | 91 +++--- ...-stream.jsx => progress-slider-stream.tsx} | 22 +- .../Containers/{reports.jsx => reports.tsx} | 98 +++--- packages/reports/src/Containers/routes.jsx | 41 --- packages/reports/src/Containers/routes.tsx | 26 ++ .../{statement.jsx => statement.tsx} | 173 +++++++---- packages/reports/src/Helpers/digits.js | 5 - packages/reports/src/Helpers/digits.ts | 8 + ...ket-underlying.js => market-underlying.ts} | 30 +- packages/reports/src/Helpers/profit-loss.js | 1 - packages/reports/src/Helpers/profit-loss.ts | 1 + .../Components/{Page404.jsx => Page404.tsx} | 0 packages/reports/src/Modules/Page404/index.js | 1 - packages/reports/src/Modules/Page404/index.ts | 3 + .../Markers/__tests__/marker-spot.spec.tsx | 18 -- .../Components/Markers/marker-line.jsx | 38 --- .../Components/Markers/marker-spot.jsx | 15 - .../src/Modules/SmartChart/Helpers/symbol.js | 10 - .../src/Stores/Modules/Profit/profit-store.js | 4 +- packages/reports/src/Stores/index.js | 19 -- packages/reports/src/Stores/index.ts | 43 +++ .../reports/src/Types/common-prop.type.ts | 103 +++++++ packages/reports/src/Types/index.ts | 1 + packages/reports/src/_common/contract.js | 289 ------------------ packages/reports/src/app.jsx | 27 -- packages/reports/src/app.tsx | 28 ++ packages/reports/src/{index.jsx => index.tsx} | 2 +- .../components/{loading.jsx => loading.tsx} | 9 +- packages/reports/tsconfig.json | 3 +- packages/shared/src/utils/contract/index.ts | 1 + .../utils/date/__tests__/date-time.spec.ts | 2 +- packages/shared/src/utils/date/date-time.ts | 6 +- packages/shared/src/utils/route/route.ts | 2 +- .../shared/src/utils/shortcode/shortcode.ts | 2 +- packages/stores/package.json | 7 +- packages/stores/src/mockStore.ts | 37 +++ packages/stores/types.ts | 38 +++ 88 files changed, 1313 insertions(+), 1210 deletions(-) delete mode 100644 packages/reports/src/Components/Elements/ContentLoader/index.js create mode 100644 packages/reports/src/Components/Elements/ContentLoader/index.ts rename packages/reports/src/Components/Elements/ContentLoader/{positions-card.jsx => positions-card.tsx} (90%) rename packages/reports/src/Components/Elements/ContentLoader/{reports-table-row.jsx => reports-table-row.tsx} (85%) rename packages/reports/src/Components/Errors/{error-component.jsx => error-component.tsx} (72%) delete mode 100644 packages/reports/src/Components/Errors/index.js create mode 100644 packages/reports/src/Components/Errors/index.ts delete mode 100644 packages/reports/src/Components/Form/CompositeCalendar/calendar-icon.jsx create mode 100644 packages/reports/src/Components/Form/CompositeCalendar/calendar-icon.tsx rename packages/reports/src/Components/Form/CompositeCalendar/{composite-calendar-mobile.jsx => composite-calendar-mobile.tsx} (80%) rename packages/reports/src/Components/Form/CompositeCalendar/{composite-calendar.jsx => composite-calendar.tsx} (64%) delete mode 100644 packages/reports/src/Components/Form/CompositeCalendar/index.js create mode 100644 packages/reports/src/Components/Form/CompositeCalendar/index.ts rename packages/reports/src/Components/Form/CompositeCalendar/{list-item.jsx => list-item.tsx} (52%) rename packages/reports/src/Components/Form/CompositeCalendar/{side-list.jsx => side-list.tsx} (54%) rename packages/reports/src/Components/Form/CompositeCalendar/{two-month-picker.jsx => two-month-picker.tsx} (64%) rename packages/reports/src/Components/Routes/__tests__/{helpers.spec.js => helpers.spec.tsx} (85%) rename packages/reports/src/Components/Routes/{binary-link.jsx => binary-link.tsx} (50%) delete mode 100644 packages/reports/src/Components/Routes/binary-routes.jsx create mode 100644 packages/reports/src/Components/Routes/binary-routes.tsx delete mode 100644 packages/reports/src/Components/Routes/helpers.js create mode 100644 packages/reports/src/Components/Routes/helpers.ts delete mode 100644 packages/reports/src/Components/Routes/index.js create mode 100644 packages/reports/src/Components/Routes/index.ts rename packages/reports/src/Components/Routes/{route-with-sub-routes.jsx => route-with-sub-routes.tsx} (74%) rename packages/reports/src/Components/{account-statistics.jsx => account-statistics.tsx} (89%) delete mode 100644 packages/reports/src/Components/amount-cell.jsx rename packages/reports/src/Components/{currency-wrapper.jsx => currency-wrapper.tsx} (65%) rename packages/reports/src/Components/{empty-portfolio-message.jsx => empty-portfolio-message.tsx} (88%) rename packages/reports/src/Components/{empty-trade-history-message.jsx => empty-trade-history-message.tsx} (76%) rename packages/reports/src/Components/{filter-component.jsx => filter-component.tsx} (80%) delete mode 100644 packages/reports/src/Components/index.js create mode 100644 packages/reports/src/Components/index.ts rename packages/reports/src/Components/{indicative-cell.jsx => indicative-cell.tsx} (70%) rename packages/reports/src/Components/{market-symbol-icon-row.jsx => market-symbol-icon-row.tsx} (82%) create mode 100644 packages/reports/src/Components/placeholder-component.tsx rename packages/reports/src/Components/{profit_loss_cell.jsx => profit_loss_cell.tsx} (57%) delete mode 100644 packages/reports/src/Components/reports-meta.jsx create mode 100644 packages/reports/src/Components/reports-meta.tsx rename packages/reports/src/Constants/{data-table-constants.js => data-table-constants.tsx} (78%) rename packages/reports/src/Constants/{routes-config.js => routes-config.tsx} (85%) rename packages/reports/src/Containers/__tests__/{open-positions-table.spec.js => open-positions-table.spec.tsx} (100%) delete mode 100644 packages/reports/src/Containers/index.js create mode 100644 packages/reports/src/Containers/index.ts rename packages/reports/src/Containers/{open-positions.jsx => open-positions.tsx} (75%) rename packages/reports/src/Containers/{profit-table.jsx => profit-table.tsx} (79%) rename packages/reports/src/Containers/{progress-slider-stream.jsx => progress-slider-stream.tsx} (67%) rename packages/reports/src/Containers/{reports.jsx => reports.tsx} (57%) delete mode 100644 packages/reports/src/Containers/routes.jsx create mode 100644 packages/reports/src/Containers/routes.tsx rename packages/reports/src/Containers/{statement.jsx => statement.tsx} (67%) delete mode 100644 packages/reports/src/Helpers/digits.js create mode 100644 packages/reports/src/Helpers/digits.ts rename packages/reports/src/Helpers/{market-underlying.js => market-underlying.ts} (56%) delete mode 100644 packages/reports/src/Helpers/profit-loss.js create mode 100644 packages/reports/src/Helpers/profit-loss.ts rename packages/reports/src/Modules/Page404/Components/{Page404.jsx => Page404.tsx} (100%) delete mode 100644 packages/reports/src/Modules/Page404/index.js create mode 100644 packages/reports/src/Modules/Page404/index.ts delete mode 100644 packages/reports/src/Modules/SmartChart/Components/Markers/__tests__/marker-spot.spec.tsx delete mode 100644 packages/reports/src/Modules/SmartChart/Components/Markers/marker-line.jsx delete mode 100644 packages/reports/src/Modules/SmartChart/Components/Markers/marker-spot.jsx delete mode 100644 packages/reports/src/Modules/SmartChart/Helpers/symbol.js delete mode 100644 packages/reports/src/Stores/index.js create mode 100644 packages/reports/src/Stores/index.ts create mode 100644 packages/reports/src/Types/common-prop.type.ts create mode 100644 packages/reports/src/Types/index.ts delete mode 100644 packages/reports/src/_common/contract.js delete mode 100644 packages/reports/src/app.jsx create mode 100644 packages/reports/src/app.tsx rename packages/reports/src/{index.jsx => index.tsx} (91%) rename packages/reports/src/templates/_common/components/{loading.jsx => loading.tsx} (69%) diff --git a/packages/components/src/components/label/label.tsx b/packages/components/src/components/label/label.tsx index 8bb0c5f953f8..922998e40da7 100644 --- a/packages/components/src/components/label/label.tsx +++ b/packages/components/src/components/label/label.tsx @@ -18,7 +18,7 @@ const available_sizes = ['regular', 'large'] as const; type TLabel = { mode: typeof available_modes[number]; - size: typeof available_sizes[number]; + size?: typeof available_sizes[number]; className?: string; }; diff --git a/packages/reports/build/constants.js b/packages/reports/build/constants.js index 45261133230f..9baedc23952b 100644 --- a/packages/reports/build/constants.js +++ b/packages/reports/build/constants.js @@ -28,6 +28,7 @@ const ALIASES = { Modules: path.resolve(__dirname, '../src/Modules'), Sass: path.resolve(__dirname, '../src/sass'), Stores: path.resolve(__dirname, '../src/Stores'), + Types: path.resolve(__dirname, '../src/Types'), }; const rules = (is_test_env = false) => [ diff --git a/packages/reports/build/loaders-config.js b/packages/reports/build/loaders-config.js index 244d0aa2d1b8..4024a6b51072 100644 --- a/packages/reports/build/loaders-config.js +++ b/packages/reports/build/loaders-config.js @@ -2,9 +2,6 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const path = require('path'); const js_loaders = [ - { - loader: '@deriv/shared/src/loaders/react-import-loader.js', - }, { loader: '@deriv/shared/src/loaders/deriv-account-loader.js', }, diff --git a/packages/reports/build/webpack.config.js b/packages/reports/build/webpack.config.js index c436373ec902..416461e592ae 100644 --- a/packages/reports/build/webpack.config.js +++ b/packages/reports/build/webpack.config.js @@ -8,7 +8,7 @@ module.exports = function (env) { context: path.resolve(__dirname, '../'), devtool: IS_RELEASE ? undefined : 'eval-cheap-module-source-map', entry: { - reports: path.resolve(__dirname, '../src', 'index.jsx'), + reports: path.resolve(__dirname, '../src', 'index'), }, mode: IS_RELEASE ? 'production' : 'development', module: { diff --git a/packages/reports/jest.config.js b/packages/reports/jest.config.js index 97d0c11394ac..babd5fc48328 100644 --- a/packages/reports/jest.config.js +++ b/packages/reports/jest.config.js @@ -15,5 +15,7 @@ module.exports = { '^Utils/(.*)$': '/src/Utils/$1', '^Services/(.*)$': '/src/Services/$1', '^Stores/(.*)$': '/src/Stores/$1', + '^Types/(.*)$': '/src/Types/$1', + '^Types$': '/src/Types/index.ts', }, }; diff --git a/packages/reports/package.json b/packages/reports/package.json index 7af00948c925..c875375fccae 100644 --- a/packages/reports/package.json +++ b/packages/reports/package.json @@ -79,6 +79,7 @@ "@deriv/components": "^1.0.0", "@deriv/deriv-api": "^1.0.11", "@deriv/shared": "^1.0.0", + "@deriv/stores": "^1.0.0", "@deriv/translations": "^1.0.0", "@types/react": "^18.0.7", "@types/react-dom": "^18.0.0", diff --git a/packages/reports/src/Components/Elements/ContentLoader/index.js b/packages/reports/src/Components/Elements/ContentLoader/index.js deleted file mode 100644 index 9e70635b68c6..000000000000 --- a/packages/reports/src/Components/Elements/ContentLoader/index.js +++ /dev/null @@ -1 +0,0 @@ -export * from './reports-table-row.jsx'; diff --git a/packages/reports/src/Components/Elements/ContentLoader/index.ts b/packages/reports/src/Components/Elements/ContentLoader/index.ts new file mode 100644 index 000000000000..1995095d0fa0 --- /dev/null +++ b/packages/reports/src/Components/Elements/ContentLoader/index.ts @@ -0,0 +1 @@ +export * from './reports-table-row'; diff --git a/packages/reports/src/Components/Elements/ContentLoader/positions-card.jsx b/packages/reports/src/Components/Elements/ContentLoader/positions-card.tsx similarity index 90% rename from packages/reports/src/Components/Elements/ContentLoader/positions-card.jsx rename to packages/reports/src/Components/Elements/ContentLoader/positions-card.tsx index d0fba00e5530..6df94a02173f 100644 --- a/packages/reports/src/Components/Elements/ContentLoader/positions-card.jsx +++ b/packages/reports/src/Components/Elements/ContentLoader/positions-card.tsx @@ -1,8 +1,11 @@ import ContentLoader from 'react-content-loader'; import React from 'react'; -import PropTypes from 'prop-types'; -const PositionsCardLoader = ({ speed }) => ( +type TPositionCardLoader = { + speed?: number; +}; + +const PositionsCardLoader = ({ speed }: TPositionCardLoader) => ( ( ); -PositionsCardLoader.propTypes = { - speed: PropTypes.number, -}; - export { PositionsCardLoader }; diff --git a/packages/reports/src/Components/Elements/ContentLoader/reports-table-row.jsx b/packages/reports/src/Components/Elements/ContentLoader/reports-table-row.tsx similarity index 85% rename from packages/reports/src/Components/Elements/ContentLoader/reports-table-row.jsx rename to packages/reports/src/Components/Elements/ContentLoader/reports-table-row.tsx index fbb6606d9395..76a490aa4bc7 100644 --- a/packages/reports/src/Components/Elements/ContentLoader/reports-table-row.jsx +++ b/packages/reports/src/Components/Elements/ContentLoader/reports-table-row.tsx @@ -1,8 +1,11 @@ import ContentLoader from 'react-content-loader'; import React from 'react'; -import PropTypes from 'prop-types'; -const ReportsTableRowLoader = ({ speed }) => ( +type TReportsTableRowLoader = { + speed?: number; +}; + +const ReportsTableRowLoader = ({ speed }: TReportsTableRowLoader) => ( ( ); -ReportsTableRowLoader.propTypes = { - speed: PropTypes.number, -}; - export { ReportsTableRowLoader }; diff --git a/packages/reports/src/Components/Errors/error-component.jsx b/packages/reports/src/Components/Errors/error-component.tsx similarity index 72% rename from packages/reports/src/Components/Errors/error-component.jsx rename to packages/reports/src/Components/Errors/error-component.tsx index ffcebae1b5fe..29358a696e5a 100644 --- a/packages/reports/src/Components/Errors/error-component.jsx +++ b/packages/reports/src/Components/Errors/error-component.tsx @@ -1,8 +1,8 @@ -import PropTypes from 'prop-types'; import React from 'react'; import { Dialog, PageErrorContainer } from '@deriv/components'; import { routes } from '@deriv/shared'; import { localize } from '@deriv/translations'; +import { TErrorComponent } from 'Types'; const ErrorComponent = ({ header, @@ -11,7 +11,7 @@ const ErrorComponent = ({ redirect_label, redirectOnClick, should_show_refresh = true, -}) => { +}: Partial) => { const refresh_message = should_show_refresh ? localize('Please refresh this page to continue.') : ''; if (is_dialog) { @@ -21,6 +21,7 @@ const ErrorComponent = ({ is_visible confirm_button_text={redirect_label || localize('Ok')} onConfirm={redirectOnClick || (() => location.reload())} + has_close_icon={false} > {message || localize('Sorry, an error occured while processing your request.')} @@ -29,7 +30,7 @@ const ErrorComponent = ({ return ( location.reload())} @@ -37,14 +38,4 @@ const ErrorComponent = ({ ); }; -ErrorComponent.propTypes = { - header: PropTypes.string, - is_dialog: PropTypes.bool, - message: PropTypes.oneOfType([PropTypes.node, PropTypes.string, PropTypes.object]), - redirect_label: PropTypes.string, - redirectOnClick: PropTypes.func, - should_show_refresh: PropTypes.bool, - type: PropTypes.string, -}; - export default ErrorComponent; diff --git a/packages/reports/src/Components/Errors/index.js b/packages/reports/src/Components/Errors/index.js deleted file mode 100644 index dc12ba08a1e7..000000000000 --- a/packages/reports/src/Components/Errors/index.js +++ /dev/null @@ -1 +0,0 @@ -export default from './error-component.jsx'; diff --git a/packages/reports/src/Components/Errors/index.ts b/packages/reports/src/Components/Errors/index.ts new file mode 100644 index 000000000000..8585809410a1 --- /dev/null +++ b/packages/reports/src/Components/Errors/index.ts @@ -0,0 +1,3 @@ +import ErrorComponent from './error-component'; + +export default ErrorComponent; diff --git a/packages/reports/src/Components/Form/CompositeCalendar/calendar-icon.jsx b/packages/reports/src/Components/Form/CompositeCalendar/calendar-icon.jsx deleted file mode 100644 index ddae60f2e40e..000000000000 --- a/packages/reports/src/Components/Form/CompositeCalendar/calendar-icon.jsx +++ /dev/null @@ -1,11 +0,0 @@ -import PropTypes from 'prop-types'; -import React from 'react'; -import { Icon } from '@deriv/components'; - -const CalendarIcon = ({ onClick }) => ; - -CalendarIcon.propTypes = { - onClick: PropTypes.func, -}; - -export default CalendarIcon; diff --git a/packages/reports/src/Components/Form/CompositeCalendar/calendar-icon.tsx b/packages/reports/src/Components/Form/CompositeCalendar/calendar-icon.tsx new file mode 100644 index 000000000000..5115ae575d28 --- /dev/null +++ b/packages/reports/src/Components/Form/CompositeCalendar/calendar-icon.tsx @@ -0,0 +1,12 @@ +import React from 'react'; +import { Icon } from '@deriv/components'; + +type TCalendarIcon = { + onClick: () => void; +}; + +const CalendarIcon = ({ onClick }: TCalendarIcon) => ( + +); + +export default CalendarIcon; diff --git a/packages/reports/src/Components/Form/CompositeCalendar/composite-calendar-mobile.jsx b/packages/reports/src/Components/Form/CompositeCalendar/composite-calendar-mobile.tsx similarity index 80% rename from packages/reports/src/Components/Form/CompositeCalendar/composite-calendar-mobile.jsx rename to packages/reports/src/Components/Form/CompositeCalendar/composite-calendar-mobile.tsx index b866304bf1e8..d3fb19e714e4 100644 --- a/packages/reports/src/Components/Form/CompositeCalendar/composite-calendar-mobile.jsx +++ b/packages/reports/src/Components/Form/CompositeCalendar/composite-calendar-mobile.tsx @@ -1,11 +1,20 @@ import classNames from 'classnames'; -import PropTypes from 'prop-types'; import React from 'react'; import { Button, DatePicker, Icon, InputField, MobileDialog, Text } from '@deriv/components'; import { localize } from '@deriv/translations'; import { toMoment } from '@deriv/shared'; +import { TInputDateRange } from 'Types'; -export const RadioButton = ({ id, className, selected_value, value, label, onChange }) => { +type TRadioButton = { + id: string; + className?: string; + selected_value?: string; + value?: string; + label?: string; + onChange: (value: { label?: string; value?: string }) => void; +}; + +export const RadioButton = ({ id, className, selected_value, value, label, onChange }: TRadioButton) => { return (