Skip to content

Commit

Permalink
feat: refactor title to add right floating things, move paginator there
Browse files Browse the repository at this point in the history
  • Loading branch information
hartym committed Mar 21, 2024
1 parent f8ad886 commit fa9a8d9
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
11 changes: 10 additions & 1 deletion frontend/src/Components/Page/PageTitle.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { ReactNode } from "react"

import { H1, P } from "mkui/Components/Typography"

export function PageTitle({ description, title }: { title?: string; description?: string }) {
interface PageTitleProps {
title?: string
description?: string
children?: ReactNode
}

export function PageTitle({ description, title, children }: PageTitleProps) {
return (
<>
{title ? (
<div className="mt-4 mb-4">
{children ? <div className="float-end">{children}</div> : null}
<H1>{title}</H1>
{description ? <P>{description}</P> : null}
</div>
Expand Down
37 changes: 20 additions & 17 deletions frontend/src/Pages/Transactions/TransactionListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,6 @@ function TransactionListPageOnQuerySuccess({
const [isFiltersOpen, setIsFiltersOpen] = useState(true)

const detailQuery = useTransactionsDetailQuery(selected?.id)
const paginatorProps = {
current: page,
setPage: setPage,
total: query.isSuccess ? query.data.total ?? undefined : undefined,
pages: query.isSuccess ? query.data.pages ?? undefined : undefined,
perPage: query.isSuccess ? query.data.perPage ?? undefined : undefined,
}
return (
<div className="flex w-full items-start gap-x-8 relative">
{isFiltersOpen ? (
Expand Down Expand Up @@ -71,13 +64,6 @@ function TransactionListPageOnQuerySuccess({
}
selected={hasSelection ? selected : undefined}
/>

{(paginatorProps.total || 0) > 0 ? (
<Paginator {...paginatorProps} showSummary={false} className={hasSelection ? "invisible" : ""} />
) : null}
{(paginatorProps.total || 0) > 0 ? (
<Paginator {...paginatorProps} className={hasSelection ? "invisible" : ""} />
) : null}
</main>

{hasSelection ? (
Expand All @@ -103,8 +89,27 @@ export function TransactionListPage() {
}
}, [page, query])

let paginator = null
if (query.isSuccess) {
const paginatorProps = {
current: page,
setPage: setPage,
total: query.isSuccess ? query.data.total ?? undefined : undefined,
pages: query.isSuccess ? query.data.pages ?? undefined : undefined,
perPage: query.isSuccess ? query.data.perPage ?? undefined : undefined,
}

paginator = (paginatorProps.total || 0) > 0 ? <Paginator {...paginatorProps} showSummary={false} /> : null
}

return (
<Page title={<PageTitle title="Transactions" />}>
<Page
title={
<PageTitle title="Transactions" description="Explore transactions that went through the proxy">
{paginator}
</PageTitle>
}
>
<OnQuerySuccess query={query}>
{(query) => (
<TransactionListPageOnQuerySuccess
Expand All @@ -119,5 +124,3 @@ export function TransactionListPage() {
</Page>
)
}

//title="Transactions" description="Explore transactions that went through the proxy"

0 comments on commit fa9a8d9

Please sign in to comment.