Skip to content

Commit 695853b

Browse files
Add reporting chart beta component (#116)
* Add ReportingChart beta component * Import types from connect-js * Undo change to src/types
1 parent 3328692 commit 695853b

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

src/Components.tsx

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import {
1212
NotificationCount,
1313
InstallState,
1414
StepChange,
15+
IntervalType,
16+
ReportName,
1517
} from '@stripe/connect-js';
1618

1719
export type CommonComponentProps = {
@@ -649,3 +651,51 @@ export const ConnectTaxSettings = ({
649651

650652
return wrapper;
651653
};
654+
655+
export const ConnectReportingChart = ({
656+
reportName,
657+
intervalStart,
658+
intervalEnd,
659+
intervalType,
660+
onLoadError,
661+
onLoaderStart,
662+
}: {
663+
/**
664+
* @param reportName The name of the report to render as a chart.
665+
* @param intervalStart The start date of the report interval.
666+
* @param intervalEnd The end date of the report interval.
667+
* @param intervalType The type of the report interval.
668+
*/
669+
reportName: ReportName;
670+
intervalStart?: Date;
671+
intervalEnd?: Date;
672+
intervalType?: IntervalType;
673+
} & CommonComponentProps): JSX.Element | null => {
674+
const {wrapper, component: reportingChart} =
675+
useCreateComponent('reporting-chart');
676+
677+
useUpdateWithSetter(reportingChart, reportName, (comp, val) =>
678+
comp.setReportName(val)
679+
);
680+
681+
useUpdateWithSetter(reportingChart, intervalStart, (comp, val) =>
682+
comp.setIntervalStart(val)
683+
);
684+
685+
useUpdateWithSetter(reportingChart, intervalEnd, (comp, val) =>
686+
comp.setIntervalEnd(val)
687+
);
688+
689+
useUpdateWithSetter(reportingChart, intervalType, (comp, val) =>
690+
comp.setIntervalType(val)
691+
);
692+
693+
useUpdateWithSetter(reportingChart, onLoaderStart, (comp, val) => {
694+
comp.setOnLoaderStart(val);
695+
});
696+
useUpdateWithSetter(reportingChart, onLoadError, (comp, val) => {
697+
comp.setOnLoadError(val);
698+
});
699+
700+
return wrapper;
701+
};

src/utils/useUpdateWithSetter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export const useUpdateWithSetter = <
2727
| ((installState: InstallState) => void)
2828
| ((productType: FinancingProductType) => void)
2929
| ((StepChange: StepChange) => void)
30+
| Date
3031
| undefined
3132
>(
3233
component: T | null,

0 commit comments

Comments
 (0)