Skip to content

Commit

Permalink
Merge pull request #3 from vinu-deriv/Vinu/79690/deriv-ui-addition
Browse files Browse the repository at this point in the history
Vinu/feat: added @deriv/ui in cashier
  • Loading branch information
heorhi-deriv committed Oct 27, 2022
2 parents f7e6804 + 64ca34e commit 3b0cc08
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
1 change: 1 addition & 0 deletions packages/cashier/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"@deriv/p2p": "^0.7.3",
"@deriv/shared": "^1.0.0",
"@deriv/translations": "^1.0.0",
"@deriv/ui": "^0.0.15",
"classnames": "^2.2.6",
"formik": "^2.1.4",
"loadjs": "^4.2.0",
Expand Down
9 changes: 6 additions & 3 deletions packages/cashier/src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { init } from 'Utils/server_time';
import Routes from 'Containers/routes';
import { MobxContentProvider } from 'Stores/connect';
import { StoreProvider } from './hooks';
import { ThemeProvider } from '@deriv/ui';

const App = ({ passthrough: { WS, root_store } }) => {
React.useEffect(() => {
Expand All @@ -14,9 +15,11 @@ const App = ({ passthrough: { WS, root_store } }) => {

return (
<MobxContentProvider store={root_store}>
<StoreProvider store={root_store}>
<Routes />
</StoreProvider>
<ThemeProvider>
<StoreProvider store={root_store}>
<Routes />
</StoreProvider>
</ThemeProvider>
</MobxContentProvider>
);
};
Expand Down
13 changes: 11 additions & 2 deletions packages/cashier/src/containers/routes/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { RouteComponentProps, withRouter } from 'react-router';
import { useTheme } from '@deriv/ui';
import { connect } from 'Stores/connect';
import { TClientStore, TCommonStore, TRootStore } from 'Types';
import BinaryRoutes from './binary-routes';
Expand All @@ -10,9 +11,16 @@ type TRoutesProps = RouteComponentProps & {
has_error: TCommonStore['has_error'];
is_logged_in: TClientStore['is_logged_in'];
is_logging_in: TClientStore['is_logging_in'];
is_dark_mode_on: boolean;
};

const Routes = ({ error, has_error, is_logged_in, is_logging_in }: TRoutesProps) => {
const Routes = ({ error, has_error, is_logged_in, is_logging_in, is_dark_mode_on }: TRoutesProps) => {
const { setColorMode } = useTheme();

React.useEffect(() => {
setColorMode(is_dark_mode_on ? 'dark' : 'light');
}, [is_dark_mode_on]);

if (has_error) {
return <ErrorComponent {...error} />;
}
Expand All @@ -22,9 +30,10 @@ const Routes = ({ error, has_error, is_logged_in, is_logging_in }: TRoutesProps)

// need to wrap withRouter around connect
// to prevent updates on <BinaryRoutes /> from being blocked
export default connect(({ client, common }: TRootStore) => ({
export default connect(({ client, common, ui }: TRootStore) => ({
is_logged_in: client.is_logged_in,
is_logging_in: client.is_logging_in,
error: common.error,
has_error: common.has_error,
is_dark_mode_on: ui.is_dark_mode_on,
}))(withRouter(Routes));

0 comments on commit 3b0cc08

Please sign in to comment.