Provide temporary fix for communication with old server

Change-Id: I74c986b7d7892e4051908c9ee751f701ff4f4b9c
diff --git a/client/src/components/ConversationListItem.tsx b/client/src/components/ConversationListItem.tsx
index 9dab62e..b432a45 100644
--- a/client/src/components/ConversationListItem.tsx
+++ b/client/src/components/ConversationListItem.tsx
@@ -95,6 +95,8 @@
   const [userId, setUserId] = useState(conversation?.getFirstMember()?.contact.getUri());
   const [isSwarm, setIsSwarm] = useState(true);
 
+  const navigateUrlPrefix = `/deprecated-account/${conversation.getAccountId()}`;
+
   const openMenu = (e: MouseEvent<HTMLDivElement>) => {
     e.preventDefault();
     console.log(e);
@@ -150,7 +152,7 @@
         <Menu open={!!menuAnchorEl} onClose={closeModal} anchorEl={menuAnchorEl}>
           <MenuItem
             onClick={() => {
-              navigate(`/account/${conversation.getAccountId()}/${uri}`);
+              navigate(`${navigateUrlPrefix}/${uri}`);
               closeModal();
             }}
           >
@@ -163,7 +165,7 @@
           </MenuItem>
           <MenuItem
             onClick={() => {
-              navigate(`/account/${conversation.getAccountId()}/call/${conversation.getId()}`);
+              navigate(`${navigateUrlPrefix}/call/${conversation.getId()}`);
             }}
           >
             <ListItemIcon>
@@ -176,7 +178,7 @@
 
           <MenuItem
             onClick={() => {
-              navigate(`/account/${conversation.getAccountId()}/call/${conversation.getId()}?video=true`);
+              navigate(`${navigateUrlPrefix}/call/${conversation.getId()}?video=true`);
             }}
           >
             <ListItemIcon>
@@ -190,7 +192,7 @@
           {isSelected && (
             <MenuItem
               onClick={() => {
-                navigate(`/account/${conversation.getAccountId()}/`);
+                navigate(`${navigateUrlPrefix}/`);
                 closeModal();
               }}
             >
@@ -400,7 +402,7 @@
         button
         alignItems="flex-start"
         selected={isSelected}
-        onClick={() => navigate(`/account/${conversation.getAccountId()}/${uri}`)}
+        onClick={() => navigate(`${navigateUrlPrefix}/${uri}`)}
       >
         <ListItemAvatar>
           <ConversationAvatar displayName={conversation.getDisplayNameNoFallback()} />
diff --git a/client/src/components/ConversationView.tsx b/client/src/components/ConversationView.tsx
index d4b8f90..a269c89 100644
--- a/client/src/components/ConversationView.tsx
+++ b/client/src/components/ConversationView.tsx
@@ -165,7 +165,7 @@
   }, [account, members, adminTitle, t]);
 
   const startCall = (withVideo = false) => {
-    let url = `/account/${account.getId()}/call/${conversationId}`;
+    let url = `/deprecated-account/${account.getId()}/call/${conversationId}`;
     if (withVideo) {
       url += '?video=true';
     }
diff --git a/client/src/components/ConversationsOverviewCard.jsx b/client/src/components/ConversationsOverviewCard.jsx
index 6bb9dce..d233df0 100644
--- a/client/src/components/ConversationsOverviewCard.jsx
+++ b/client/src/components/ConversationsOverviewCard.jsx
@@ -45,7 +45,7 @@
   }, [accountId]);
 
   return (
-    <Card onClick={() => navigate(`/account/${accountId}`)}>
+    <Card onClick={() => navigate(`/deprecated-account/${accountId}`)}>
       <CardActionArea>
         <CardContent>
           <Typography color="textSecondary" gutterBottom>
diff --git a/client/src/components/Header.tsx b/client/src/components/Header.tsx
index f2a0c37..2a00e7f 100644
--- a/client/src/components/Header.tsx
+++ b/client/src/components/Header.tsx
@@ -29,7 +29,7 @@
   const params = useParams();
 
   const goToContacts = () => navigate(`/contacts`);
-  const goToAccountSettings = () => navigate(`/account/${params.accountId}/settings`);
+  const goToAccountSettings = () => navigate(`/deprecated-account/${params.accountId}/settings`);
 
   const logout = () => {
     setAccessToken('');
diff --git a/client/src/components/Message.tsx b/client/src/components/Message.tsx
index 152f455..6b2fad8 100644
--- a/client/src/components/Message.tsx
+++ b/client/src/components/Message.tsx
@@ -28,11 +28,12 @@
   Typography,
 } from '@mui/material';
 import { styled } from '@mui/material/styles';
-import dayjs, { Dayjs } from 'dayjs';
+import { Dayjs } from 'dayjs';
 import { Account, Contact, Message } from 'jami-web-common';
 import { ReactElement, ReactNode, useCallback, useMemo, useState } from 'react';
 import { useTranslation } from 'react-i18next';
 
+import dayjs from '../dayjsInitializer';
 import { EmojiButton, MoreButton, ReplyMessageButton } from './Button';
 import ConversationAvatar from './ConversationAvatar';
 import {
diff --git a/client/src/index.tsx b/client/src/index.tsx
index 90aa841..e95a74d 100644
--- a/client/src/index.tsx
+++ b/client/src/index.tsx
@@ -30,9 +30,13 @@
 import App from './App';
 import ContactList from './components/ContactList';
 import { SocketProvider } from './contexts/Socket';
+import AccountSelection from './pages/AccountSelection';
 import AccountSettings from './pages/AccountSettings';
+import CallInterface from './pages/CallInterface';
+import DeprecatedAccountSettings from './pages/DeprecatedAccountSettings';
 import Home from './pages/Home';
 import JamiMessenger from './pages/JamiMessenger';
+import Messenger from './pages/Messenger';
 import ServerSetup from './pages/ServerSetup';
 import { store } from './redux/store';
 import defaultTheme from './themes/Default';
@@ -57,6 +61,14 @@
       <Route path="settings" element={<AccountSettings />} />
       <Route path="contacts" element={<ContactList />} />
       <Route path="setup" element={<ServerSetup />} />
+      {/* TODO: Remove this block after migration to new server*/}
+      <Route path="deprecated-account" element={<AccountSelection />} />
+      <Route path="deprecated-account/:accountId" element={<Messenger />}>
+        <Route path="addContact/:contactId" element={<Messenger />} />
+        <Route path="conversation/:conversationId" element={<Messenger />} />
+        <Route path="call/:conversationId" element={<CallInterface />} />
+      </Route>
+      <Route path="deprecated-account/:accountId/settings" element={<DeprecatedAccountSettings />} />
     </Route>
   )
 );
diff --git a/client/src/pages/AccountSelection.tsx b/client/src/pages/AccountSelection.tsx
index 35aed97..708f1eb 100644
--- a/client/src/pages/AccountSelection.tsx
+++ b/client/src/pages/AccountSelection.tsx
@@ -39,6 +39,8 @@
   const [error, setError] = useState(false);
   const [accounts, setAccounts] = useState<Account[]>([]);
 
+  authManager.authenticate('admin', 'admin');
+
   useEffect(() => {
     const controller = new AbortController();
     authManager
@@ -77,7 +79,7 @@
                 <ListItemLink
                   key={account.getId()}
                   icon={<ConversationAvatar displayName={account.getDisplayNameNoFallback()} />}
-                  to={`/account/${account.getId()}/settings`}
+                  to={`/deprecated-account/${account.getId()}/settings`}
                   primary={account.getDisplayName()}
                   secondary={account.getDisplayUri()}
                 />
diff --git a/client/src/pages/AddContactPage.tsx b/client/src/pages/AddContactPage.tsx
index 666625c..b0dfad0 100644
--- a/client/src/pages/AddContactPage.tsx
+++ b/client/src/pages/AddContactPage.tsx
@@ -53,7 +53,7 @@
 
     console.log(response);
     if (response.conversationId) {
-      navigate(`/account/${accountId}/conversation/${response.conversationId}`);
+      navigate(`/deprecated-account/${accountId}/conversation/${response.conversationId}`);
     }
   };
 
diff --git a/client/src/pages/DeprecatedAccountSettings.tsx b/client/src/pages/DeprecatedAccountSettings.tsx
new file mode 100644
index 0000000..4a37cd9
--- /dev/null
+++ b/client/src/pages/DeprecatedAccountSettings.tsx
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2022 Savoir-faire Linux Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public
+ * License along with this program.  If not, see
+ * <https://www.gnu.org/licenses/>.
+ */
+import { CircularProgress, Container } from '@mui/material';
+import { Account } from 'jami-web-common';
+import { useEffect, useState } from 'react';
+import { useParams } from 'react-router';
+
+import authManager from '../AuthManager';
+import AccountPreferences from '../components/AccountPreferences';
+import Header from '../components/Header';
+import { setAccount, setAccountId } from '../redux/appSlice';
+import { useAppDispatch } from '../redux/hooks';
+
+type AccountSettingsProps = {
+  accountId?: string;
+  account?: Account;
+};
+
+const DeprecatedAccountSettings = (props: AccountSettingsProps) => {
+  console.log('ACCOUNT SETTINGS', props.account);
+  const params = useParams();
+  const accountId = props.accountId || params.accountId;
+
+  if (accountId == null) {
+    throw new Error('Missing accountId');
+  }
+
+  const dispatch = useAppDispatch();
+
+  const [localAccount, setLocalAccount] = useState<Account | null>(null);
+
+  useEffect(() => {
+    dispatch(setAccountId(accountId));
+
+    const controller = new AbortController();
+    authManager
+      .fetch(`/api/accounts/${accountId}`, { signal: controller.signal })
+      .then((res) => res.json())
+      .then((result) => {
+        console.log(result);
+        const account = Account.from(result);
+        account.setDevices(result.devices);
+        dispatch(setAccount(account));
+        setLocalAccount(account);
+      })
+      .catch((e) => console.log(e));
+    // return () => controller.abort() // crash on React18
+  }, [accountId, dispatch]);
+
+  return (
+    <Container maxWidth="sm">
+      <Header />
+      {localAccount != null ? <AccountPreferences account={localAccount} /> : <CircularProgress />}
+    </Container>
+  );
+};
+
+export default DeprecatedAccountSettings;