Skip to content

Commit

Permalink
feat(results): 🛂 Limit typebot branding
Browse files Browse the repository at this point in the history
  • Loading branch information
baptisteArno committed Feb 13, 2022
1 parent f46ba38 commit f57827c
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
2 changes: 1 addition & 1 deletion apps/builder/components/account/SubscriptionTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const SubscriptionTag = ({ plan }: { plan?: Plan }) => {
return <Tag>Offered</Tag>
}
case Plan.PRO: {
return <Tag colorScheme="blue">Pro plan</Tag>
return <Tag colorScheme="orange">Pro plan</Tag>
}
default: {
return <Tag>Free plan</Tag>
Expand Down
29 changes: 25 additions & 4 deletions apps/builder/components/settings/GeneralSettingsForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
import { Flex, FormLabel, Stack, Switch } from '@chakra-ui/react'
import {
Flex,
FormLabel,
Stack,
Switch,
Tag,
useDisclosure,
} from '@chakra-ui/react'
import { UpgradeModal } from 'components/shared/modals/UpgradeModal.'
import { useUser } from 'contexts/UserContext'
import { GeneralSettings } from 'models'
import React from 'react'
import { isFreePlan } from 'services/user'

type Props = {
generalSettings: GeneralSettings
Expand All @@ -11,16 +21,27 @@ export const GeneralSettingsForm = ({
generalSettings,
onGeneralSettingsChange,
}: Props) => {
const handleSwitchChange = () =>
const { isOpen, onOpen, onClose } = useDisclosure()
const { user } = useUser()
const isUserFreePlan = isFreePlan(user)
const handleSwitchChange = () => {
if (generalSettings?.isBrandingEnabled && isUserFreePlan) return
onGeneralSettingsChange({
isBrandingEnabled: !generalSettings?.isBrandingEnabled,
})
}

return (
<Stack spacing={6}>
<Flex justifyContent="space-between" align="center">
<UpgradeModal isOpen={isOpen} onClose={onClose} />
<Flex
justifyContent="space-between"
align="center"
onClick={isUserFreePlan ? onOpen : undefined}
>
<FormLabel htmlFor="branding" mb="0">
Typebot.io branding
Typebot.io branding{' '}
{isUserFreePlan && <Tag colorScheme="orange">Pro</Tag>}
</FormLabel>
<Switch
id="branding"
Expand Down
20 changes: 20 additions & 0 deletions apps/builder/playwright/tests/settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,24 @@ test.describe.parallel('Settings page', () => {
await page.fill('textarea#description', 'Lorem ipsum')
})
})

test.describe('Free user', () => {
test.use({
storageState: path.join(__dirname, '../freeUser.json'),
})
test("can't remove branding", async ({ page }) => {
const typebotId = 'free-branding-typebot'
await importTypebotInDatabase(
path.join(__dirname, '../fixtures/typebots/theme.json'),
{
id: typebotId,
}
)
await page.goto(`/typebots/${typebotId}/settings`)
await page.click('button:has-text("General")')
await expect(page.locator('text=Pro')).toBeVisible()
await page.click('text=Typebot.io branding')
await expect(page.locator('text=Upgrade now')).toBeVisible()
})
})
})

3 comments on commit f57827c

@vercel
Copy link

@vercel vercel bot commented on f57827c Feb 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

viewer-v2 – ./apps/viewer

viewer-v2-typebot-io.vercel.app
typebot-viewer.vercel.app
viewer-v2-git-main-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f57827c Feb 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

builder-v2 – ./apps/builder

next.typebot.io
builder-v2-git-main-typebot-io.vercel.app
builder-v2-typebot-io.vercel.app

@vercel
Copy link

@vercel vercel bot commented on f57827c Feb 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

landing-page-v2 – ./apps/landing-page

landing-page-v2-typebot-io.vercel.app
landing-page-v2-git-main-typebot-io.vercel.app
landing-page-v2-jade.vercel.app

Please sign in to comment.