From 7c2f6e165956197b139962a2a2fef370e0952012 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Mon, 7 Nov 2022 04:50:43 -0800 Subject: [PATCH] Small fixes --- frontend/src/basic/BookPage/index.tsx | 1 + frontend/src/basic/Main.tsx | 3 ++- frontend/src/basic/MakerPage/index.tsx | 3 +++ frontend/src/components/MakerForm/MakerForm.tsx | 7 ++++--- frontend/src/components/SettingsForm/index.tsx | 5 ++++- frontend/src/models/Settings.model.ts | 5 ++++- mobile/App.tsx | 1 + 7 files changed, 19 insertions(+), 6 deletions(-) diff --git a/frontend/src/basic/BookPage/index.tsx b/frontend/src/basic/BookPage/index.tsx index f317d3954..d5aca5e7a 100644 --- a/frontend/src/basic/BookPage/index.tsx +++ b/frontend/src/basic/BookPage/index.tsx @@ -132,6 +132,7 @@ const BookPage = ({ setPage('order'); history.push('/order/' + id); }} + baseUrl={baseUrl} /> diff --git a/frontend/src/basic/Main.tsx b/frontend/src/basic/Main.tsx index 7b74b653e..c43ee751c 100644 --- a/frontend/src/basic/Main.tsx +++ b/frontend/src/basic/Main.tsx @@ -107,7 +107,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { window.removeEventListener('resize', onResize); } }; - }, []); + }, [baseUrl]); useEffect(() => { let host = ''; @@ -316,6 +316,7 @@ const Main = ({ settings, setSettings }: MainProps): JSX.Element => { setFav={setFav} windowSize={{ ...windowSize, height: windowSize.height - navbarHeight }} hasRobot={robot.avatarLoaded} + baseUrl={baseUrl} /> diff --git a/frontend/src/basic/MakerPage/index.tsx b/frontend/src/basic/MakerPage/index.tsx index 2635c04ad..08ed48a77 100644 --- a/frontend/src/basic/MakerPage/index.tsx +++ b/frontend/src/basic/MakerPage/index.tsx @@ -24,6 +24,7 @@ interface MakerPageProps { hasRobot: boolean; setCurrentOrder: (state: number) => void; setPage: (state: Page) => void; + baseUrl: string; } const MakerPage = ({ @@ -38,6 +39,7 @@ const MakerPage = ({ setCurrentOrder, setPage, hasRobot = false, + baseUrl, }: MakerPageProps): JSX.Element => { const { t } = useTranslation(); const history = useHistory(); @@ -108,6 +110,7 @@ const MakerPage = ({ onReset={() => setShowMatches(false)} submitButtonLabel={matches.length > 0 && !showMatches ? 'Submit' : 'Create order'} setPage={setPage} + baseUrl={baseUrl} /> diff --git a/frontend/src/components/MakerForm/MakerForm.tsx b/frontend/src/components/MakerForm/MakerForm.tsx index 657ef04ed..e32e3103e 100644 --- a/frontend/src/components/MakerForm/MakerForm.tsx +++ b/frontend/src/components/MakerForm/MakerForm.tsx @@ -29,9 +29,8 @@ import { LimitList, Maker, Favorites, defaultMaker } from '../../models'; import { LocalizationProvider, TimePicker } from '@mui/x-date-pickers'; import DateFnsUtils from '@date-io/date-fns'; import { useHistory } from 'react-router-dom'; -import { StoreTokenDialog, NoRobotDialog, ConfirmationDialog } from '../Dialogs'; +import { ConfirmationDialog } from '../Dialogs'; import { apiClient } from '../../services/api'; -import { systemClient } from '../../services/System'; import { FlagWithProps } from '../Icons'; import AutocompletePayments from './AutocompletePayments'; @@ -59,6 +58,7 @@ interface MakerFormProps { onOrderCreated?: (id: number) => void; hasRobot?: boolean; setPage?: (state: Page) => void; + baseUrl: string; } const MakerForm = ({ @@ -77,6 +77,7 @@ const MakerForm = ({ onOrderCreated = () => null, hasRobot = true, setPage = () => null, + baseUrl, }: MakerFormProps): JSX.Element => { const { t } = useTranslation(); const theme = useTheme(); @@ -263,7 +264,7 @@ const MakerForm = ({ escrow_duration: maker.escrowDuration, bond_size: maker.bondSize, }; - apiClient.post('/api/make/', body).then((data: object) => { + apiClient.post(baseUrl, '/api/make/', body).then((data: object) => { setBadRequest(data.bad_request); if (data.id) { onOrderCreated(data.id); diff --git a/frontend/src/components/SettingsForm/index.tsx b/frontend/src/components/SettingsForm/index.tsx index 4417529e5..1873150a1 100644 --- a/frontend/src/components/SettingsForm/index.tsx +++ b/frontend/src/components/SettingsForm/index.tsx @@ -150,7 +150,10 @@ const SettingsForm = ({ setSettings({ ...settings, network })} + onChange={(e, network) => { + setSettings({ ...settings, network }); + systemClient.setCookie('settings_network', network); + }} > {t('Mainnet')} diff --git a/frontend/src/models/Settings.model.ts b/frontend/src/models/Settings.model.ts index dd3805223..189c48f84 100644 --- a/frontend/src/models/Settings.model.ts +++ b/frontend/src/models/Settings.model.ts @@ -37,6 +37,9 @@ class BaseSettings { : i18n.resolvedLanguage == null ? 'en' : i18n.resolvedLanguage.substring(0, 2); + + const networkCookie = systemClient.getCookie('settings_network'); + this.network = networkCookie !== '' ? networkCookie : 'mainnet'; } public frontend: 'basic' | 'pro' = 'basic'; @@ -44,7 +47,7 @@ class BaseSettings { public fontSize: number = 14; public language?: Language; public freezeViewports: boolean = false; - public network: 'mainnet' | 'testnet' | undefined = 'testnet'; + public network: 'mainnet' | 'testnet' | undefined = 'mainnet'; public coordinator: Coordinator | undefined = undefined; public host?: string; public unsafeClient: boolean = false; diff --git a/mobile/App.tsx b/mobile/App.tsx index f0331f8fa..bc80029e6 100644 --- a/mobile/App.tsx +++ b/mobile/App.tsx @@ -50,6 +50,7 @@ const App = () => { loadCookie('settings_fontsize_basic'); loadCookie('settings_language'); loadCookie('settings_mode'); + loadCookie('settings_network'); loadCookie('enc_priv_key').then(() => injectMessageResolve(reponseId)); };