diff --git a/src/app.tsx b/src/app.tsx index 7eaaba2..a3e0284 100644 --- a/src/app.tsx +++ b/src/app.tsx @@ -1,14 +1,13 @@ import { createRoot } from 'react-dom/client'; import { RouterProvider, createMemoryRouter } from 'react-router'; -import { styled } from 'styled-components'; import React, { PureComponent } from 'react'; import Root from './routes/root'; import ErrorPage from './error-page'; import { Home } from './routes/home'; -import ConnectionPage from './component/Connection/ConnectionPage'; import TableLayout from './component/TableLayout'; -import ConnectionForm from './component/Connection/ConnectionForm'; import { Tables } from './routes/tables'; +import Connect from './routes/connect'; +import Create from './routes/connect/create'; const root = createRoot(document.getElementById('App')); @@ -17,12 +16,6 @@ const root = createRoot(document.getElementById('App')); // export const history = createMemoryHistory(); // -const ModalLike = styled.div` - width: 50%; - min-width: 400px; - align-self: center; -`; - const router = createMemoryRouter([ { path: '/', @@ -38,19 +31,11 @@ const router = createMemoryRouter([ children: [ { index: true, - element: ( - - - - ), + element: , }, { path: 'create', - element: ( - - - - ), + element: , }, ], }, diff --git a/src/component/Connection/ConnectionForm.tsx b/src/component/Connection/ConnectionForm.tsx index 44cb09e..d78ee88 100644 --- a/src/component/Connection/ConnectionForm.tsx +++ b/src/component/Connection/ConnectionForm.tsx @@ -6,10 +6,12 @@ import { } from '../../Contexts'; import { ConnectionObject } from './types'; import { PureComponent, useContext } from 'react'; +import { NavigateFunction, useNavigate } from 'react-router'; interface ConnectionFormProps { connectTo: ConnectToFunc; addConnectionToConfig: (connection: ConnectionObject) => void; + navigate: NavigateFunction; } type ConnectionFormType = ConnectionObject & { save: boolean; @@ -34,6 +36,8 @@ class ConnectionForm extends PureComponent { } render() { + const { navigate } = this.props; + const initialValues = { name: '', host: 'localhost', @@ -86,6 +90,13 @@ class ConnectionForm extends PureComponent { > + @@ -98,9 +109,11 @@ class ConnectionForm extends PureComponent { function ConnectionFormWithContext() { const { connectTo } = useContext(ConnectionContext); const { addConnectionToConfig } = useConfiguration(); + const navigate = useNavigate(); return ( diff --git a/src/component/Style/ModalLike.tsx b/src/component/Style/ModalLike.tsx new file mode 100644 index 0000000..79245e3 --- /dev/null +++ b/src/component/Style/ModalLike.tsx @@ -0,0 +1,23 @@ +import { styled } from 'styled-components'; + +const Container = styled.div` + height: 100%; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; +`; + +const Content = styled.div` + width: 50%; + min-width: 400px; + align-self: center; +`; + +export default function ModalLike({ children }: { children: React.ReactNode }) { + return ( + + {children} + + ); +} diff --git a/src/configuration/index.ts b/src/configuration/index.ts index ccbb2cc..654449a 100644 --- a/src/configuration/index.ts +++ b/src/configuration/index.ts @@ -10,6 +10,7 @@ import { EncryptedConfiguration, } from './type'; +// TODO use app.getPath('userData') to store the configuration file instead of env-paths const envPath = envPaths('TianaTables', { suffix: '' }); const dataFilePath = resolve(envPath.config, 'config.json'); diff --git a/src/routes/connect.tsx b/src/routes/connect.tsx new file mode 100644 index 0000000..e090ef2 --- /dev/null +++ b/src/routes/connect.tsx @@ -0,0 +1,10 @@ +import ModalLike from '../component/Style/ModalLike'; +import ConnectionPage from '../component/Connection/ConnectionPage'; + +export default function Connect() { + return ( + + + + ); +} diff --git a/src/routes/connect/create.tsx b/src/routes/connect/create.tsx new file mode 100644 index 0000000..6a7f885 --- /dev/null +++ b/src/routes/connect/create.tsx @@ -0,0 +1,10 @@ +import ModalLike from '../../component/Style/ModalLike'; +import ConnectionFormWithContext from '../../component/Connection/ConnectionForm'; + +export default function Create() { + return ( + + + + ); +} diff --git a/src/routes/home.tsx b/src/routes/home.tsx index 8bffa8e..1f7d430 100644 --- a/src/routes/home.tsx +++ b/src/routes/home.tsx @@ -4,7 +4,7 @@ import { Button } from 'antd'; export function Home() { return (
-

Welcome to Tiana Tables !

+

Tiana Tables !