🚸 (theme) Move isBrandingEnable param in the Theme tab
This commit is contained in:
@@ -1,24 +1,15 @@
|
|||||||
import {
|
import {
|
||||||
Flex,
|
|
||||||
FormControl,
|
FormControl,
|
||||||
FormLabel,
|
FormLabel,
|
||||||
HStack,
|
HStack,
|
||||||
Stack,
|
Stack,
|
||||||
Switch,
|
|
||||||
Tag,
|
Tag,
|
||||||
useDisclosure,
|
|
||||||
Text,
|
Text,
|
||||||
} from '@chakra-ui/react'
|
} from '@chakra-ui/react'
|
||||||
import { useWorkspace } from '@/features/workspace/WorkspaceProvider'
|
|
||||||
import { Plan } from '@typebot.io/prisma'
|
|
||||||
import { GeneralSettings, rememberUserStorages } from '@typebot.io/schemas'
|
import { GeneralSettings, rememberUserStorages } from '@typebot.io/schemas'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { isDefined } from '@typebot.io/lib'
|
import { isDefined } from '@typebot.io/lib'
|
||||||
import { SwitchWithLabel } from '@/components/inputs/SwitchWithLabel'
|
import { SwitchWithLabel } from '@/components/inputs/SwitchWithLabel'
|
||||||
import { ChangePlanModal } from '@/features/billing/components/ChangePlanModal'
|
|
||||||
import { LockTag } from '@/features/billing/components/LockTag'
|
|
||||||
import { isFreePlan } from '@/features/billing/helpers/isFreePlan'
|
|
||||||
import { useI18n } from '@/locales'
|
|
||||||
import { SwitchWithRelatedSettings } from '@/components/SwitchWithRelatedSettings'
|
import { SwitchWithRelatedSettings } from '@/components/SwitchWithRelatedSettings'
|
||||||
import { DropdownList } from '@/components/DropdownList'
|
import { DropdownList } from '@/components/DropdownList'
|
||||||
import { MoreInfoTooltip } from '@/components/MoreInfoTooltip'
|
import { MoreInfoTooltip } from '@/components/MoreInfoTooltip'
|
||||||
@@ -32,18 +23,6 @@ export const GeneralSettingsForm = ({
|
|||||||
generalSettings,
|
generalSettings,
|
||||||
onGeneralSettingsChange,
|
onGeneralSettingsChange,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const t = useI18n()
|
|
||||||
const { isOpen, onOpen, onClose } = useDisclosure()
|
|
||||||
const { workspace } = useWorkspace()
|
|
||||||
const isWorkspaceFreePlan = isFreePlan(workspace)
|
|
||||||
const handleSwitchChange = () => {
|
|
||||||
if (generalSettings?.isBrandingEnabled && isWorkspaceFreePlan) return
|
|
||||||
onGeneralSettingsChange({
|
|
||||||
...generalSettings,
|
|
||||||
isBrandingEnabled: !generalSettings?.isBrandingEnabled,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const toggleRememberUser = (isEnabled: boolean) =>
|
const toggleRememberUser = (isEnabled: boolean) =>
|
||||||
onGeneralSettingsChange({
|
onGeneralSettingsChange({
|
||||||
...generalSettings,
|
...generalSettings,
|
||||||
@@ -78,26 +57,6 @@ export const GeneralSettingsForm = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack spacing={6}>
|
<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">
|
|
||||||
Typebot.io branding{' '}
|
|
||||||
{isWorkspaceFreePlan && <LockTag plan={Plan.STARTER} />}
|
|
||||||
</FormLabel>
|
|
||||||
<Switch
|
|
||||||
id="branding"
|
|
||||||
isChecked={generalSettings.isBrandingEnabled}
|
|
||||||
onChange={handleSwitchChange}
|
|
||||||
/>
|
|
||||||
</Flex>
|
|
||||||
<SwitchWithLabel
|
<SwitchWithLabel
|
||||||
label="Prefill input"
|
label="Prefill input"
|
||||||
initialValue={generalSettings.isInputPrefillEnabled ?? true}
|
initialValue={generalSettings.isInputPrefillEnabled ?? true}
|
||||||
|
|||||||
@@ -42,6 +42,12 @@ export const ThemeSideMenu = () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateBranding = (isBrandingEnabled: boolean) =>
|
||||||
|
typebot &&
|
||||||
|
updateTypebot({
|
||||||
|
settings: { ...typebot.settings, general: { isBrandingEnabled } },
|
||||||
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack
|
<Stack
|
||||||
flex="1"
|
flex="1"
|
||||||
@@ -87,15 +93,17 @@ export const ThemeSideMenu = () => {
|
|||||||
<AccordionButton py={6}>
|
<AccordionButton py={6}>
|
||||||
<HStack flex="1" pl={2}>
|
<HStack flex="1" pl={2}>
|
||||||
<DropletIcon />
|
<DropletIcon />
|
||||||
<Heading fontSize="lg">Font & Background</Heading>
|
<Heading fontSize="lg">Global</Heading>
|
||||||
</HStack>
|
</HStack>
|
||||||
<AccordionIcon />
|
<AccordionIcon />
|
||||||
</AccordionButton>
|
</AccordionButton>
|
||||||
<AccordionPanel pb={4}>
|
<AccordionPanel pb={4}>
|
||||||
{typebot && (
|
{typebot && (
|
||||||
<GeneralSettings
|
<GeneralSettings
|
||||||
|
isBrandingEnabled={typebot.settings.general.isBrandingEnabled}
|
||||||
generalTheme={typebot.theme.general}
|
generalTheme={typebot.theme.general}
|
||||||
onGeneralThemeChange={updateGeneralTheme}
|
onGeneralThemeChange={updateGeneralTheme}
|
||||||
|
onBrandingChange={updateBranding}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</AccordionPanel>
|
</AccordionPanel>
|
||||||
|
|||||||
@@ -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 { Background, GeneralTheme } from '@typebot.io/schemas'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { BackgroundSelector } from './BackgroundSelector'
|
import { BackgroundSelector } from './BackgroundSelector'
|
||||||
import { FontSelector } from './FontSelector'
|
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 = {
|
type Props = {
|
||||||
|
isBrandingEnabled: boolean
|
||||||
generalTheme: GeneralTheme
|
generalTheme: GeneralTheme
|
||||||
onGeneralThemeChange: (general: GeneralTheme) => void
|
onGeneralThemeChange: (general: GeneralTheme) => void
|
||||||
|
onBrandingChange: (isBrandingEnabled: boolean) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GeneralSettings = ({
|
export const GeneralSettings = ({
|
||||||
|
isBrandingEnabled,
|
||||||
generalTheme,
|
generalTheme,
|
||||||
onGeneralThemeChange,
|
onGeneralThemeChange,
|
||||||
|
onBrandingChange,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
|
const t = useI18n()
|
||||||
|
const { isOpen, onOpen, onClose } = useDisclosure()
|
||||||
|
const { workspace } = useWorkspace()
|
||||||
|
const isWorkspaceFreePlan = isFreePlan(workspace)
|
||||||
|
|
||||||
const handleSelectFont = (font: string) =>
|
const handleSelectFont = (font: string) =>
|
||||||
onGeneralThemeChange({ ...generalTheme, font })
|
onGeneralThemeChange({ ...generalTheme, font })
|
||||||
|
|
||||||
const handleBackgroundChange = (background: Background) =>
|
const handleBackgroundChange = (background: Background) =>
|
||||||
onGeneralThemeChange({ ...generalTheme, background })
|
onGeneralThemeChange({ ...generalTheme, background })
|
||||||
|
|
||||||
|
const updateBranding = () => {
|
||||||
|
if (isBrandingEnabled && isWorkspaceFreePlan) return
|
||||||
|
onBrandingChange(!isBrandingEnabled)
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack spacing={6}>
|
<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
|
<FontSelector
|
||||||
activeFont={generalTheme.font}
|
activeFont={generalTheme.font}
|
||||||
onSelectFont={handleSelectFont}
|
onSelectFont={handleSelectFont}
|
||||||
|
|||||||
Reference in New Issue
Block a user