2022-02-12 10:23:58 +01:00
|
|
|
import { Button, HStack, Tag, useDisclosure, Text } from '@chakra-ui/react'
|
|
|
|
import { FolderPlusIcon } from 'assets/icons'
|
2022-04-05 14:55:19 +02:00
|
|
|
import { UpgradeModal } from 'components/shared/modals/UpgradeModal'
|
|
|
|
import { LimitReached } from 'components/shared/modals/UpgradeModal/UpgradeModal'
|
2022-05-13 15:22:44 -07:00
|
|
|
import { useWorkspace } from 'contexts/WorkspaceContext'
|
2022-02-12 10:23:58 +01:00
|
|
|
import React from 'react'
|
2022-05-13 15:22:44 -07:00
|
|
|
import { isFreePlan } from 'services/workspace'
|
2022-02-12 10:23:58 +01:00
|
|
|
|
|
|
|
type Props = { isLoading: boolean; onClick: () => void }
|
|
|
|
|
|
|
|
export const CreateFolderButton = ({ isLoading, onClick }: Props) => {
|
2022-05-13 15:22:44 -07:00
|
|
|
const { workspace } = useWorkspace()
|
2022-02-12 10:23:58 +01:00
|
|
|
const { isOpen, onOpen, onClose } = useDisclosure()
|
|
|
|
|
|
|
|
const handleClick = () => {
|
2022-05-13 15:22:44 -07:00
|
|
|
if (isFreePlan(workspace)) return onOpen()
|
2022-02-12 10:23:58 +01:00
|
|
|
onClick()
|
|
|
|
}
|
|
|
|
return (
|
|
|
|
<Button
|
|
|
|
leftIcon={<FolderPlusIcon />}
|
|
|
|
onClick={handleClick}
|
|
|
|
isLoading={isLoading}
|
|
|
|
>
|
|
|
|
<HStack>
|
|
|
|
<Text>Create a folder</Text>
|
2022-05-13 15:22:44 -07:00
|
|
|
{isFreePlan(workspace) && <Tag colorScheme="orange">Pro</Tag>}
|
2022-02-12 10:23:58 +01:00
|
|
|
</HStack>
|
2022-02-12 12:54:16 +01:00
|
|
|
<UpgradeModal
|
|
|
|
isOpen={isOpen}
|
|
|
|
onClose={onClose}
|
|
|
|
type={LimitReached.FOLDER}
|
|
|
|
/>
|
2022-02-12 10:23:58 +01:00
|
|
|
</Button>
|
|
|
|
)
|
|
|
|
}
|