-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Initial (barebone) frontend setup
- Loading branch information
Showing
12 changed files
with
200 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { filename } from '../dal'; | ||
|
||
export default function (fastify, opts, done) { | ||
const routes = [ | ||
{ | ||
method: "GET", | ||
url: `/api/bootstrap`, | ||
handler: async function () { | ||
return { file: filename }; | ||
}, | ||
}, | ||
]; | ||
|
||
for (const route of routes) { | ||
fastify.route(route); | ||
} | ||
|
||
done(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const path = require("path"); | ||
const fullFile = process.env.LEDGER_FILE; | ||
|
||
export const filename = path.basename(fullFile); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
require("dotenv").config({ path: "../" }); | ||
require("dotenv"); | ||
|
||
import colors from 'colors/safe'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import React, { FC } from 'react'; | ||
import { useQuery } from 'react-query'; | ||
import { Route, Routes } from 'react-router-dom'; | ||
|
||
import Loader from 'atoms/Loader'; | ||
|
||
import Page from 'templates/Page'; | ||
|
||
import Dashboard from 'pages/dashboard'; | ||
|
||
const App: FC = () => { | ||
const { isLoading, error, data } = useQuery("bootstrap", () => | ||
fetch("/api/bootstrap").then((res) => res.json()) | ||
); | ||
|
||
console.log(isLoading, data); | ||
if (isLoading) { | ||
return <Loader />; | ||
} | ||
|
||
return ( | ||
<> | ||
<Page filename={data.file}> | ||
<Routes> | ||
<Route path="/" element={<Dashboard />} /> | ||
</Routes> | ||
</Page> | ||
</> | ||
); | ||
}; | ||
|
||
export default App; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React, { FC } from 'react'; | ||
|
||
import { createStyles, Loader as MLoader } from '@mantine/core'; | ||
|
||
const useStyles = createStyles(() => { | ||
return { | ||
wrapper: { textAlign: "center", margin: "1em 0" }, | ||
}; | ||
}); | ||
|
||
const Loader: FC = () => { | ||
const { classes } = useStyles(); | ||
return ( | ||
<div className={classes.wrapper}> | ||
<MLoader /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Loader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,33 @@ | ||
import React from 'react'; | ||
import { render } from 'react-dom'; | ||
import { QueryClient, QueryClientProvider } from 'react-query'; | ||
import { BrowserRouter, Route, Routes } from 'react-router-dom'; | ||
|
||
import Page from 'templates/Page'; | ||
|
||
import Dashboard from 'pages/dashboard'; | ||
|
||
import App from './App'; | ||
import GlobalStyle from './globalstyle'; | ||
import FourOhFour from './pages/four-oh-four'; | ||
|
||
const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
refetchOnWindowFocus: false, | ||
}, | ||
}, | ||
}); | ||
|
||
render( | ||
<> | ||
<GlobalStyle /> | ||
<Page> | ||
<QueryClientProvider client={queryClient}> | ||
<BrowserRouter> | ||
<Routes> | ||
<Route path="/404" element={<FourOhFour />} /> | ||
<Route path="/" element={<Dashboard />} /> | ||
<Route path="/*" element={<App />} /> | ||
</Routes> | ||
</BrowserRouter> | ||
</Page> | ||
</QueryClientProvider> | ||
</>, | ||
document.getElementById("rroot") | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,33 @@ | ||
import React, { FC } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const Main = styled.main` | ||
const Wrapper = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
min-height: 100vh; | ||
header { | ||
margin-bottom: 15px; | ||
h1 { | ||
margin-bottom: 5px; | ||
} | ||
} | ||
`; | ||
|
||
const Body = styled.div` | ||
padding: 1em; | ||
const Body = styled.main` | ||
flex: 1; | ||
background: #ecf0f5; | ||
`; | ||
|
||
const Page: FC = ({ children }) => ( | ||
<Main> | ||
const Page: FC<{ filename: string }> = ({ filename, children }) => ( | ||
<Wrapper> | ||
<header> | ||
<h1>kLedger UI</h1> | ||
<div>File in use: {filename}</div> | ||
</header> | ||
<Body>{children}</Body> | ||
</Main> | ||
<footer>github</footer> | ||
</Wrapper> | ||
); | ||
|
||
export default Page; |
Oops, something went wrong.