2
0

feat(settings): Add create result on page refresh option

This commit is contained in:
Baptiste Arnaud
2022-03-07 18:21:01 +01:00
parent e3e07ddd4d
commit 260819f124
5 changed files with 91 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import {
useDisclosure,
} from '@chakra-ui/react'
import { UpgradeModal } from 'components/shared/modals/UpgradeModal.'
import { SwitchWithLabel } from 'components/shared/SwitchWithLabel'
import { useUser } from 'contexts/UserContext'
import { GeneralSettings } from 'models'
import React from 'react'
@ -27,10 +28,19 @@ export const GeneralSettingsForm = ({
const handleSwitchChange = () => {
if (generalSettings?.isBrandingEnabled && isUserFreePlan) return
onGeneralSettingsChange({
...generalSettings,
isBrandingEnabled: !generalSettings?.isBrandingEnabled,
})
}
const handleNewResultOnRefreshChange = (
isNewResultOnRefreshEnabled: boolean
) =>
onGeneralSettingsChange({
...generalSettings,
isNewResultOnRefreshEnabled,
})
return (
<Stack spacing={6}>
<UpgradeModal isOpen={isOpen} onClose={onClose} />
@ -49,6 +59,12 @@ export const GeneralSettingsForm = ({
onChange={handleSwitchChange}
/>
</Flex>
<SwitchWithLabel
id="new-result"
label="Create new session on page refresh"
initialValue={generalSettings.isNewResultOnRefreshEnabled ?? false}
onCheckChange={handleNewResultOnRefreshChange}
/>
</Stack>
)
}

View File

@ -23,6 +23,10 @@ test.describe.parallel('Settings page', () => {
await expect(
typebotViewer(page).locator('a:has-text("Made with Typebot")')
).toBeHidden()
await page.click('text=Create new session on page refresh')
await expect(
page.locator('input[type="checkbox"] >> nth=-1')
).toHaveAttribute('checked', '')
})
})