diff --git a/.bruno/BRF/api-transactions.bru b/.bruno/BRF/api-transactions.bru new file mode 100644 index 0000000..fccb7c1 --- /dev/null +++ b/.bruno/BRF/api-transactions.bru @@ -0,0 +1,15 @@ +meta { + name: /api/transactions + type: http + seq: 14 +} + +get { + url: {{base_url}}/api/transactions + body: none + auth: inherit +} + +settings { + encodeUrl: true +} diff --git a/client/public/components/accounts_page.tsx b/client/public/components/accounts_page.tsx index 318df3f..4709118 100644 --- a/client/public/components/accounts_page.tsx +++ b/client/public/components/accounts_page.tsx @@ -20,7 +20,7 @@ const AccountsPage = () => {
| Number | Description | diff --git a/client/public/components/app.tsx b/client/public/components/app.tsx index 76f6858..3b0b139 100644 --- a/client/public/components/app.tsx +++ b/client/public/components/app.tsx @@ -1,14 +1,43 @@ import { h } from 'preact' +import { useCallback, useEffect } from 'preact/hooks' import { LocationProvider, Route, Router } from 'preact-iso' +import { get } from 'lowline' import Head from './head.ts' import Footer from './footer.tsx' import Header from './header.tsx' import ErrorPage from './error_page.tsx' import routes from '../routes.ts' +import throttle from '../../shared/utils/throttle.ts' import s from './app.module.scss' +const remember = throttle(function remember() { + window.history.replaceState( + { + ...window.history.state, + scrollTop: window.scrollY, + }, + '', + null, + ) +}, 100) + export default function App({ error, url, title }) { + useEffect(() => { + addEventListener('scroll', remember) + + return () => removeEventListener('scroll', remember) + }) + + const onRouteChange = useCallback(() => { + const offset = get(window.history, 'state.scrollTop') + console.log('offset', offset) + + setTimeout(() => { + window.scrollTo(0, offset || 0) + }, 100) + }, []) + return (
|---|
| ID | @@ -85,10 +85,13 @@ const EntriesPage = () => {{entry.id} | -{entry.number} | ++ {entry.journal} + {entry.number} + | {entry.entryDate?.slice(0, 10)} | {entry.transactionDate?.slice(0, 10)} | -{entry.amount} | +{entry.amount} | {entry.description} |
|---|
| ID | @@ -58,14 +52,14 @@ const EntriesPage = () => {{entry.number} | {entry.entryDate?.slice(0, 10)} | {entry.transactionDate?.slice(0, 10)} | -{entry.amount} | +{entry.amount} | {entry.description} |
|---|
| Account | @@ -78,8 +72,8 @@ const EntriesPage = () => { {entry?.transactions?.map((transaction) => (|||||
|---|---|---|---|---|---|
| {transaction.account_number} | -{transaction.amount >= 0 ? formatNumber(transaction.amount) : null} | -{transaction.amount < 0 ? formatNumber(Math.abs(transaction.amount)) : null} | +{transaction.amount >= 0 ? formatNumber(transaction.amount) : null} | +{transaction.amount < 0 ? formatNumber(Math.abs(transaction.amount)) : null} | {transaction.description} |