Skip to content

Commit

Permalink
Add reporting chart beta component (#116)
Browse files Browse the repository at this point in the history
* Add ReportingChart beta component

* Import types from connect-js

* Undo change to src/types
  • Loading branch information
neerajsamtani-stripe authored Oct 4, 2024
1 parent 3328692 commit 695853b
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/Components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
NotificationCount,
InstallState,
StepChange,
IntervalType,
ReportName,
} from '@stripe/connect-js';

export type CommonComponentProps = {
Expand Down Expand Up @@ -649,3 +651,51 @@ export const ConnectTaxSettings = ({

return wrapper;
};

export const ConnectReportingChart = ({
reportName,
intervalStart,
intervalEnd,
intervalType,
onLoadError,
onLoaderStart,
}: {
/**
* @param reportName The name of the report to render as a chart.
* @param intervalStart The start date of the report interval.
* @param intervalEnd The end date of the report interval.
* @param intervalType The type of the report interval.
*/
reportName: ReportName;
intervalStart?: Date;
intervalEnd?: Date;
intervalType?: IntervalType;
} & CommonComponentProps): JSX.Element | null => {
const {wrapper, component: reportingChart} =
useCreateComponent('reporting-chart');

useUpdateWithSetter(reportingChart, reportName, (comp, val) =>
comp.setReportName(val)
);

useUpdateWithSetter(reportingChart, intervalStart, (comp, val) =>
comp.setIntervalStart(val)
);

useUpdateWithSetter(reportingChart, intervalEnd, (comp, val) =>
comp.setIntervalEnd(val)
);

useUpdateWithSetter(reportingChart, intervalType, (comp, val) =>
comp.setIntervalType(val)
);

useUpdateWithSetter(reportingChart, onLoaderStart, (comp, val) => {
comp.setOnLoaderStart(val);
});
useUpdateWithSetter(reportingChart, onLoadError, (comp, val) => {
comp.setOnLoadError(val);
});

return wrapper;
};
1 change: 1 addition & 0 deletions src/utils/useUpdateWithSetter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export const useUpdateWithSetter = <
| ((installState: InstallState) => void)
| ((productType: FinancingProductType) => void)
| ((StepChange: StepChange) => void)
| Date
| undefined
>(
component: T | null,
Expand Down

0 comments on commit 695853b

Please sign in to comment.