Skip to content

Commit

Permalink
Verified | Reporting tab (#1520)
Browse files Browse the repository at this point in the history
* verified commit

* refactor: Add Reporting tab to investor view and dry out into PoolReportPage

* add missing dependencies

* add missing dependencies

* move headers and columns outside of component

* add missing dependencies

* disable eslint

* missing dependencies

* refactor: Rename to ReportContextType

* remove not used startDate

* eslint disable
  • Loading branch information
Hornebom authored Aug 21, 2023
1 parent b17f6c5 commit 5aa1b52
Show file tree
Hide file tree
Showing 28 changed files with 1,192 additions and 548 deletions.
14 changes: 9 additions & 5 deletions centrifuge-app/src/components/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import BN from 'bn.js'
import * as React from 'react'
import { Link, LinkProps } from 'react-router-dom'
import styled from 'styled-components'
import { useElementScrollSize } from '../utils/useElementScrollSize'

type GroupedProps = {
groupIndex?: number
Expand Down Expand Up @@ -68,6 +69,8 @@ export const DataTable = <T extends Record<string, any>>({
)

const [currentSortKey, setCurrentSortKey] = React.useState(defaultSortKey || '')
const ref = React.useRef(null)
const { scrollWidth } = useElementScrollSize(ref)

const updateSortOrder = (sortKey: Column['sortKey']) => {
if (!sortKey) return
Expand All @@ -82,8 +85,9 @@ export const DataTable = <T extends Record<string, any>>({
}, [orderBy, data, currentSortKey, page, pageSize])

const showHeader = groupIndex === 0 || !groupIndex

return (
<Stack as={rounded && !lastGroupIndex ? Card : Stack}>
<Stack ref={ref} as={rounded && !lastGroupIndex ? Card : Stack} minWidth={scrollWidth > 0 ? scrollWidth : 'auto'}>
<Shelf>
{showHeader &&
columns.map((col, i) => (
Expand Down Expand Up @@ -189,22 +193,22 @@ const DataCol = styled(Text)<{ align: Column['align'] }>`
white-space: nowrap;
&:first-child {
padding-right: '16px';
padding-right: 16px;
}
${({ align }) => {
switch (align) {
case 'left':
return css({
justifyContent: 'flex-start',
'&:last-child': {
paddingRight: '16px',
paddingRight: 16,
},
})
case 'center':
return css({
justifyContent: 'center',
'&:last-child': {
paddingRight: '16px',
paddingRight: 16,
},
})
case 'right':
Expand All @@ -214,7 +218,7 @@ const DataCol = styled(Text)<{ align: Column['align'] }>`
justifyContent: 'flex-end',
'&:last-child': {
paddingRight: '16px',
paddingRight: 16,
},
})
}
Expand Down
10 changes: 8 additions & 2 deletions centrifuge-app/src/components/DataTableGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,15 @@ import { Card, Stack } from '@centrifuge/fabric'
import * as React from 'react'
import { DataTableProps } from './DataTable'

export function DataTableGroup({ children }: { children: React.ReactElement<DataTableProps>[] }) {
export function DataTableGroup({
children,
rounded = true,
}: {
children: React.ReactElement<DataTableProps>[]
rounded?: boolean
}) {
return (
<Stack as={Card} gap="3">
<Stack as={rounded ? Card : undefined} gap="3">
{React.Children.map(children, (child, index) => {
return React.isValidElement(child)
? React.cloneElement(child, {
Expand Down
Loading

0 comments on commit 5aa1b52

Please sign in to comment.