12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- import {Button} from 'sentry/components/button';
- import {t} from 'sentry/locale';
- import IndicatorStore from 'sentry/stores/indicatorStore';
- import type {Organization} from 'sentry/types/organization';
- import TrialStarter from 'getsentry/components/trialStarter';
- type ButtonProps = React.ComponentProps<typeof Button>;
- type Props = React.PropsWithChildren<
- {
- organization: Organization;
- source: string;
- analyticsData?: Record<string, any>;
- handleClick?: () => void;
- onTrialFailed?: () => void;
- onTrialStarted?: () => void;
- requestData?: Record<string, unknown>;
- } & ButtonProps
- >;
- function StartTrialButton({
- children,
- organization,
- source,
- onTrialStarted,
- onTrialFailed,
- handleClick,
- requestData,
- analyticsData: _,
- ...buttonProps
- }: Props) {
- return (
- <TrialStarter
- source={source}
- organization={organization}
- onTrialFailed={() => {
- IndicatorStore.addError(t('Error starting trial. Please try again.'));
- onTrialFailed?.();
- }}
- onTrialStarted={onTrialStarted}
- requestData={requestData}
- >
- {({startTrial, trialStarting, trialStarted}) => (
- <Button
- disabled={trialStarting || trialStarted}
- data-test-id="start-trial-button"
- onClick={() => {
- handleClick?.();
- startTrial();
- }}
- {...buttonProps}
- >
- {children || t('Start trial')}
- </Button>
- )}
- </TrialStarter>
- );
- }
- export default StartTrialButton;
|