2
0
Files
bot/apps/builder/components/shared/buttons/UpgradeButton.tsx
2022-09-27 08:30:42 +02:00

25 lines
779 B
TypeScript

import { Button, ButtonProps, useDisclosure } from '@chakra-ui/react'
import { useWorkspace } from 'contexts/WorkspaceContext'
import React from 'react'
import { isNotDefined } from 'utils'
import { ChangePlanModal } from '../modals/ChangePlanModal'
import { LimitReached } from '../modals/ChangePlanModal'
type Props = { type?: LimitReached } & ButtonProps
export const UpgradeButton = ({ type, ...props }: Props) => {
const { isOpen, onOpen, onClose } = useDisclosure()
const { workspace } = useWorkspace()
return (
<Button
colorScheme="blue"
{...props}
isLoading={isNotDefined(workspace)}
onClick={onOpen}
>
{props.children ?? 'Upgrade'}
<ChangePlanModal isOpen={isOpen} onClose={onClose} type={type} />
</Button>
)
}