RocketChat/Rocket.Chat

View on GitHub
apps/meteor/client/views/admin/subscription/components/UpgradeButton.tsx

Summary

Maintainability
A
0 mins
Test Coverage
import { Button } from '@rocket.chat/fuselage';
import type { ButtonProps } from '@rocket.chat/fuselage/dist/components/Button/Button';
import type { ReactElement } from 'react';
import React, { memo } from 'react';

import { useExternalLink } from '../../../../hooks/useExternalLink';
import { useCheckoutUrl } from '../hooks/useCheckoutUrl';

const UpgradeButton = ({
    children,
    target = '_blank',
    action,
    ...props
}: Partial<ButtonProps> & {
    target: string;
    action: string;
}): ReactElement => {
    const handleOpenLink = useExternalLink();
    const url = useCheckoutUrl()({ target, action });

    return (
        <Button icon='new-window' onClick={() => handleOpenLink(url)} {...props}>
            {children}
        </Button>
    );
};

export default memo(UpgradeButton);