import { Flex, FormLabel, Stack, Switch, useDisclosure } from '@chakra-ui/react' import { LockTag } from 'components/shared/LockTag' import { ChangePlanModal, LimitReached, } from 'components/shared/modals/ChangePlanModal' import { SwitchWithLabel } from 'components/shared/SwitchWithLabel' import { useWorkspace } from 'contexts/WorkspaceContext' import { Plan } from 'db' import { GeneralSettings } from 'models' import React from 'react' import { isFreePlan } from 'services/workspace' import { isDefined } from 'utils' type Props = { generalSettings: GeneralSettings onGeneralSettingsChange: (generalSettings: GeneralSettings) => void } export const GeneralSettingsForm = ({ generalSettings, onGeneralSettingsChange, }: Props) => { 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 handleNewResultOnRefreshChange = (isRememberSessionChecked: boolean) => onGeneralSettingsChange({ ...generalSettings, isNewResultOnRefreshEnabled: !isRememberSessionChecked, }) const handleInputPrefillChange = (isInputPrefillEnabled: boolean) => onGeneralSettingsChange({ ...generalSettings, isInputPrefillEnabled, }) const handleHideQueryParamsChange = (isHideQueryParamsEnabled: boolean) => onGeneralSettingsChange({ ...generalSettings, isHideQueryParamsEnabled, }) return ( Typebot.io branding{' '} {isWorkspaceFreePlan && } ) }