common component props
This commit is contained in:
@@ -1,21 +1,24 @@
|
||||
import * as React from "react";
|
||||
import { ComponentProps } from "../report.props";
|
||||
import { buildLatestItems } from "./LatestItems.adapter";
|
||||
import LatestItemsView from "./LatestItems.view";
|
||||
import { LatestItemsProps } from "./LatestItems.props";
|
||||
|
||||
type Props = ComponentProps;
|
||||
export default function LatestItems(props: LatestItemsProps) {
|
||||
const {
|
||||
reportData,
|
||||
state,
|
||||
stateSetters,
|
||||
isFetching,
|
||||
} = props;
|
||||
|
||||
export default function LatestItems({
|
||||
reportData,
|
||||
state,
|
||||
stateSetters,
|
||||
header,
|
||||
accentColor = "",
|
||||
isFetching,
|
||||
}: Props) {
|
||||
const { flow, selectedPeriodId, selectedGroupKey } = state;
|
||||
const [visibleCount, setVisibleCount] = React.useState(5);
|
||||
|
||||
// Reset count when flow changes to start clean
|
||||
React.useEffect(() => {
|
||||
setVisibleCount(5);
|
||||
}, [flow]);
|
||||
|
||||
const allItems = React.useMemo(() => {
|
||||
return buildLatestItems(reportData, selectedPeriodId, selectedGroupKey, flow);
|
||||
}, [reportData, selectedPeriodId, selectedGroupKey, flow]);
|
||||
@@ -28,11 +31,9 @@ export default function LatestItems({
|
||||
|
||||
return (
|
||||
<LatestItemsView
|
||||
{...props}
|
||||
items={visibleItems}
|
||||
header={header}
|
||||
accentColor={accentColor}
|
||||
canExpand={canExpand}
|
||||
isFetching={isFetching}
|
||||
onExpand={() => setVisibleCount((prev) => prev + 5)}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user