2022-02-14 16:41:39 +01:00
|
|
|
import { Button, ButtonProps, useDisclosure } from '@chakra-ui/react'
|
2022-06-01 12:09:45 +02:00
|
|
|
import { useWorkspace } from 'contexts/WorkspaceContext'
|
2022-02-14 16:41:39 +01:00
|
|
|
import React from 'react'
|
2022-06-01 12:09:45 +02:00
|
|
|
import { isNotDefined } from 'utils'
|
2022-09-17 16:37:33 +02:00
|
|
|
import { ChangePlanModal } from '../modals/ChangePlanModal'
|
|
|
|
import { LimitReached } from '../modals/ChangePlanModal'
|
2022-02-14 16:41:39 +01:00
|
|
|
|
2022-09-17 16:37:33 +02:00
|
|
|
type Props = { type?: LimitReached } & ButtonProps
|
2022-02-14 16:41:39 +01:00
|
|
|
|
2022-09-17 16:37:33 +02:00
|
|
|
export const UpgradeButton = ({ type, ...props }: Props) => {
|
2022-02-14 16:41:39 +01:00
|
|
|
const { isOpen, onOpen, onClose } = useDisclosure()
|
2022-06-01 12:09:45 +02:00
|
|
|
const { workspace } = useWorkspace()
|
2022-02-14 16:41:39 +01:00
|
|
|
return (
|
2022-06-01 12:09:45 +02:00
|
|
|
<Button
|
|
|
|
colorScheme="blue"
|
|
|
|
{...props}
|
|
|
|
isLoading={isNotDefined(workspace)}
|
|
|
|
onClick={onOpen}
|
|
|
|
>
|
2022-02-18 14:57:10 +01:00
|
|
|
{props.children ?? 'Upgrade'}
|
2022-09-17 16:37:33 +02:00
|
|
|
<ChangePlanModal isOpen={isOpen} onClose={onClose} type={type} />
|
2022-02-14 16:41:39 +01:00
|
|
|
</Button>
|
|
|
|
)
|
|
|
|
}
|