2
0

🚸 (theme) Move isBrandingEnable param in the Theme tab

This commit is contained in:
Baptiste Arnaud
2023-07-11 10:43:49 +02:00
parent 3421e4822f
commit a31345ae26
3 changed files with 50 additions and 43 deletions

View File

@ -1,26 +1,66 @@
import { Stack } from '@chakra-ui/react'
import { Flex, FormLabel, Stack, Switch, useDisclosure } from '@chakra-ui/react'
import { Background, GeneralTheme } from '@typebot.io/schemas'
import React from 'react'
import { BackgroundSelector } from './BackgroundSelector'
import { FontSelector } from './FontSelector'
import { LockTag } from '@/features/billing/components/LockTag'
import { Plan } from '@typebot.io/prisma'
import { isFreePlan } from '@/features/billing/helpers/isFreePlan'
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
import { ChangePlanModal } from '@/features/billing/components/ChangePlanModal'
import { useI18n } from '@/locales'
type Props = {
isBrandingEnabled: boolean
generalTheme: GeneralTheme
onGeneralThemeChange: (general: GeneralTheme) => void
onBrandingChange: (isBrandingEnabled: boolean) => void
}
export const GeneralSettings = ({
isBrandingEnabled,
generalTheme,
onGeneralThemeChange,
onBrandingChange,
}: Props) => {
const t = useI18n()
const { isOpen, onOpen, onClose } = useDisclosure()
const { workspace } = useWorkspace()
const isWorkspaceFreePlan = isFreePlan(workspace)
const handleSelectFont = (font: string) =>
onGeneralThemeChange({ ...generalTheme, font })
const handleBackgroundChange = (background: Background) =>
onGeneralThemeChange({ ...generalTheme, background })
const updateBranding = () => {
if (isBrandingEnabled && isWorkspaceFreePlan) return
onBrandingChange(!isBrandingEnabled)
}
return (
<Stack spacing={6}>
<ChangePlanModal
isOpen={isOpen}
onClose={onClose}
type={t('billing.limitMessage.brand')}
/>
<Flex
justifyContent="space-between"
align="center"
onClick={isWorkspaceFreePlan ? onOpen : undefined}
>
<FormLabel htmlFor="branding" mb="0" cursor="pointer">
Show Typebot brand{' '}
{isWorkspaceFreePlan && <LockTag plan={Plan.STARTER} />}
</FormLabel>
<Switch
id="branding"
isChecked={isBrandingEnabled}
onChange={updateBranding}
/>
</Flex>
<FontSelector
activeFont={generalTheme.font}
onSelectFont={handleSelectFont}